log: open log file in cloexec mode
authorRobert Swiecki <robert@swiecki.net>
Sat, 10 Feb 2018 03:13:39 +0000 (04:13 +0100)
committerRobert Swiecki <robert@swiecki.net>
Sat, 10 Feb 2018 03:13:39 +0000 (04:13 +0100)
log.cc

diff --git a/log.cc b/log.cc
index fbcb4d2..e9a3715 100644 (file)
--- a/log.cc
+++ b/log.cc
@@ -66,8 +66,8 @@ bool initLogFile(struct nsjconf_t* nsjconf) {
        if (nsjconf->logfile.empty()) {
                log_fd = fcntl(log_fd, F_DUPFD_CLOEXEC, 0);
        } else {
-               if (TEMP_FAILURE_RETRY(
-                       log_fd = open(nsjconf->logfile.c_str(), O_CREAT | O_RDWR | O_APPEND, 0640)) == -1) {
+               if (TEMP_FAILURE_RETRY(log_fd = open(nsjconf->logfile.c_str(),
+                                          O_CREAT | O_RDWR | O_APPEND | O_CLOEXEC, 0640)) == -1) {
                        log_fd = STDERR_FILENO;
                        PLOG_E("Couldn't open logfile open('%s')", nsjconf->logfile.c_str());
                        return false;