CC: | aab [...] aab.cc.purdue.edu |
Subject: | Bad sysopen() call in Syslog.pm -- |
Date: | Sat, 5 Apr 2008 00:39:09 -0400 (EDT) |
To: | bug-Sys-Syslog [...] rt.cpan.org |
From: | Paul Townsend <aab [...] aab.cc.purdue.edu> |
=====
I suffered from the same malady that Bug #17723 reports while using a
Solaris 8 workstation. I found (via `truss') that the script was
attempting to open "/dev/log" with the O_RDONLY flag and then was trying
to write to the file. The cause turned out to be that the third and
fourth arguments to the sysopen() function were reversed in the
Syslog.pm code. The patch below swaps the third and fourth parameters
and Sys::Syslog now works fine for "stream sockets".
How come this doesn't break for other OSs? I installed it on three
revisions of AIX with nary a complaint.
FWIW - The "perlfunc" man page says
sysopen (FILEHANDLE, FILENAME, MODE, PERMS)
while the OS's "open(2)" man pages say
open (const char *filename, int flags[, int modes])
I think the "MODE" and the "modes" words got mixed up (;-}) in
the case of Syslog.pm. The "perlfunc" man page should probably
be modifed a bit, perhaps by changing "MODE" to "FLAGS" or
something similar. (Fat chance, right?)
-- Paul Townsend (Alpha alpha Beta [at] Purdue Dot edu)
--- Syslog.pm.orig 2007-12-31 11:15:28.000000000 -0500
+++ Syslog.pm 2008-04-04 23:39:44.875852000 -0400
@@ -619,7 +619,7 @@
push @$errs, "stream $syslog_path is not writable";
return 0;
}
- if (!sysopen(SYSLOG, $syslog_path, 0400, O_WRONLY)) {
+ if (!sysopen(SYSLOG, $syslog_path, O_WRONLY, 0400)) {
push @$errs, "stream can't open $syslog_path: $!";
return 0;
}