summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArturo Borrero Gonzalez <arturo@debian.org>2016-11-04 11:37:02 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-11-09 00:26:04 +0100
commit631d92b68922e7da827115d62a55425ab667c89d (patch)
treed0fbbd62488d938312f682ab915a2b7e82cbdb39 /src
parentab81c355fa292b7d71253a4b8d3a3daf31a78ed1 (diff)
log: introduce a mechanism to know if log was initialized
This will allow to call dlog() function from all the points in the execution at runtime. If the log was not initialized, then we just fprintf and return. By now, we can't init the log engine earlier because we require config from the user, so there is a egg-chicken problem. This means that we can't log parsing messages to logfiles but only to stderr/stdout. Signed-off-by: Arturo Borrero Gonzalez <arturo@debian.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/log.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/log.c b/src/log.c
index 0796ba9..6deccfa 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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));