This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: $whoami calculation in Sys::Syslog.pm should not be greedy
authorRoderick Schertler <roderick@argon.org>
Sat, 29 Mar 1997 16:33:24 +0000 (11:33 -0500)
committerChip Salzenberg <chip@atlantic.net>
Tue, 25 Mar 1997 19:04:34 +0000 (07:04 +1200)
On Fri, 28 Mar 1997 16:42:46 -0600 (CST), mer@world.evansville.net (Marc Rouleau) said:
>
> I suggest replacing
>
>     if (!$ident && $mask =~ /^(\S.*):\s?(.*)/) {
>
> with
>
>     if (!$ident && $mask =~ /^(\S.*?):\s?(.*)/) {
>
> at about line 157.  Otherwise, syslog'ing text containing a colon
> doesn't work right.

I think it's a reasonable tradeoff (it'll prevent "foo::bar: message"
from working but it'll allow "foo: can't do x: message").  The first
probably doesn't work properly with most syslogds anyway, one here would
log it as

    foo:<17.6>:bar[21244]: message

p5p-msgid: pz4tdu7j57.fsf@eeyore.ibcinc.com

lib/Sys/Syslog.pm

index ee90127..2da1d76 100644 (file)
@@ -154,7 +154,7 @@ sub syslog {
 
     $whoami = $ident;
 
-    if (!$ident && $mask =~ /^(\S.*):\s?(.*)/) {
+    if (!$whoami && $mask =~ /^(\S.*?):\s?(.*)/) {
        $whoami = $1;
        $mask = $2;
     }