|Summary:||perl sys::syslog formatting bug|
|Product:||Red Hat Enterprise Linux 3||Reporter:||Tru Huynh <tru>|
|Component:||perl||Assignee:||Jason Vas Dias <jvdias>|
|Status:||CLOSED NOTABUG||QA Contact:||David Lawrence <dkl>|
|Fixed In Version:||Doc Type:||Bug Fix|
|Doc Text:||Story Points:||---|
|Last Closed:||2005-11-03 00:08:12 UTC||Type:||---|
|oVirt Team:||---||RHEL 7.3 requirements from Atomic Host:|
Description Tru Huynh 2005-06-22 14:39:31 UTC
From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; NetBSD amd64; en-US; rv:1.7.8) Gecko/20050524 Description of problem: the sys::syslog from perl en RHEL3 or 4 on x86_64 or x86 has a formatting bug. perl-5.8.0-89.10/perl-5.8.5-12.1 have the same issue Version-Release number of selected component (if applicable): perl-5.8.0-89.10.x86_64 How reproducible: Always Steps to Reproduce: 1.perl -e 'use Sys::Syslog; openlog "", "", "whatever"; syslog "info", "::a"; closelog;' 2.tail /var/log/messages 3.logger(1) does not show this issue Actual Results: /var/log/messages: ... Jun 22 16:33:14 sillage :: a (there is 2 additionnal spaces, one between last : and character a, and one at the end of the line) Expected Results: /var/log/messages: ... Jun 22 16:33:14 sillage ::a (no spaces added) Additional info: annoying bug for parsing timestamps (for instance in syslog generated files by perl programs). Tru
Comment 1 Tru Huynh 2005-06-22 15:02:02 UTC
perldoc Sys::Syslog ... openlog $ident, $logopt, $facility; ... openlog $ident, $logopt, $facility $ident is prepended to every message. $logopt contains zero or more of the words pid, ndelay, nowait. The cons option is ignored, since the failover mechanism will drop down to the console automat- ically if all other media fail. $facility specifies the part of the system here $ident is DEFINED and set as en empty string ("") but tested as non-empty instead of undefined... upstream ?
Comment 2 Warren Togami 2005-07-04 02:53:30 UTC
You are saying this is an issue in RHEL4 perl too? What about FC4?
Comment 3 Tru Huynh 2005-07-04 07:40:57 UTC
yes, RHEL4 has the same issue perl-5.8.5-12.1.x86_64 I don't have any FC4 installed to try on, sorry.
Comment 4 Jason Vas Dias 2005-11-03 00:08:12 UTC
Yes, this happens in all currently shipped Red Hat perl versions . I'm not sure this is really a bug - the 'man Sys::Syslog' man-page states: " openlog $ident, $logopt, $facility ... syslog $priority, $format, @args ... If you didnât use openlog() before using syslog(), syslog will try to guess the $ident by extracting the shortest prefix of $format that ends in a ":". " So what is happening is that since you specified no 'ident' for openlog, Syslog.pm tries to extract the ident from the message, and thinks it is ':'. The "ident" is then used to prefix the message, ie. is the message 'tag', followed by ": " . The 'tag' field is not optional, as shown by the prototype of the c openlog call: void openlog(const char *ident, int option, int facility); The string pointed to by ident is prepended to every message, and is typically set to the program name, and if the LOG_PID option is supplied, it will be suffixed with the process id in brackets, to form the usual syslog tag of 'program[pid]:' . There are several ways to workaround this situation : 1. Provide an "ident" to openlog - eg., in your example: $ perl -e 'use Sys::Syslog; openlog $0, "", ""; syslog "info", "::a"; closelog;' This would emit the syslog line: <date> <host> -e: ::a Usually $0 will be the name of the script, which is '-e' for perl command line expressions . 2. Use a proper printf format as the second argument to syslog: $ perl -e 'use Sys::Syslog; syslog "info", "%s", "::a";' logs the line: <date> <host> <user>: ::a The openlog is optional, meaning that syslog will open a log socket for you. Unless Sys::Syslog were to arbitrarily disallow an 'ident' value of ':', (which could be an executable file name), it cannot fix this bug and still provide the feature of embedding the ident tag in the message. So this is not a bug - use one of the workarounds given above.