This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: syslog and LOG_KERN broken


   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:

   He wrote:
   >      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
   > internal_function
   > 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
   > condition
   > 
   >       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.

Mark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]