misc/169023: setfsent(), getfsent(), etc. leave /etc/fstab open after exec()

Jukka A. Ukkonen jau at oxit.fi
Thu Jun 14 05:40:03 UTC 2012


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

From: "Jukka A. Ukkonen" <jau at oxit.fi>
To: bug-followup at FreeBSD.org, jau at 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--


More information about the freebsd-bugs mailing list