summaryrefslogtreecommitdiff
path: root/misc/syslog.c
diff options
context:
space:
mode:
authorDan Raymond <draymond@foxvalley.net>2021-04-13 10:26:12 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-04-13 16:33:27 -0300
commitf2913118cdbe72e1e6d89273eddabdf35e9d6b73 (patch)
treeb01f388978653db1355f21a50fb918b412e9d978 /misc/syslog.c
parent58137d00ba9afda4ed78df8c146cc13cc732a6a2 (diff)
downloadglibc-f2913118cdbe72e1e6d89273eddabdf35e9d6b73.tar.gz
misc: syslog: Fix calls to openlog() with LOG_KERN facility (BZ #3604)
POSIX states for syslog [1]: "Values of the priority argument are formed by OR'ing together a severity-level value and an optional facility value. If no facility value is specified, the current default facility value is used." So the patch fixes an existing violation of the openlog interface contract where it is ignoring the facility argument when the value is zero It allows the use LOG_KERN by calling openlog prior syslog usage. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html
Diffstat (limited to 'misc/syslog.c')
-rw-r--r--misc/syslog.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/misc/syslog.c b/misc/syslog.c
index 2cc63ef287..bb30cd963a 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -285,7 +285,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
/* Get connected, output the message to the local logger. */
if (!connected)
- openlog_internal(LogTag, LogStat | LOG_NDELAY, 0);
+ openlog_internal(NULL, LogStat | LOG_NDELAY, LogFacility);
/* If we have a SOCK_STREAM connection, also send ASCII NUL as
a record terminator. */
@@ -299,7 +299,7 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
/* Try to reopen the syslog connection. Maybe it went
down. */
closelog_internal ();
- openlog_internal(LogTag, LogStat | LOG_NDELAY, 0);
+ openlog_internal(NULL, LogStat | LOG_NDELAY, LogFacility);
}
if (!connected || __send(LogFile, buf, bufsize, send_flags) < 0)
@@ -343,7 +343,7 @@ openlog_internal(const char *ident, int logstat, int logfac)
if (ident != NULL)
LogTag = ident;
LogStat = logstat;
- if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
+ if ((logfac &~ LOG_FACMASK) == 0)
LogFacility = logfac;
int retry = 0;