From owner-svn-src-all@FreeBSD.ORG Mon Feb 20 13:59:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A9CA106566C; Mon, 20 Feb 2012 13:59:25 +0000 (UTC) (envelope-from ghelmer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A3E68FC15; Mon, 20 Feb 2012 13:59:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1KDxPPF053934; Mon, 20 Feb 2012 13:59:25 GMT (envelope-from ghelmer@svn.freebsd.org) Received: (from ghelmer@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1KDxPrW053932; Mon, 20 Feb 2012 13:59:25 GMT (envelope-from ghelmer@svn.freebsd.org) Message-Id: <201202201359.q1KDxPrW053932@svn.freebsd.org> From: Guy Helmer Date: Mon, 20 Feb 2012 13:59:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231938 - head/lib/libutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Feb 2012 13:59:25 -0000 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;