From owner-svn-src-head@FreeBSD.ORG Tue Nov 20 12:43:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F8FAEA0; Tue, 20 Nov 2012 12:43:12 +0000 (UTC) (envelope-from baptiste.daroussin@gmail.com) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 228528FC12; Tue, 20 Nov 2012 12:43:10 +0000 (UTC) Received: by mail-wg0-f50.google.com with SMTP id 12so2470923wgr.31 for ; Tue, 20 Nov 2012 04:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=efdeaWj9lhvVdEPOUPkynFSzE8zXRmevFqty4rkcJ4c=; b=wgbHUkCue3YmXUV5VQ5eC0Ewx0Hqwn0IPr7FVqVBm9k5WBB4N8QE9LDAHvkBQDll/w 1EemqpgNtBSpQfu+IjfL5T58UmhziRMiZMHIEMO3uGdhuJYBCXr1Roc1LRjWDGQ+SEhx o6D89RweSl0xtR3PCLrZps4ox6bNyY4oppn0ggktGkiX6TX7HbViL/8DBa0og2P1VS/f joz8/nO+vPJXXSY6qYzbZ/ntskW0w9oFbFCTpMwhunMLAjX850Uc4Pb245rDlaVPU6QI g0GR4jEZnenTJJ6Tkdp5xTT5ldeDL7jRnikT5AiJgEUjTQV/LBiBSSViHB1rgkSezagG DuCw== Received: by 10.180.24.193 with SMTP id w1mr14207251wif.22.1353415390076; Tue, 20 Nov 2012 04:43:10 -0800 (PST) Received: from ithaqua.etoilebsd.net (ithaqua.etoilebsd.net. [37.59.37.188]) by mx.google.com with ESMTPS id i2sm17615416wiw.3.2012.11.20.04.43.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 04:43:09 -0800 (PST) Sender: Baptiste Daroussin Date: Tue, 20 Nov 2012 13:43:08 +0100 From: Baptiste Daroussin To: Jaakko Heinonen Subject: Re: svn commit: r243328 - head/lib/libutil Message-ID: <20121120124307.GJ71195@ithaqua.etoilebsd.net> References: <201211200722.qAK7M7Im057617@svn.freebsd.org> <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zYjDATHXTWnytHRU" Content-Disposition: inline In-Reply-To: <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 12:43:12 -0000 --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--