Date: Tue, 10 Jan 2012 22:25:26 +0100 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Guy Helmer <ghelmer@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r229936 - head/lib/libutil Message-ID: <20120110212525.GA1694@garage.freebsd.pl> In-Reply-To: <201201101843.q0AIhRuM022949@svn.freebsd.org> References: <201201101843.q0AIhRuM022949@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] 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 > > Log: > Set the FD_CLOEXEC flag on the open pidfile file descriptor. > > Discussed with: pjd, des Could you also update manual page to note that pidfile_open(3) can now also set errno via fcntl(2)? > Modified: > head/lib/libutil/pidfile.c > > Modified: head/lib/libutil/pidfile.c > ============================================================================== > --- 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) == -1) { > + error = errno; > + unlink(pfh->pf_path); > + close(fd); > + free(pfh); > + errno = error; > + return (NULL); > + } > + > /* > * Remember file information, so in pidfile_write() we are sure we write > * to the proper descriptor. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk8MrMUACgkQForvXbEpPzREVQCgud/IWcYtGthH+KWcv70yASfg s/UAn14wIVzxl42Gn62dZ4VgTynEe4Wo =PeFr -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120110212525.GA1694>
