Add missing O_RDONLY here and there
authorRobert Swiecki <robert@swiecki.net>
Thu, 8 Feb 2018 14:23:15 +0000 (15:23 +0100)
committerRobert Swiecki <robert@swiecki.net>
Thu, 8 Feb 2018 14:23:15 +0000 (15:23 +0100)
config.cc
contain.c

index 5a68c33c698d5f99ad29e0896386770371cb1a02..97cb6985cd5a235d899f0c534ce3af631a936481 100644 (file)
--- a/config.cc
+++ b/config.cc
@@ -309,7 +309,7 @@ static void LogHandler(
 extern "C" bool configParse(struct nsjconf_t* nsjconf, const char* file) {
        LOG_I("Parsing configuration from '%s'", file);
 
-       int fd = open(file, O_RDONLY);
+       int fd = open(file, O_RDONLY | O_CLOEXEC);
        if (fd == -1) {
                PLOG_W("Couldn't open config file '%s'", file);
                return false;
index c772fa4f1e7c205d57faf74bbda6a5b1b5de384d..48a435b21d92d85ef9ed1cd132c40cbc9e054f6e 100644 (file)
--- a/contain.c
+++ b/contain.c
@@ -178,7 +178,7 @@ static bool containMakeFdsCOENaive(struct nsjconf_t* nsjconf) {
 static bool containMakeFdsCOEProc(struct nsjconf_t* nsjconf) {
        int dirfd = open("/proc/self/fd", O_DIRECTORY | O_RDONLY | O_CLOEXEC);
        if (dirfd == -1) {
-               PLOG_D("open('/proc/self/fd', O_DIRECTORY|O_RDONLY)");
+               PLOG_D("open('/proc/self/fd', O_DIRECTORY|O_RDONLY|O_CLOEXEC)");
                return false;
        }
        DIR* dir = fdopendir(dirfd);