Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 342601 - app-admin/sysklogd-1.4.2_pre20061230-r2 uses incorrect log level due to conflict between C library's syslog()
Summary: app-admin/sysklogd-1.4.2_pre20061230-r2 uses incorrect log level due to confl...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-25 09:25 UTC by Dmitriy Matrosov
Modified: 2010-11-20 17:39 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Resolve conflict with C library's syslog() and vsyslog() (sysklogd-1.4.1-resolve-glibc-syslog-conflict.diff,4.45 KB, patch)
2010-10-26 17:31 UTC, Dmitriy Matrosov
Details | Diff
Resolve conflict with C library's syslog() and vsyslog(). (fix some typo from previous patch) (sysklogd-1.4.1-resolve-glibc-syslog-conflict.diff,3.97 KB, patch)
2010-10-26 17:48 UTC, Dmitriy Matrosov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitriy Matrosov 2010-10-25 09:25:02 UTC
Kernel messages written with facility LOG_USER instead of LOG_KERN. So file kern.log (from default syslog.conf file) remains empty, and all kernel messages go into file user.log.

Reproducible: Always

Steps to Reproduce:
1.Start syslogd and klogd with default syslog.conf.
2.Trigger some kernel message, e.g. by mounting hdd partition.

Actual Results:  
Kernel message about this action appear in user.log instead of kern.log.


Expected Results:  
Kernel messages should be written into kern.log.

Portage 2.1.8.3 (default/linux/amd64/10.0/desktop/gnome, gcc-4.4.3, glibc-2.11.2-r0, 2.6.34-gentoo-r11 x86_64)
=================================================================
System uname: Linux-2.6.34-gentoo-r11-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T9300_@_2.50GHz-with-gentoo-1.12.13
Timestamp of tree: Mon, 25 Oct 2010 06:15:03 +0000
app-shells/bash:     4.0_p37
dev-lang/python:     2.6.5-r3, 3.1.2-r4
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    2.3-r1
sys-devel/autoconf:  2.65-r1
sys-devel/automake:  1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.3-r2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=core2 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/ ftp://mirror.yandex.ru/gentoo-distfiles/ ftp://xeon.gentoo.ru/mirrors/Gentoo/"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.ru.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdr cli consolekit cracklib crypt cups cxx dbus dri dts dvd dvdr eds emboss encode evo exif fam firefox flac fortran gdbm gdu gif gnome gnome-keyring gpm gstreamer gtk hal iconv ipv6 jpeg lcms ldap libnotify mad mikmod mmx mng modules mp3 mp4 mpeg mudflap multilib nautilus ncurses nls nptl nptlonly ogg opengl openmp pam pango pcre pdf perl png policykit ppds pppd python qt3support qt4 readline sdl session spell sse sse2 ssl startup-notification svg sysfs tcpd tiff truetype unicode usb vorbis x264 xcb xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware voodoo" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 1 Dmitriy Matrosov 2010-10-25 09:28:58 UTC
Here is part of my syslog.conf (almost the same as default, only '-' removed somewhere)

auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          /var/log/syslog
#cron.*                         /var/log/cron.log
daemon.*                        /var/log/daemon.log
kern.*                          /var/log/kern.log
lpr.*                           /var/log/lpr.log
mail.*                          /var/log/mail.log
user.*                          /var/log/user.log
uucp.*                          /var/log/uucp.log
local6.debug                    /var/log/imapd.log


Here is backtrace of klogd

#0  syslog (priority=6, fmt=0x405718 "%s") at /usr/include/bits/syslog.h:32
#1  Syslog (priority=6, fmt=0x405718 "%s") at klogd.c:640
#2  0x00000000004027e9 in LogLine (len=<value optimized out>, ptr=<value optimized out>) at klogd.c:777
#3  0x0000000000402dd5 in main (argc=<value optimized out>, argv=0x7fffffffe518) at klogd.c:1223

So, klogd call syslog() function from glibc instead of its own from syslog.c
file, and libc's syslog() convert facility of message from LOG_KERN into LOG_USER.

I found two ways to fix this (this is not a real fix - just confirmation, that
this _may be a problem):

1. If I compile sysklogd without any optimisation flags ('-O'), gcc will not
inline libc's syslog(), so proper syslog() (from syslog.c) will be called, and
all will work as expected. Here is backtrace

