package libmail-spf-query-perl
retitle 356700 syslog-ng: Inappropriately expects \n (and \0?) in syslog 
messages
reassign 356700 syslog-ng 1.9.9-1
thanks

John A. Martin wrote:
> The same libmail-spf-query-perl-1.999.1-1 was used before and after
> the log lines were run together.  The problem arose when the perl and
> perl-base packages were upgraded from 5.8.8-2 to 5.8.8-3.
>
> Now when downgrading perl and perl-base to 5.8.8-2 the problem
> disappears.  When upgrading perl and perl-base to 5.8.8-3 the problem
> appears again.  The problem in reproducible.

Julian Mehnle wrote:
> There is a line in Sys::Syslog that adds a newline to the message before
> sending it to the syslog socket, but it hasn't changed in Perl 5.8.8

Oh, it _has_ changed!  See the attached diff of the Sys::Syslog changes in
perl 5.8.8-3 vs. perl 5.8.8-2.  Apparently the Sys::Syslog in perl 5.8.8-3
does no longer append a newline (\n) to syslog messages.  Since RFC 3164[1],
"The BSD syslog Protocol", does not require a newline terminator in syslog
messages, I think this change is valid and appropriate.

However it seems syslog-ng does not add its own newline when writing the
received messages to the log file, so it relies on the generator of the
message to add the newline.  This is a bug in syslog-ng, so I'll reassign
the bug there.

There's probably another, similar issue with regard to adding NULL byte
(\0) terminators to log messages.  RFC 3164 does not require such \0
terminators either, and the changed Sys::Syslog in perl 5.8.8-3, which also
stops appending \0 bytes to syslog messages, seems not to cause problems
with sysklogd.

Although there seems to have been some reluctance by the Perl folks to omit
the \0 terminators due to potential problems with UNIX domain sockets[2], I
don't see why such terminators would be required with UNIX domain sockets
but not with UDP sockets.  I am not a sockets expert, though.

If \0 terminators are indeed required with UNIX domain sockets (which I
don't believe to be true), then their omittance in the Sys::Syslog in perl
5.8.8-3 is inappropriate and should be reverted.  Otherwise, this is
another bug in syslog-ng.

In any case, those are not bugs in libmail-spf-query-perl AKA Mail::SPF::
Query.

Julian.

References:
 1. http://www.rfc-editor.org/rfc/rfc3164.txt
 2. http://rt.perl.org/rt3/Ticket/Display.html?id=28019#txn-83160
Remove spurious \n and \0 terminators.

diff -Naur --exclude=debian perl-5.8.8.orig/ext/Sys/Syslog/Syslog.pm perl-5.8.8/ext/Sys/Syslog/Syslog.pm
--- perl-5.8.8.orig/ext/Sys/Syslog/Syslog.pm	2006-01-11 23:22:47.000000000 +1100
+++ perl-5.8.8/ext/Sys/Syslog/Syslog.pm	2006-02-11 11:59:14.000000000 +1100
@@ -676,15 +676,16 @@
 	$mask =~ s/(?<!%)((?:%%)*)%m/$1$err/g;
     }
 
-    $mask .= "\n" unless $mask =~ /\n$/;
     $message = @_ ? sprintf($mask, @_) : $mask;
+    $message =~ s/[\r\n]+/ /g;
+    $message =~ s/ +$//;
 
     $sum = $numpri + $numfac;
     my $oldlocale = setlocale(LC_TIME);
     setlocale(LC_TIME, 'C');
     my $timestamp = strftime "%b %e %T", localtime;
     setlocale(LC_TIME, $oldlocale);
-    my $buf = "<$sum>$timestamp $whoami: $message\0";
+    my $buf = "<$sum>$timestamp $whoami: $message";
 
     # it's possible that we'll get an error from sending
     # (e.g. if method is UDP and there is no UDP listener,
@@ -724,7 +725,6 @@
 
 sub _syslog_send_console {
     my ($buf) = @_;
-    chop($buf); # delete the NUL from the end
     # The console print is a method which could block
     # so we do it in a child process and always return success
     # to the caller.
@@ -743,7 +743,7 @@
 	}
     } else {
         if (open(CONS, ">/dev/console")) {
-	    my $ret = print CONS $buf . "\r";
+	    my $ret = print CONS $buf . "\r\n";
 	    exit ($ret) if defined $pid;
 	    close CONS;
 	}

Attachment: pgpAeceCwgM6l.pgp
Description: PGP signature

Reply via email to