From owner-svn-src-head@FreeBSD.ORG Tue Jan 10 21:28:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0478E1065677; Tue, 10 Jan 2012 21:28:21 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id A18738FC17; Tue, 10 Jan 2012 21:28:20 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id A96A7D9C; Tue, 10 Jan 2012 22:28:18 +0100 (CET) Date: Tue, 10 Jan 2012 22:27:11 +0100 From: Pawel Jakub Dawidek To: Guy Helmer Message-ID: <20120110212710.GB1694@garage.freebsd.pl> References: <201201101843.q0AIhRuM022949@svn.freebsd.org> <20120110212525.GA1694@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eJnRUKwClWJh1Khz" Content-Disposition: inline In-Reply-To: <20120110212525.GA1694@garage.freebsd.pl> X-OS: FreeBSD 9.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r229936 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 10 Jan 2012 21:28:21 -0000 --eJnRUKwClWJh1Khz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 10, 2012 at 10:25:26PM +0100, Pawel Jakub Dawidek wrote: > On Tue, Jan 10, 2012 at 06:43:27PM +0000, Guy Helmer wrote: > > Author: ghelmer > > Date: Tue Jan 10 18:43:27 2012 > > New Revision: 229936 > > URL: http://svn.freebsd.org/changeset/base/229936 > >=20 > > Log: > > Set the FD_CLOEXEC flag on the open pidfile file descriptor. > > =20 > > Discussed with: pjd, des >=20 > Could you also update manual page to note that pidfile_open(3) can now > also set errno via fcntl(2)? Actually, it would also be useful to document the fact that we now set FD_CLOEXEC flag, so one doesn't have to look at the code to find it. > > Modified: > > head/lib/libutil/pidfile.c > >=20 > > Modified: head/lib/libutil/pidfile.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/lib/libutil/pidfile.c Tue Jan 10 18:20:19 2012 (r229935) > > +++ head/lib/libutil/pidfile.c Tue Jan 10 18:43:27 2012 (r229936) > > @@ -137,6 +137,20 @@ pidfile_open(const char *path, mode_t mo > > free(pfh); > > return (NULL); > > } > > + > > + /* > > + * Prevent the file descriptor from escaping to other > > + * programs via exec(3). > > + */ > > + if (fcntl(fd, F_SETFD, FD_CLOEXEC) =3D=3D -1) { > > + error =3D errno; > > + unlink(pfh->pf_path); > > + close(fd); > > + free(pfh); > > + errno =3D error; > > + return (NULL); > > + } > > + > > /* > > * Remember file information, so in pidfile_write() we are sure we wr= ite > > * to the proper descriptor. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --eJnRUKwClWJh1Khz Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk8MrS0ACgkQForvXbEpPzQxogCfa/9gbXsgdYUPnmaUlYiAnA92 B58An3t1bIujsh51y1Xber8lyCy7NikY =9emm -----END PGP SIGNATURE----- --eJnRUKwClWJh1Khz--