From a4980cbde24b48c5540435d27d01651d5ca46d03 Mon Sep 17 00:00:00 2001 From: Tomas Heinrich Date: Tue, 29 May 2012 11:21:50 +0200 Subject: bugfix: if debug message could end up in log file when forking if rsyslog was set to auto-background (thus fork, the default) and debug mode to stdout was enabled, debug messages ended up in the first log file opened. Currently, stdout logging is completely disabled in forking mode (but writing to the debug log file is still possible). This is a change in behaviour, which is under review. If it causes problems to you, please let us know. Signed-off-by: Rainer Gerhards --- ChangeLog | 8 ++++++++ runtime/debug.c | 4 +--- runtime/debug.h | 1 + tools/syslogd.c | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2290bac..0a3cda9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,14 @@ Version 5.8.12 [V5-stable] 2012-05-?? - bugfix/omudpspoof: problems, including abort, happend when run on multiple threads. Root cause is that libnet is not thread-safe. omudpspoof now guards libnet calls with their own mutex. +- bugfix: if debug message could end up in log file when forking + if rsyslog was set to auto-background (thus fork, the default) and debug + mode to stdout was enabled, debug messages ended up in the first log file + opened. Currently, stdout logging is completely disabled in forking mode + (but writing to the debug log file is still possible). This is a change + in behaviour, which is under review. If it causes problems to you, + please let us know. + Thanks to Tomas Heinrich for the patch. - bugfix/tcpflood: sending small test files did not work correctly --------------------------------------------------------------------------- Version 5.8.11 [V5-stable] 2012-05-03 diff --git a/runtime/debug.c b/runtime/debug.c index d02bd516..fa33b99d 100644 --- a/runtime/debug.c +++ b/runtime/debug.c @@ -68,7 +68,7 @@ static int bPrintAllDebugOnExit = 0; static int bAbortTrace = 1; /* print a trace after SIGABRT or SIGSEGV */ static char *pszAltDbgFileName = NULL; /* if set, debug output is *also* sent to here */ static int altdbg = -1; /* and the handle for alternate debug output */ -static int stddbg; +int stddbg = 1; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */ /* list of files/objects that should be printed */ typedef struct dbgPrintName_s { @@ -1297,8 +1297,6 @@ dbgGetRuntimeOptions(void) uchar *optname; /* set some defaults */ - stddbg = 1; - if((pszOpts = (uchar*) getenv("RSYSLOG_DEBUG")) != NULL) { /* we have options set, so let's process them */ while(dbgGetRTOptNamVal(&pszOpts, &optname, &optval)) { diff --git a/runtime/debug.h b/runtime/debug.h index 717c0fef..26672c3e 100644 --- a/runtime/debug.h +++ b/runtime/debug.h @@ -35,6 +35,7 @@ /* external static data elements (some time to be replaced) */ extern int Debug; /* debug flag - read-only after startup */ extern int debugging_on; /* read-only, except on sig USR1 */ +extern int stddbg; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */ /* data types */ diff --git a/tools/syslogd.c b/tools/syslogd.c index 98f06627..f3f27598 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2514,6 +2514,9 @@ doGlblProcessInit(void) sigAct.sa_handler = doexit; sigaction(SIGTERM, &sigAct, NULL); + /* stop writing debug messages to stdout (if debugging is on) */ + stddbg = -1; + if (fork()) { /* Parent process */ -- cgit