2828#include "database/query-table.h"
2929// runGC()
3030#include "gc.h"
31- // open(), O_WRONLY, O_CREAT, O_APPEND
31+ // open(), O_WRONLY, O_CREAT, O_APPEND, O_CLOEXEC
3232#include <fcntl.h>
3333
3434static bool print_log = true, print_stdout = true;
@@ -67,7 +67,7 @@ static bool write_log_line(struct log_fd *log, const char *line, size_t len)
6767 {
6868 log -> reopen_needed = 0 ;
6969 close (log -> fd );
70- log -> fd = open (log -> path , O_WRONLY |O_CREAT |O_APPEND , S_IRUSR |S_IWUSR |S_IRGRP );
70+ log -> fd = open (log -> path , O_WRONLY |O_CREAT |O_APPEND | O_CLOEXEC , S_IRUSR |S_IWUSR |S_IRGRP );
7171 }
7272
7373 ssize_t written = 0 ;
@@ -111,7 +111,7 @@ void open_log_fds(bool ftl)
111111 if (config .files .log .ftl .v .s != NULL )
112112 {
113113 ftl_log .path = config .files .log .ftl .v .s ;
114- ftl_log .fd = open (ftl_log .path , O_WRONLY |O_CREAT |O_APPEND , S_IRUSR |S_IWUSR |S_IRGRP );
114+ ftl_log .fd = open (ftl_log .path , O_WRONLY |O_CREAT |O_APPEND | O_CLOEXEC , S_IRUSR |S_IWUSR |S_IRGRP );
115115 if (ftl_log .fd == -1 )
116116 {
117117 printf ("ERROR: Opening of FTL log (%s) failed: %s\nUsing syslog instead!\n" ,
@@ -126,14 +126,14 @@ void open_log_fds(bool ftl)
126126 if (config .files .log .webserver .v .s != NULL )
127127 {
128128 webserver_log .path = config .files .log .webserver .v .s ;
129- webserver_log .fd = open (webserver_log .path , O_WRONLY |O_CREAT |O_APPEND , S_IRUSR |S_IWUSR |S_IRGRP );
129+ webserver_log .fd = open (webserver_log .path , O_WRONLY |O_CREAT |O_APPEND | O_CLOEXEC , S_IRUSR |S_IWUSR |S_IRGRP );
130130 }
131131
132132 // pihole.log (dnsmasq) — FTL owns this file from now on
133133 if (config .files .log .dnsmasq .v .s != NULL )
134134 {
135135 dnsmasq_log .path = config .files .log .dnsmasq .v .s ;
136- dnsmasq_log .fd = open (dnsmasq_log .path , O_WRONLY |O_CREAT |O_APPEND , S_IRUSR |S_IWUSR |S_IRGRP );
136+ dnsmasq_log .fd = open (dnsmasq_log .path , O_WRONLY |O_CREAT |O_APPEND | O_CLOEXEC , S_IRUSR |S_IWUSR |S_IRGRP );
137137 }
138138}
139139
@@ -897,7 +897,7 @@ bool flush_dnsmasq_log(void)
897897 pthread_mutex_lock (& dnsmasq_log .lock );
898898 if (dnsmasq_log .fd != -1 )
899899 close (dnsmasq_log .fd );
900- dnsmasq_log .fd = open (dnsmasq_log .path , O_WRONLY |O_CREAT |O_APPEND , S_IRUSR |S_IWUSR |S_IRGRP );
900+ dnsmasq_log .fd = open (dnsmasq_log .path , O_WRONLY |O_CREAT |O_APPEND | O_CLOEXEC , S_IRUSR |S_IWUSR |S_IRGRP );
901901 pthread_mutex_unlock (& dnsmasq_log .lock );
902902
903903 // Flush dnsmasq FIFO logs
0 commit comments