summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-14 13:50:35 +0100
committerTom Gundersen <teg@jklm.no>2014-01-14 14:09:01 +0100
commit8a6233fb653098c14d84430b3516edd63265d405 (patch)
tree16ae8ba189fcf2f38b4f6abf20880085eefe2d72 /src
parent12f404c4d1dc31a54013646473249b4644fc23e7 (diff)
sd-resolv: require SOCK_CLOEXEC
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-resolv.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index aa97ef7699..8845d6e784 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -415,8 +415,8 @@ static void* thread_worker(void *p) {
}
sd_resolv_t* sd_resolv_new(unsigned n_proc) {
- int i;
sd_resolv_t *resolv = NULL;
+ int i, r;
assert(n_proc >= 1);
@@ -437,27 +437,15 @@ sd_resolv_t* sd_resolv_new(unsigned n_proc) {
memset(resolv->queries, 0, sizeof(resolv->queries));
-#ifdef SOCK_CLOEXEC
- if (socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds) < 0 ||
- socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds+2) < 0) {
-
- /* Try again, without SOCK_CLOEXEC */
- if (errno == EINVAL) {
-#endif
- if (socketpair(PF_UNIX, SOCK_DGRAM, 0, resolv->fds) < 0 ||
- socketpair(PF_UNIX, SOCK_DGRAM, 0, resolv->fds+2) < 0)
- goto fail;
-#ifdef SOCK_CLOEXEC
- } else
- goto fail;
- }
-#endif
+ r = socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds);
+ if (r < 0)
+ goto fail;
- for (i = 0; i < MESSAGE_FD_MAX; i++)
- fd_cloexec(resolv->fds[i], true);
+ r = socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds+2);
+ if (r < 0)
+ goto fail;
for (resolv->valid_workers = 0; resolv->valid_workers < n_proc; resolv->valid_workers++) {
- int r;
r = pthread_create(&resolv->workers[resolv->valid_workers], NULL, thread_worker, resolv);
if (r) {
errno = r;