Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 May 2011 07:21:41 +0000 (UTC)
From:      Dag-Erling Smorgrav <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221830 - head/lib/libfetch
Message-ID:  <201105130721.p4D7LfIM063129@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



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