Skip Menu |
 

This queue is for tickets about the Sys-Syslog CPAN distribution.

Report information
The Basics
Id: 69992
Status: resolved
Priority: 0/
Queue: Sys-Syslog

People
Owner: Nobody in particular
Requestors: ntyni [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.29
Fixed in: 0.31

Attachments
0001-Only-use-the-requested-socket-types-if-setlogsock-is.patch



Subject: setlogsock() and default methods
Download (untitled) / with headers
text/plain 844b
Changes to setlogsock() in 0.28 made the function prepend the requested socket types to the list of default ones instead of overriding the default list. This behaviour is undocumented and makes the test suite unwittingly test unrelated socket types: for instance, it now claims 'tcp' is fully working even when "syslog/tcp" cannot be resolved and there is no TCP listener on the system. It also makes it impossible to spot things like a missing UDP receiver, as openlog() will silently fall back to the native logging method. Please consider the attached patch that reverts this behaviour change and augments the test suite. The patch context requires the one in [rt.cpan.org #69986] to be applied, but this should be easily resolvable should you decide to reject that one. Thanks for your work on Sys-Syslog, -- Niko Tyni ntyni@debian.org
Subject: 0001-Only-use-the-requested-socket-types-if-setlogsock-is.patch
From 8a3e720a7f84248c86ade7a7898c084b0faec85b Mon Sep 17 00:00:00 2001 From: Niko Tyni <ntyni@debian.org> Date: Wed, 3 Aug 2011 21:32:19 +0300 Subject: [PATCH] Only use the requested socket types if setlogsock() is called Changes to setlogsock() in 0.28 made the function prepend the requested socket types to the list of default ones instead of overriding the default list. This behaviour is undocumented and makes the test suite unwittingly test unrelated socket types: for instance, it now claims 'tcp' is fully working even when "syslog/tcp" cannot be resolved and there is no TCP listener on the system. Restore the 0.27 behaviour of using only the requested socket type(s) and augment the test suite to cover this. --- Syslog.pm | 2 +- t/syslog.t | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Syslog.pm b/Syslog.pm index 4fcedd7..bc6752f 100644 --- a/Syslog.pm +++ b/Syslog.pm @@ -314,7 +314,7 @@ sub setlogsock { for my $sock_type (@sock_types) { if ( $mechanism{$sock_type}{check}->() ) { - unshift @connectMethods, $sock_type; + @connectMethods = ( $sock_type ); $found = 1; } else { diff --git a/t/syslog.t b/t/syslog.t index ebc1326..90df65d 100644 --- a/t/syslog.t +++ b/t/syslog.t @@ -296,3 +296,17 @@ SKIP: { ok( !$r, "setlogsock failed correctly when tcp services can't be resolved"); is( $@, '', "setlogsock didn't croak"); } + +BEGIN { $tests += 2 } +SKIP: { + my $file = "foobar"; + open(TST, ">$file") or skip "can't create file '$file': $!", 2; + close(TST); + eval { $r = setlogsock("stream", $file) }; + skip "can't test openlog() failures with a missing stream", 2 if !$r; + unlink $file; + $r = eval { openlog('perl', 'ndelay', 'local0') }; + ok( !defined $r, "openlog() failed correctly with a nonexistent stream"); + like( $@, "/not writable/", "openlog() croaked correctly with a nonexistent stream"); +} + -- 1.7.5.4
Subject: Re: [rt.cpan.org #69992] setlogsock() and default methods
Date: Sat, 18 Aug 2012 14:28:59 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Hello, Niko Tyni wrote via RT: Show quoted text
> Changes to setlogsock() in 0.28 made the function prepend the > requested socket types to the list of default ones instead of > overriding the default list. > > This behaviour is undocumented and makes the test suite unwittingly > test unrelated socket types: for instance, it now claims 'tcp' is fully > working even when "syslog/tcp" cannot be resolved and there is no TCP > listener on the system. > > It also makes it impossible to spot things like a missing UDP receiver, > as openlog() will silently fall back to the native logging method. > > Please consider the attached patch that reverts this behaviour change > and augments the test suite. The patch context requires the one in > [rt.cpan.org #69986] to be applied, but this should be easily resolvable > should you decide to reject that one.
I couldn't directly apply this patch because it would have prevented setlogsock() from working in certain cases, but did adapt it. Thanks for reporting this problem, it will be fixed in version 0.31 -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.