On Mon, Jun 18, 2007 at 04:31:33PM +0200, Rados??aw Koz??owski wrote:
> I'm running mon r1.22 on RHEL 4 with perl 5.8.5 and the following line:
>
> my @log = map { s/\%//mg; } @_;
>
> in
>
> no warnings; # Redefining syslog
> sub syslog {
> eval {
> local $SIG{"__DIE__"}= sub { };
> my @log = map { s/\%//mg; } @_;
> Sys::Syslog::syslog(@log);
> }
> }
> use warnings;
>
> breaks logging to syslogd for me (ie. nothing is being logged). If I
> pass @_ to Sys::Syslog::syslog directly, everything works fine.
>
> What's the idea behind this substitution, why is it needed?
I just realized, I didn't fully answer your question.
There are two things happening in Mon's local definition of syslog().
One, as I mentioned earlier, was wrapping it with an eval block so
if Sys::Syslog decided to call die() it wouldn't kill the Mon server.
The other is a workaround for a possible syslog vulnerability - syslog
has printf-like processing with % arguments, but Mon doesn't use
that feature. If somehow Mon syslogged something with % signs in it,
you might see garbage in the log, or worse yet, a Perl error or crash.
There was a Perl advisory on this a year or two ago, so the
"my @log = map { s/\%//mg; } @_;" was added to delete any % signs that
may have ended up in strings intended for syslog.
If that map {} statement is giving you trouble, you could try replacing
these two lines:
> my @log = map { s/\%//mg; } @_;
> Sys::Syslog::syslog(@log);
with:
Sys::Syslog::syslog($_[0], "%s", $_[1])
Which should work since as long as all the Mon syslog statements in the
current release use only two arguments (priority, string) to syslog()
(which I believe they do, but haven't the time to check at the moment).
_______________________________________________
mon mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/mon