From 4f082c7df3998cdc2cdf9845a62d886d05257cb8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 30 Apr 2014 02:56:02 +0200 Subject: Remove now unneeded FD_CLOEXEC flag config --- src/async.c | 2 -- src/fastd.c | 3 +-- src/fastd.h | 9 --------- src/poll.c | 2 +- src/socket.c | 1 - src/tuntap.c | 6 +++--- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/async.c b/src/async.c index 2343cbb..28e0b03 100644 --- a/src/async.c +++ b/src/async.c @@ -41,8 +41,6 @@ void fastd_async_init(void) { if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds)) exit_errno("socketpair"); - fastd_setfd(fds[0], FD_CLOEXEC); - fastd_setfd(fds[1], FD_CLOEXEC); fastd_setfl(fds[1], O_NONBLOCK); ctx.async_rfd = fds[0]; diff --git a/src/fastd.c b/src/fastd.c index 191c82d..709f55f 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -510,7 +510,6 @@ static int daemonize(void) { } else { /* child 2 */ - fastd_setfd(pipefd[1], FD_CLOEXEC); return pipefd[1]; } } @@ -524,7 +523,7 @@ static void notify_systemd(const char *notify_socket) { if ((notify_socket[0] != '@' && notify_socket[0] != '/') || notify_socket[1] == 0) return; - fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0); + fd = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd < 0) return; diff --git a/src/fastd.h b/src/fastd.h index 2654bfd..b5dbe0c 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -331,15 +331,6 @@ static inline int fastd_rand(int min, int max) { } -static inline void fastd_setfd(const int fd, int set) { - int flags = fcntl(fd, F_GETFD); - if (flags < 0) - exit_errno("Getting file descriptor flags failed: fcntl"); - - if (fcntl(fd, F_SETFD, flags|set) < 0) - exit_errno("Setting file descriptor flags failed: fcntl"); -} - static inline void fastd_setfl(const int fd, int set) { int flags = fcntl(fd, F_GETFL); if (flags < 0) diff --git a/src/poll.c b/src/poll.c index 4ccf7de..ce1a7f4 100644 --- a/src/poll.c +++ b/src/poll.c @@ -91,7 +91,7 @@ static inline int handshake_timeout(void) { void fastd_poll_init(void) { - ctx.epoll_fd = epoll_create1(EPOLL_CLOEXEC); + ctx.epoll_fd = epoll_create1(0); if (ctx.epoll_fd < 0) exit_errno("epoll_create1"); diff --git a/src/socket.c b/src/socket.c index 0751a3c..d49888c 100644 --- a/src/socket.c +++ b/src/socket.c @@ -56,7 +56,6 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) { if (fd < 0) goto error; - fastd_setfd(fd, FD_CLOEXEC); fastd_setfl(fd, O_NONBLOCK); int one = 1; diff --git a/src/tuntap.c b/src/tuntap.c index d9fd353..d30a392 100644 --- a/src/tuntap.c +++ b/src/tuntap.c @@ -60,7 +60,7 @@ void fastd_tuntap_open(void) { pr_debug("initializing tun/tap device..."); - if ((ctx.tunfd = open("/dev/net/tun", O_RDWR|O_CLOEXEC|O_NONBLOCK)) < 0) + if ((ctx.tunfd = open("/dev/net/tun", O_RDWR|O_NONBLOCK)) < 0) exit_errno("could not open tun/tap device file"); if (conf.ifname) @@ -184,7 +184,7 @@ void fastd_tuntap_open(void) { strncat(ifname, type, IFNAMSIZ-1); } - if ((ctx.tunfd = open(ifname, O_RDWR|O_CLOEXEC|O_NONBLOCK)) < 0) + if ((ctx.tunfd = open(ifname, O_RDWR|O_NONBLOCK)) < 0) exit_errno("could not open tun/tap device file"); if (!(ctx.ifname = fdevname_r(ctx.tunfd, malloc(IFNAMSIZ), IFNAMSIZ))) @@ -254,7 +254,7 @@ void fastd_tuntap_open(void) { pr_debug("initializing tun device..."); - if ((ctx.tunfd = open(ifname, O_RDWR|O_CLOEXEC|O_NONBLOCK)) < 0) + if ((ctx.tunfd = open(ifname, O_RDWR|O_NONBLOCK)) < 0) exit_errno("could not open tun device file"); ctx.ifname = strndup(conf.ifname, IFNAMSIZ-1); -- cgit v1.2.3