diff options
-rw-r--r-- | include/conntrackd.h | 1 | ||||
-rw-r--r-- | src/log.c | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/include/conntrackd.h b/include/conntrackd.h index 8406c54..f995f4b 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -147,6 +147,7 @@ struct ct_general_state { sigset_t block; FILE *log; FILE *stats_log; + int log_init; struct local_server local; struct ct_mode *mode; struct ct_filter *us_filter; @@ -57,6 +57,8 @@ int init_log(void) CONFIG(stats).syslog_facility != -1) openlog(PACKAGE, LOG_PID, CONFIG(syslog_facility)); + STATE(log_init) = 1; + return 0; } @@ -101,7 +103,7 @@ void dlog(int priority, const char *format, ...) FILE *console_out; va_list args; - if (CONFIG(running_mode) != DAEMON) { + if (CONFIG(running_mode) != DAEMON || STATE(log_init) == 0) { switch (priority) { case LOG_INFO: case LOG_NOTICE: @@ -118,6 +120,9 @@ void dlog(int priority, const char *format, ...) va_end(args); } + if (STATE(log_init) == 0) + return; + if (fd) { va_start(args, format); logline_put(fd, priority, format, &args); @@ -211,6 +216,8 @@ void dlog_exp(FILE *fd, struct nf_expect *exp, unsigned int type) void close_log(void) { + STATE(log_init) = 0; + if (STATE(log) != NULL) fclose(STATE(log)); |