From: Ulrich Pfeifer Date: Fri, 5 Sep 1997 00:00:00 +0000 (+0000) Subject: Syslog.pm and missing _PATH_LOG X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6a06c6b3ce238e0862e09fdca0c17e9d40e9b2c;p=p5sagit%2Fp5-mst-13.2.git Syslog.pm and missing _PATH_LOG I just ran into a problem with Syslog.pm. I tried to install some modules which did call Sys::Syslog::setlogsock('unix'). The following connect fails because my syslog.ph does not define _PATH_LOG (This is SunOS 5.5.1). The easiest way to handle this would be to make setlogsock('unix') a NOOP if _PATH_LOG is not defined. I am not advocating to ignore it silently. But can we make setlogsock return a value indicating that the operation did or did not work? It seems a little cleaner that to force users to check for _PATH_LOG themselves? p5p-msgid: p5iuw1cris.fsf@knowway.de.uu.net --- diff --git a/lib/Sys/Syslog.pm b/lib/Sys/Syslog.pm index f6d9c35..2790e48 100644 --- a/lib/Sys/Syslog.pm +++ b/lib/Sys/Syslog.pm @@ -59,10 +59,11 @@ Sets log mask I<$mask_priority> and returns the old mask. Sets the socket type to be used for the next call to C or C. -A value of 'unix' will connect to the UNIX domain socket returned -by C<_PATH_LOG> in F. A value of 'inet' will connect -to an INET socket returned by getservbyname(). -Any other value croaks. +A value of 'unix' will connect to the UNIX domain socket returned by +C<_PATH_LOG> in F. If F fails to define +C<_PATH_LOG>, C returns C; otherwise a true value is +returned. A value of 'inet' will connect to an INET socket returned by +getservbyname(). Any other value croaks. The default is for the INET socket to be used. @@ -135,12 +136,18 @@ sub setlogmask { sub setlogsock { local($setsock) = shift; if (lc($setsock) eq 'unix') { + if (defined &_PATH_LOG) { + $sock_unix = 1; + } else { + return; + } $sock_unix = 1; } elsif (lc($setsock) eq 'inet') { undef($sock_unix); } else { croak "Invalid argument passed to setlogsock; must be 'unix' or 'inet'"; } + return 1; } sub syslog {