#0  syslog (pri=32767, fmt=0x400da7 "read") at syslog.c:86
#1  0x00000000004022ea in Syslog (priority=6, fmt=0x405a27 "%s") at klogd.c:640
#2  0x00000000004025ee in LogLine (
    ptr=0x607381 "<4>[10576.960848] EXT3-fs (dm-0): warning: maximal mount count reached, running e2fsck is recommended\n<6>[10576.961027] EXT3-fs (dm-0): using internal journal\n<6>[10576.961033] EXT3-fs (dm-0): mounted"..., len=235) at klogd.c:777
#3  0x0000000000402b6a in LogProcLine () at klogd.c:983
#4  0x00000000004031e9 in main (argc=3, argv=0x7fffffffe518) at klogd.c:1223

2. If I rename sysklogd's own syslog() function into, e.g. syslog_A(), also all
will work fine. Here is diff:

diff -Naur ./sysklogd-1.4.1_orig/klogd.c ./sysklogd-1.4.1/klogd.c
--- ./sysklogd-1.4.1_orig/klogd.c	2010-10-25 16:24:07.000000000 +0400
+++ ./sysklogd-1.4.1/klogd.c	2010-10-25 16:27:10.000000000 +0400
@@ -637,7 +637,7 @@
 			}
 			argl += 3;
 		}
-		syslog(priority, fmt, argl);
+		syslog_A(priority, fmt, argl);
 		va_end(ap);
 #ifdef TESTING
 		putchar('\n');
diff -Naur ./sysklogd-1.4.1_orig/klogd.h ./sysklogd-1.4.1/klogd.h
--- ./sysklogd-1.4.1_orig/klogd.h	1997-06-13 13:35:54.000000000 +0400
+++ ./sysklogd-1.4.1/klogd.h	2010-10-25 16:27:02.000000000 +0400
@@ -38,3 +38,4 @@
 extern char * ExpandKadds(char *, char *);
 extern void SetParanoiaLevel(int);
 extern void Syslog(int priority, char *fmt, ...);
+extern void syslog_A(int pri, const char *fmt, ...);
diff -Naur ./sysklogd-1.4.1_orig/syslog.c ./sysklogd-1.4.1/syslog.c
--- ./sysklogd-1.4.1_orig/syslog.c	2010-10-25 16:23:46.000000000 +0400
+++ ./sysklogd-1.4.1/syslog.c	2010-10-25 16:27:17.000000000 +0400
@@ -82,7 +82,7 @@
 static int	LogFacility = LOG_USER;	/* default facility code */
 
 void
-syslog(int pri, const char *fmt, ...)
+syslog_A(int pri, const char *fmt, ...)
 {
 	va_list ap;
 

But, though, this two steps fix the problem, i doubt, that this is the _real
reason - I just can't find anything else, because I am not very well know the
subject.

And sorry for my bad grammar, I'm not english.
Comment 2 Dmitriy Matrosov 2010-10-26 11:27:39 UTC
I think, I found yet another way to fix a problem, and, I think, this is a real reason of such behavior: gcc version.

Inlining of glibc()'s syslog() function defined in <bits/syslog.h> as

#ifdef __va_arg_pack
__extern_always_inline void
syslog (int __pri, __const char *__fmt, ...)
{
  __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
}
#elif !defined __cplusplus
# define syslog(pri, ...) \
  __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
#endif

and preprocessor constant '__va_arg_pack' defined in <sys/cdefs.h> as

#if __GNUC_PREREQ (4,3)
# define __va_arg_pack() __builtin_va_arg_pack ()
# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
#endif

So, i try to compile it with gcc-4.2.4-r1 and gcc-4.1.2. And it works (syslog() function from sysklogd's syslog.c file has been called, but not glibc's syslog()).

Hope this helps -)
Comment 3 SpanKY gentoo-dev 2010-10-26 14:01:43 UTC
the app shouldnt be defining conflicting symbols
Comment 4 Dmitriy Matrosov 2010-10-26 17:31:34 UTC
Created attachment 252063 [details, diff]
Resolve conflict with C library's syslog() and vsyslog()

I rename syslog() and vsyslog() functions from syslog.c to avoid conflict with corresponding C library functions.
Comment 5 Dmitriy Matrosov 2010-10-26 17:48:54 UTC
Created attachment 252073 [details, diff]
Resolve conflict with C library's syslog() and vsyslog(). (fix some typo from previous patch)
Comment 6 SpanKY gentoo-dev 2010-11-20 17:39:04 UTC
should be fixed in sysklogd-1.5-r1