From 62c3edd9575cb7dfef0d86392e4b87a4c14d8dee Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sun, 27 Mar 2022 13:10:26 +0200 Subject: treewide: Fix android-cloexec-* clang-tidy warnings, re-enable checks Signed-off-by: Stefano Brivio --- tap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tap.c') diff --git a/tap.c b/tap.c index 8415d5a..6333015 100644 --- a/tap.c +++ b/tap.c @@ -875,12 +875,13 @@ static int tun_ns_fd = -1; static int tap_ns_tun(void *arg) { struct ifreq ifr = { .ifr_flags = IFF_TAP | IFF_NO_PI }; + int flags = O_RDWR | O_NONBLOCK | O_CLOEXEC; struct ctx *c = (struct ctx *)arg; strncpy(ifr.ifr_name, c->pasta_ifn, IFNAMSIZ); if (ns_enter(c) || - (tun_ns_fd = open("/dev/net/tun", O_RDWR | O_NONBLOCK)) < 0 || + (tun_ns_fd = open("/dev/net/tun", flags)) < 0 || ioctl(tun_ns_fd, TUNSETIFF, &ifr) || !(c->pasta_ifi = if_nametoindex(c->pasta_ifn))) tun_ns_fd = -1; -- cgit v1.2.3