Date: Tue, 20 Nov 2012 13:43:08 +0100 From: Baptiste Daroussin <bapt@FreeBSD.org> To: Jaakko Heinonen <jh@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r243328 - head/lib/libutil Message-ID: <20121120124307.GJ71195@ithaqua.etoilebsd.net> In-Reply-To: <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi> References: <201211200722.qAK7M7Im057617@svn.freebsd.org> <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
--zYjDATHXTWnytHRU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 20, 2012 at 02:22:26PM +0200, Jaakko Heinonen wrote: >=20 > Hi! >=20 > On 2012-11-20, Baptiste Daroussin wrote: > > change mode the group file to 0644 after a successfull rename(2) > >=20 > > int > > gr_mkdb(void) > > { > > - return (rename(tempname, group_file)); > > + int ret; > > + > > + ret =3D rename(tempname, group_file); > > + > > + if (ret =3D=3D 0) > > + chmod(group_file, 0644); > > + > > + return (ret); > > } >=20 > Rename+chmod is not an atomic operation. There is a window when the file > has wrong permissions. Also, you don't check the return value of > chmod(). Maybe chmod first and then rename? >=20 > --=20 > Jaakko Yes you are right chmod should probably be first. regards, Bapt --zYjDATHXTWnytHRU Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlCretsACgkQ8kTtMUmk6EwBDACbB16OGN7Ldql22OLC7wibz7H9 ECsAoL21HP7HC4tBF6Dej6jQM5bInlMZ =/UGf -----END PGP SIGNATURE----- --zYjDATHXTWnytHRU--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121120124307.GJ71195>