From: Michal Sojka Date: Sun, 12 Mar 2017 01:11:39 +0000 (+0100) Subject: procd: Don't use syslog before its initialization X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=225b18d22d9f1e47ff99632d038d7777e0763104;p=project%2Fprocd.git procd: Don't use syslog before its initialization When procd starts a rcS script, it captures its stdout and stderr and logs them via syslog(). The problem with that is that the rest of procd code uses ulog rather than syslog() directly and ulog_open() doesn't call openlog() immediately, but only after something is logged with ulog(). This lazy calling of openlog() can result in the following unwanted behavior: 1) When rcS's stdout/err is logged via syslog(), the log identifier is not set yet (due to openlog() not called) and so the log message lacks information about source. 2) procd can also log stdout/err from services. When a message from a service needs to be logged, ulog_open() is called to change the log identifier to match the service name/PID. After logging the service messages, ulog_open() is called again the change the identifier back to "procd". The lazy call to openlog() means that the messages logged directly with syslog() will be logged with the identification of the previously logged service and not of the rcS script that produced the message. Both problems are fixed by replacing direct call to syslog() with ULOG_NOTE, which automatically calls openlog() if needed. Signed-off-by: Michal Sojka --- diff --git a/rcS.c b/rcS.c index 0208a75..4813146 100644 --- a/rcS.c +++ b/rcS.c @@ -54,7 +54,7 @@ static void pipe_cb(struct ustream *s, int bytes) break; *newline = 0; len = newline + 1 - str; - syslog(LOG_NOTICE, "%s", str); + ULOG_NOTE("%s", str); #ifdef SHOW_BOOT_ON_CONSOLE fprintf(stderr, "%s\n", str); #endif