Subject: | LOG_UNIX to rsyslog requires SOCK_DGRAM |
Date: | Fri, 20 Aug 2010 17:46:52 +0200 |
To: | bug-Log-Syslog-Fast [...] rt.cpan.org |
From: | Tim Esselens <tim.esselens [...] gmail.com> |
test: Log::Syslog::Fast->new(LOG_UNIX,'/dev/log',0,LOG_LOCAL0,LOG_INFO,'foo','logger')
env: centos 5.5, perl 5.5.8, rsyslogd 3.22.1
result: Error in ->new: Protocol wrong type for socket at file line nn
findings:
- rsyslogd uses (AF_UNIX/SOCK_DGRAM)
- Sys::Syslog uses connect to check the socket and retries with SOCK_DGRAM:
socket(SYSLOG,AF_UNIX,SOCK_STREAM,0) || croak "socket: $!";
if (!connect(SYSLOG,$that)) {
socket(SYSLOG,AF_UNIX,SOCK_DGRAM,0) || croak "socket: $!";
proposed patch:
--- FastSyslogger.cpp.orig 2010-08-20 17:28:08.000000000 +0200
+++ FastSyslogger.cpp 2010-08-20 17:43:15.000000000 +0200
@@ -78,6 +78,8 @@
// construct socket
sock_ = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (connect(sock_, p_address, address_len) != 0)
+ sock_ = socket(AF_UNIX, SOCK_DGRAM, 0);
}
else
throw "bad protocol";