init: do not eat last char in messages;

do not print duplicate "init:" prefix to syslog
This commit is contained in:
Denis Vlasenko 2008-12-09 21:23:31 +00:00
parent efb545b9bd
commit 1bcdcd2ef0

View File

@ -118,18 +118,18 @@ static void message(int where, const char *fmt, ...)
msg[0] = '\r'; msg[0] = '\r';
va_start(arguments, fmt); va_start(arguments, fmt);
l = vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments); l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
if (l > sizeof(msg) - 2) if (l > sizeof(msg) - 1)
l = sizeof(msg) - 2; l = sizeof(msg) - 1;
msg[l] = '\0'; msg[l] = '\0';
va_end(arguments); va_end(arguments);
if (ENABLE_FEATURE_INIT_SYSLOG) { if (ENABLE_FEATURE_INIT_SYSLOG) {
/* Log the message to syslogd */
if (where & L_LOG) { if (where & L_LOG) {
/* don't print out "\r" */ /* Log the message to syslogd */
openlog(applet_name, 0, LOG_DAEMON); openlog("init", 0, LOG_DAEMON);
syslog(LOG_INFO, "init: %s", msg + 1); /* don't print "\r" */
syslog(LOG_INFO, "%s", msg + 1);
closelog(); closelog();
} }
msg[l++] = '\n'; msg[l++] = '\n';