From owner-freebsd-bugs@FreeBSD.ORG  Thu Jun 14 05:40:03 2012
Return-Path: <owner-freebsd-bugs@FreeBSD.ORG>
Delivered-To: freebsd-bugs@hub.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 8E7511065672
	for <freebsd-bugs@hub.freebsd.org>;
	Thu, 14 Jun 2012 05:40:03 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40])
	by mx1.freebsd.org (Postfix) with ESMTP id 7223E8FC14
	for <freebsd-bugs@hub.freebsd.org>;
	Thu, 14 Jun 2012 05:40:03 +0000 (UTC)
Received: from freefall.freebsd.org (localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5E5e38M008716
	for <freebsd-bugs@freefall.freebsd.org>; Thu, 14 Jun 2012 05:40:03 GMT
	(envelope-from gnats@freefall.freebsd.org)
Received: (from gnats@localhost)
	by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q5E5e33x008715;
	Thu, 14 Jun 2012 05:40:03 GMT (envelope-from gnats)
Date: Thu, 14 Jun 2012 05:40:03 GMT
Message-Id: <201206140540.q5E5e33x008715@freefall.freebsd.org>
To: freebsd-bugs@FreeBSD.org
From: "Jukka A. Ukkonen" <jau@oxit.fi>
Cc: 
Subject: Re: misc/169023: setfsent(), getfsent(), etc. leave /etc/fstab open
 after exec()
X-BeenThere: freebsd-bugs@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: "Jukka A. Ukkonen" <jau@oxit.fi>
List-Id: Bug reports <freebsd-bugs.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs>
List-Post: <mailto:freebsd-bugs@freebsd.org>
List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 14 Jun 2012 05:40:03 -0000

The following reply was made to PR misc/169023; it has been noted by GNATS.

From: "Jukka A. Ukkonen" <jau@oxit.fi>
To: bug-followup@FreeBSD.org, jau@iki.fi
Cc:  
Subject: Re: misc/169023: setfsent(), getfsent(), etc. leave /etc/fstab open
 after exec()
Date: Thu, 14 Jun 2012 08:34:06 +0300

 This is a multi-part message in MIME format.
 --------------090001050406070603010704
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 A better version of the same patch which now uses _fcntl() instead of 
 plain fcntl().
 
 
 
 --------------090001050406070603010704
 Content-Type: text/plain; charset=UTF-8;
  name="setfsent-cloexec.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="setfsent-cloexec.patch"
 
 --- lib/libc/gen/fstab.c.orig	2012-04-17 14:54:01.000000000 +0300
 +++ lib/libc/gen/fstab.c	2012-06-14 07:30:23.000000000 +0300
 @@ -45,6 +45,7 @@
  #include <stdlib.h>
  #include <string.h>
  #include <unistd.h>
 +#include <fcntl.h>
  #include "un-namespace.h"
  
  static FILE *_fs_fp;
 @@ -258,6 +259,11 @@
  			setfstab(getenv("PATH_FSTAB"));
  	}
  	if ((_fs_fp = fopen(path_fstab, "r")) != NULL) {
 +		int	fd;
 +
 +		fd = fileno (_fs_fp);
 +		(void) _fcntl (fd, F_SETFD, FD_CLOEXEC);
 +
  		LineNo = 0;
  		return(1);
  	}
 
 --------------090001050406070603010704--