Skip Menu |
 

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

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

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

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

Attachments


Subject: setlogsock() doesn't return undef on failure
Download (untitled) / with headers
text/plain 262b
Hi, contrary to the documentation, since 0.28 setlogsock() returns true even when the requested socket type could not be used. Please see the attached proposed patch with test cases and a fix. Thanks for your work on Sys-Syslog, -- Niko Tyni ntyni@debian.org
Subject: 0001-Make-setlogsock-return-value-meaningful-on-failures-.patch
From 4e79d8a2cb732dbe28f5759b0f3e896fd4fff3f2 Mon Sep 17 00:00:00 2001 From: Niko Tyni <ntyni@debian.org> Date: Wed, 3 Aug 2011 19:11:43 +0300 Subject: [PATCH] Make setlogsock() return value meaningful on failures again Changes to setlogsock() in 0.28 made the function return true even when the requested socket type could not be used. This includes cases where _PATH_LOG doesn't exist, the requested stream path can't be opened or the requested network service (syslog/udp, syslog/tcp, syslog-ng/tcp) can't be resolved. Restore the return value behaviour to the documented one and include test cases for the easily simulated or detected situations. The syslog tcp services are not defined by default on at least Debian and FreeBSD, so the relevant tests should give moderate coverage. --- Syslog.pm | 4 +++- t/syslog.t | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/Syslog.pm b/Syslog.pm index a68f817..4fcedd7 100644 --- a/Syslog.pm +++ b/Syslog.pm @@ -310,10 +310,12 @@ sub setlogsock { $transmit_ok = 0; @fallbackMethods = (); @connectMethods = @defaultMethods; + my $found = 0; for my $sock_type (@sock_types) { if ( $mechanism{$sock_type}{check}->() ) { unshift @connectMethods, $sock_type; + $found = 1; } else { warnings::warnif "setlogsock(): type='$sock_type': " @@ -321,7 +323,7 @@ sub setlogsock { } } - return 1; + return $found; } sub syslog { diff --git a/t/syslog.t b/t/syslog.t index c2bc7ff..2eabb00 100644 --- a/t/syslog.t +++ b/t/syslog.t @@ -283,3 +283,16 @@ BEGIN { $tests += 3 + 4 * 3 } setlogmask($oldmask); } } + +BEGIN { $tests += 4 } +eval { $r = setlogsock("stream", "foo/bar") }; +ok( !$r, "setlogsock failed correctly with a nonexistent stream path"); +is( $@, '', "setlogsock didn't croak"); + +SKIP: { + my $service = getservbyname("syslog", "tcp") || getservbyname("syslog-ng", "tcp"); + skip "can't test setlogsock() tcp failure", 2 if $service; + eval { $r = setlogsock("tcp") }; + ok( !$r, "setlogsock failed correctly when tcp services can't be resolved"); + is( $@, '', "setlogsock didn't croak"); +} -- 1.7.5.4
Subject: Re: [rt.cpan.org #69986] AutoReply: setlogsock() doesn't return undef on failure
Date: Wed, 3 Aug 2011 19:50:26 +0300
To: Bugs in Sys-Syslog via RT <bug-Sys-Syslog [...] rt.cpan.org>
From: Niko Tyni <ntyni [...] iki.fi>
Download (untitled) / with headers
text/plain 495b
On Wed, Aug 03, 2011 at 12:34:36PM -0400, Bugs in Sys-Syslog via RT wrote: Show quoted text
> contrary to the documentation, since 0.28 setlogsock() returns true even > when the requested socket type could not be used. > > Please see the attached proposed patch with test cases and a fix.
Oops, the patch had a one character typo that could cause test failures on a system with syslogng/tcp (but not syslog/tcp) in /etc/services. Revised patch attached for your convenience. -- Niko Tyni ntyni@debian.org

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #69986] setlogsock() doesn't return undef on failure
Date: Wed, 15 Aug 2012 16:44:02 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 374b
Niko Tyni wrote via RT: Show quoted text
> Hi,
Hello, Show quoted text
> contrary to the documentation, since 0.28 setlogsock() returns true even > when the requested socket type could not be used. > > Please see the attached proposed patch with test cases and a fix.
Thanks, applied. This will be included in Sys::Syslog 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.