This is the mail archive of the
mailing list for the glibc project.
Re: syslog and LOG_KERN broken
- To: aj at suse dot de
- Subject: Re: syslog and LOG_KERN broken
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Thu, 9 Mar 2000 15:11:26 +0100 (MET)
- CC: libc-alpha at sourceware dot cygnus dot com, werner at suse dot de
- References: <email@example.com>
Date: 09 Mar 2000 12:33:58 +0100
User-Agent: Gnus/5.0804 (Gnus v5.8.4) XEmacs/21.1 (Bryce Canyon)
I've found some old mails (sorry, Werner) where Werner complains about
a bug in syslog:
> there is a nasty bug in the syslog facility of the
> glibc. If klogd is linked without the syslog.o (defining
> the (v)syslog() and openlog/closlog() functions) the
> glibc is used. With glibc it seems that the LOG facility is
> LOG_USER even if LOG_KERN is set in openlog():
> ... now ist seems that in /mirror/cvs/data/glibc/misc/syslog.c
> there is a problem in openlog_internal() ...
> static void
> openlog_internal(const char *ident, int logstat, int logfac)
> if (ident != NULL)
> LogTag = ident;
> LogStat = logstat;
> if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
> LogFacility = logfac;
> in comparision to /mirror/cvs/data/glibc/misc/sys/syslog.h
> (/usr/include/sys/syslog.h) where
> /* facility codes */
> #define LOG_KERN (0<<3) /* kernel messages */
> #define LOG_USER (1<<3) /* random user-level messages */
> is defined ... default of LogFacility is LOG_USER but the
> logfac != 0
> makes LOG_KERN unavailable for openlog(). The LogFacility LOG_KERN
> should be allowed for local connections of root processes.
We've got two possibilities:
- give LOG_KERN a value != 0 (shouldn't be a big problem since this
never worked before!)
- Remove the check in openlog_internal (but then the default will be
LOG_KERN instead of LOG_USER)
What do you think?
The Solaris 2.6 and BSD man pages for syslog() clearly state that LOG_KERN
messages ``cannot be generated by any user processes''. So the
current implementation is fine.
Removing the check in openlog_internal is not an option, since that
clearly brakes binary compatibility. LOG_USER is explicitly
documented as the default.
Giving LOG_KERN a different value breaks binary compatibility too.
The argument that it never worked is bogus, since it is not supposed
to have ever worked in combination with openlog(). But it is a valid
argument for messages generated (by the kernel) in a different way.
I think the idea is that klogd is supposed to be that other way of
generating messages. IIRC it reads messages from /dev/klog and
forwards them to syslog. It cannot use openlog()/syslog()/closelog()
from glibc and therefore provides its own (possibly simplified)
implementation of syslog(). Werner seems to have been trying to
replace that private implementation with the one in glibc, and that
simply won't work.
On my own system I use a BSD syslogd (from NetBSD I believe) which
reads directly from /dev/klog and this works fine.
Conclusion: I don't think there is a bug other than the fact that
syslog() is undocumented.