Re: [Mon-devel] [Mon-commit] mon mon,1.23,1.24
Brought to you by:
trockij
From: Jim T. <tr...@ar...> - 2007-12-05 14:19:46
|
On Mon, 3 Dec 2007, Augie Schwer wrote: > This was causing syslog messages to be silently discarded in modern > versions of Perl; this should probably go into the 1.2 Stable Branch > as well; what do you think Jim? Yes, it should go into the stable. Have a look at the diff below. syslog may croak for a number of different reasons, so that's the reason for wrapping it in the eval. The % removal appears to be a safeguard for an exploit that was in older versions of the syslog module. I made the call to syslog in a way that would avoid the bug without having to remove the %s. It'll also log an error to "monerrfile" if the syslog fails for one reason or another. Does that make sense? diff -u -r1.22.2.2 mon --- mon 6 Jun 2007 11:46:19 -0000 1.22.2.2 +++ mon 5 Dec 2007 14:18:18 -0000 @@ -5392,11 +5392,13 @@ no warnings; # Redefining syslog sub syslog { - eval { - local $SIG{"__DIE__"}= sub { }; - my @log = map { s/\%//mg; } @_; - Sys::Syslog::syslog(@log); - } + return if (!@_); + + my $pri = (@_ == 1) ? "err" : shift; + + eval { Sys::Syslog::syslog ($pri, '%s', "@_"); }; + + print STDERR "syslog error: $@\n" if ($@ ne ""); } use warnings; |