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 --- conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 80f4303..ea51de4 100644 --- a/conf.c +++ b/conf.c @@ -285,7 +285,7 @@ static void get_dns(struct ctx *c) if (dns_set && dnss_set) return; - if ((fd = open("/etc/resolv.conf", O_RDONLY)) < 0) + if ((fd = open("/etc/resolv.conf", O_RDONLY | O_CLOEXEC)) < 0) goto out; while (!(*buf = 0) && line_read(buf, BUFSIZ, fd)) { @@ -406,13 +406,17 @@ static int conf_ns_opt(struct ctx *c, continue; } + /* Don't pass O_CLOEXEC here: ns_enter() needs those files */ if (!c->netns_only) { if (*conf_userns) + /* NOLINTNEXTLINE(android-cloexec-open) */ ufd = open(conf_userns, O_RDONLY); else if (*userns) + /* NOLINTNEXTLINE(android-cloexec-open) */ ufd = open(userns, O_RDONLY); } + /* NOLINTNEXTLINE(android-cloexec-open) */ nfd = open(netns, O_RDONLY); if (nfd == -1 || (ufd == -1 && !c->netns_only)) { -- cgit v1.2.3