Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Feb 2012 13:59:25 +0000 (UTC)
From:      Guy Helmer <ghelmer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r231938 - head/lib/libutil
Message-ID:  <201202201359.q1KDxPrW053932@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ghelmer
Date: Mon Feb 20 13:59:24 2012
New Revision: 231938
URL: http://svn.freebsd.org/changeset/base/231938

Log:
  Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the
  file descriptor via exec(3).
  
  Now that daemon(8) has been fixed to resolve the issue noted by trociny,
  the consensus is that this change should be OK.

Modified:
  head/lib/libutil/pidfile.c

Modified: head/lib/libutil/pidfile.c
==============================================================================
--- head/lib/libutil/pidfile.c	Mon Feb 20 13:22:00 2012	(r231937)
+++ head/lib/libutil/pidfile.c	Mon Feb 20 13:59:24 2012	(r231938)
@@ -124,7 +124,7 @@ pidfile_open(const char *path, mode_t mo
 	 * pidfile_write() can be called multiple times.
 	 */
 	fd = flopen(pfh->pf_path,
-	    O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
+	    O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode);
 	if (fd == -1) {
 		if (errno == EWOULDBLOCK && pidptr != NULL) {
 			count = 20;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202201359.q1KDxPrW053932>