From owner-svn-src-head@FreeBSD.ORG Tue Nov 20 12:22:40 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 9A4723F3; Tue, 20 Nov 2012 12:22:40 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi [195.197.172.111]) by mx1.freebsd.org (Postfix) with ESMTP id 1DB458FC13; Tue, 20 Nov 2012 12:22:39 +0000 (UTC) Received: from a91-153-116-96.elisa-laajakaista.fi (a91-153-116-96.elisa-laajakaista.fi [91.153.116.96]) by gw03.mail.saunalahti.fi (Postfix) with SMTP id B5B5921661E; Tue, 20 Nov 2012 14:22:27 +0200 (EET) Date: Tue, 20 Nov 2012 14:22:26 +0200 From: Jaakko Heinonen To: Baptiste Daroussin Subject: Re: svn commit: r243328 - head/lib/libutil Message-ID: <20121120122226.GA1828@a91-153-116-96.elisa-laajakaista.fi> References: <201211200722.qAK7M7Im057617@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201211200722.qAK7M7Im057617@svn.freebsd.org> 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:22:40 -0000 Hi! On 2012-11-20, Baptiste Daroussin wrote: > change mode the group file to 0644 after a successfull rename(2) > > int > gr_mkdb(void) > { > - return (rename(tempname, group_file)); > + int ret; > + > + ret = rename(tempname, group_file); > + > + if (ret == 0) > + chmod(group_file, 0644); > + > + return (ret); > } 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? -- Jaakko