From: Tom Gundersen Date: Tue, 14 Jan 2014 12:50:35 +0000 (+0100) Subject: sd-resolv: require SOCK_CLOEXEC X-Git-Tag: submit/kdbus-integration/20140207.094352~98 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a6233fb653098c14d84430b3516edd63265d405;p=platform%2Fupstream%2Fsystemd.git sd-resolv: require SOCK_CLOEXEC --- diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c index aa97ef7..8845d6e 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;