Summary: | app-admin/sysklogd-1.4.2_pre20061230-r2 uses incorrect log level due to conflict between C library's syslog() | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Dmitriy Matrosov <sgf.dma> |
Component: | Current packages | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | High | ||
Version: | unspecified | ||
Hardware: | AMD64 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
Resolve conflict with C library's syslog() and vsyslog()
Resolve conflict with C library's syslog() and vsyslog(). (fix some typo from previous patch) |
Description
Dmitriy Matrosov
2010-10-25 09:25:02 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. 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 -) the app shouldnt be defining conflicting symbols 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.
Created attachment 252073 [details, diff]
Resolve conflict with C library's syslog() and vsyslog(). (fix some typo from previous patch)
should be fixed in sysklogd-1.5-r1 |