svn commit: r221830 - head/lib/libfetch

Dag-Erling Smorgrav des at FreeBSD.org
Fri May 13 07:21:43 UTC 2011


Author: des
Date: Fri May 13 07:21:41 2011
New Revision: 221830
URL: http://svn.freebsd.org/changeset/base/221830

Log:
  Mark all socket and file descriptors close-on-exec.
  
  PR:		bin/151866
  MFC after:	3 weeks

Modified:
  head/lib/libfetch/common.c
  head/lib/libfetch/file.c

Modified: head/lib/libfetch/common.c
==============================================================================
--- head/lib/libfetch/common.c	Fri May 13 05:27:58 2011	(r221829)
+++ head/lib/libfetch/common.c	Fri May 13 07:21:41 2011	(r221830)
@@ -213,6 +213,7 @@ fetch_reopen(int sd)
 	/* allocate and fill connection structure */
 	if ((conn = calloc(1, sizeof(*conn))) == NULL)
 		return (NULL);
+	fcntl(sd, F_SETFD, FD_CLOEXEC);
 	conn->sd = sd;
 	++conn->ref;
 	return (conn);

Modified: head/lib/libfetch/file.c
==============================================================================
--- head/lib/libfetch/file.c	Fri May 13 05:27:58 2011	(r221829)
+++ head/lib/libfetch/file.c	Fri May 13 07:21:41 2011	(r221830)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/stat.h>
 
 #include <dirent.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -57,6 +58,7 @@ fetchXGetFile(struct url *u, struct url_
 		fetch_syserr();
 	}
 
+	fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 	return (f);
 }
 
@@ -84,6 +86,7 @@ fetchPutFile(struct url *u, const char *
 		fetch_syserr();
 	}
 
+	fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 	return (f);
 }
 


More information about the svn-src-all mailing list