diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2012-11-20 14:03:09 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2012-11-20 14:03:09 +0000 |
commit | 99799f94bd83e6e3821bed79cef8571670c3f021 (patch) | |
tree | 73ccb563a55d7a8d862bb0d4b325b497627b858a /libutil | |
parent | b0d96cba2224b5fa66661c07e685d542bf38b196 (diff) | |
download | pw-darwin-99799f94bd83e6e3821bed79cef8571670c3f021.tar.gz pw-darwin-99799f94bd83e6e3821bed79cef8571670c3f021.tar.zst pw-darwin-99799f94bd83e6e3821bed79cef8571670c3f021.zip |
only rename(2) after chmod(2) has succeed
report error if chmod(2) fails
Reported by: jh
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/gr_util.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libutil/gr_util.c b/libutil/gr_util.c index 8d0490b..be34395 100644 --- a/libutil/gr_util.c +++ b/libutil/gr_util.c @@ -318,14 +318,10 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr) int gr_mkdb(void) { - int ret; - - ret = rename(tempname, group_file); - - if (ret == 0) - chmod(group_file, 0644); + if (chmod(tempname, 0644) != 0) + return (-1); - return (ret); + return (rename(tempname, group_file)); } /* |