summaryrefslogtreecommitdiffstats
path: root/lib/libfetch
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2011-05-13 07:21:41 +0000
committerdes <des@FreeBSD.org>2011-05-13 07:21:41 +0000
commit410ff8d8e2715a88fd3194f1a7a96cec047fb67b (patch)
tree08dfd8f2074bf1e9a290755f2e8e5876c4ceebf8 /lib/libfetch
parentbbbc4c545502c531d59efe43f9b7bde9b9a92979 (diff)
downloadFreeBSD-src-410ff8d8e2715a88fd3194f1a7a96cec047fb67b.zip
FreeBSD-src-410ff8d8e2715a88fd3194f1a7a96cec047fb67b.tar.gz
Mark all socket and file descriptors close-on-exec.
PR: bin/151866 MFC after: 3 weeks
Diffstat (limited to 'lib/libfetch')
-rw-r--r--lib/libfetch/common.c1
-rw-r--r--lib/libfetch/file.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index ff10d27..fefc4c5 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -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);
diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c
index a1492ba..dffaad8 100644
--- a/lib/libfetch/file.c
+++ b/lib/libfetch/file.c
@@ -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_stat *us, const char *flags)
fetch_syserr();
}
+ fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
return (f);
}
@@ -84,6 +86,7 @@ fetchPutFile(struct url *u, const char *flags)
fetch_syserr();
}
+ fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
return (f);
}
OpenPOWER on IntegriCloud