only rename(2) after chmod(2) has succeed

report error if chmod(2) fails

Reported by:	jh
This commit is contained in:
Baptiste Daroussin 2012-11-20 14:03:09 +00:00
parent 02c62349c9
commit 09259e6c48
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=243334

View file

@ -318,14 +318,10 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
int
gr_mkdb(void)
{
int ret;
if (chmod(tempname, 0644) != 0)
return (-1);
ret = rename(tempname, group_file);
if (ret == 0)
chmod(group_file, 0644);
return (ret);
return (rename(tempname, group_file));
}
/*