diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-01-13 17:45:00 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-01-13 17:45:00 +0000 |
commit | 1b268631a10374af952b9bc6c86c04527c453455 (patch) | |
tree | fe5da2c47d4a365226a2b2b42ca2ca4c79be87e5 | |
parent | ce7e79404fd3d1446251f83b908450d82a67a928 (diff) | |
download | perl-1b268631a10374af952b9bc6c86c04527c453455.tar.gz |
Integrate:
[ 26752]
Upgrade to Sys::Syslog 0.12
[ 26766]
Remove Syslog tests that use external modules
[ 26768]
If getservbyname fails tell what service the lookup
attempt tried to use.
[ 26769]
Why should Syslog jump through hoops to look up the hostname so it can
immediately convert it to an IP address, when all it really wants is
a connection to the loopback device?
[ 26772]
Gisle is correct - $host needs to stay in case the user sets it
themselves. But if the user doesn't, default to INADDR_LOOPBACK.
[ 26773]
Subject: Re: Sys::Syslog blows up rather spectacularly on Solaris
From: Alan Burlison <Alan.Burlison@sun.com>
Message-ID: <43C3D80E.20704@sun.com>
Date: Tue, 10 Jan 2006 15:51:42 +0000
[ 26782]
Subject: Fw: CPAN Upload: S/SA/SAPER/Sys-Syslog-0.13.tar.gz
From: Sébastien Aperghis-Tramoni <maddingue@free.fr>
Date: Wed, 11 Jan 2006 02:13:31 +0100
Message-ID: <1136942011.43c45bbb82dce@imp1-g19.free.fr>
p4raw-link: @26782 on //depot/perl: 5f9a320f7db18c2f082bcc387670ef2c479af6b0
p4raw-link: @26773 on //depot/perl: 71cedc6d5edb73a8e9122dd411eab6a5cb2978b9
p4raw-link: @26772 on //depot/perl: 807d24c827c4cbd2046888817a0509dd8c4b593a
p4raw-link: @26769 on //depot/perl: 3ed3657f6b25720167d7640e4a1c6c6eef504596
p4raw-link: @26768 on //depot/perl: 18fd236b74f8374016eb16e779d1122c897d2f4a
p4raw-link: @26766 on //depot/perl: eaba850b35360c3ac11654547219f859d3e632e4
p4raw-link: @26752 on //depot/perl: 04f98b2924420f2d5dda20af9ff8971605fd60d2
p4raw-id: //depot/maint-5.8/perl@26828
p4raw-deleted: from //depot/perl@26827 'delete in'
ext/Sys/Syslog/t/distchk.t ext/Sys/Syslog/t/pod.t
ext/Sys/Syslog/t/podcover.t ext/Sys/Syslog/t/portfs.t
(@26309..)
p4raw-integrated: from //depot/perl@26827 'copy in'
ext/Sys/Syslog/README (@26515..) ext/Sys/Syslog/Changes
(@26752..)
p4raw-integrated: from //depot/perl@26773 'ignore'
ext/Sys/Syslog/Syslog.pm (@26772..)
p4raw-integrated: from //depot/perl@26766 'merge in' MANIFEST
(@26761..)
p4raw-integrated: from //depot/perl@26752 'ignore'
ext/Sys/Syslog/t/constants.t (@26309..)
-rw-r--r-- | MANIFEST | 5 | ||||
-rw-r--r-- | ext/Sys/Syslog/Changes | 24 | ||||
-rw-r--r-- | ext/Sys/Syslog/README | 7 | ||||
-rw-r--r-- | ext/Sys/Syslog/Syslog.pm | 59 | ||||
-rw-r--r-- | ext/Sys/Syslog/t/constants.t | 61 | ||||
-rw-r--r-- | ext/Sys/Syslog/t/distchk.t | 4 | ||||
-rw-r--r-- | ext/Sys/Syslog/t/pod.t | 6 | ||||
-rw-r--r-- | ext/Sys/Syslog/t/podcover.t | 6 | ||||
-rw-r--r-- | ext/Sys/Syslog/t/portfs.t | 8 |
9 files changed, 87 insertions, 93 deletions
@@ -864,11 +864,6 @@ ext/Sys/Syslog/Syslog.pm Sys::Syslog extension Perl module ext/Sys/Syslog/Syslog.xs Sys::Syslog extension external subroutines ext/Sys/Syslog/t/00-load.t test for Sys::Syslog ext/Sys/Syslog/t/constants.t test for Sys::Syslog -ext/Sys/Syslog/t/distchk.t test for Sys::Syslog -ext/Sys/Syslog/t/podcover.t test for Sys::Syslog -ext/Sys/Syslog/t/podspell.t test for Sys::Syslog -ext/Sys/Syslog/t/pod.t test for Sys::Syslog -ext/Sys/Syslog/t/portfs.t test for Sys::Syslog ext/Sys/Syslog/t/syslog.t See if Sys::Syslog works ext/Thread/create.tx Test thread creation ext/Thread/die2.tx Test thread die() differently diff --git a/ext/Sys/Syslog/Changes b/ext/Sys/Syslog/Changes index a2ee1f80ff..0a0e15e147 100644 --- a/ext/Sys/Syslog/Changes +++ b/ext/Sys/Syslog/Changes @@ -1,7 +1,29 @@ Revision history for Sys-Syslog +0.13 2006.01.11 + [CODE] Merged blead@26768: If getservbyname fails tell what service + the lookup attempt tried to use. + [CODE] Merged blead@26769: suppress Sys::Hostname usage and directly + use INADDR_LOOPBACK. + [CODE] Merged blead@26772: $host needs to stay in case the user sets it. + [CODE] Merged blead@26773: check that $syslog_path is a socket. + [TESTS] RT#16980 (Alan Burlison): Sys::Syslog blows up rather + spectacularly on Solaris. Corrected by previous patches. + [TESTS] Applied Gisle Aas patch for a better handling of error messages, + then optimized it. + [TESTS] RT#16974: Failed test in t/podspell. This test is now skipped. + +0.12 2006.01.07 + [CODE] Merged some modifications from bleadperl. + [DOC] Added a link to an article about Sys::Syslog. + [TESTS] Removed optional dependency on Test::Exception. + [TESTS] Improved t/constant.t + [TESTS] Rewrote t/constants.t because future versions of + ExtUtils::Constant will prevent the constant() function from + being directly called. + 0.11 2005.12.28 - [BUGFIX] setlogmask() now behaves liek its C counterpart. + [BUGFIX] setlogmask() now behaves like its C counterpart. [CODE] Can now export and use the macros. [CODE] Support for three Exporter tags. [CODE] XSLoader is now optional. diff --git a/ext/Sys/Syslog/README b/ext/Sys/Syslog/README index 2456652e67..0d468645ee 100644 --- a/ext/Sys/Syslog/README +++ b/ext/Sys/Syslog/README @@ -26,7 +26,7 @@ INSTALLATION - Linux 2.6, gcc 3.4.1 - FreeBSD 4.7, gcc 2.95.4 - - Mac OS X 10.2.6, gcc 3.1 + - Mac OS X 10.4, gcc 4.0.1 Sys::Syslog should on any Perl since 5.6.0. This module has been tested by the author to check that it works with the following @@ -36,11 +36,10 @@ INSTALLATION - Perl 5.8.5 i386-linux-thread-multi (vendor build) - Perl 5.6.1 i386-freebsd (custom build) - Perl 5.8.7 i386-freebsd (custom build) - - Perl 5.6.0 darwin (vendor build) - - Perl 5.8.7 cygwin-thread-multi-64int (vendor build) + - Perl 5.8.6 darwin-thread-multi-2level (vendor build) See also the corresponding CPAN Testers page: - http://testers.cpan.org/show/Net-Pcap.html + http://testers.cpan.org/show/Sys-Syslog.html SUPPORT AND DOCUMENTATION diff --git a/ext/Sys/Syslog/Syslog.pm b/ext/Sys/Syslog/Syslog.pm index 6bdb3b9197..40b158e288 100644 --- a/ext/Sys/Syslog/Syslog.pm +++ b/ext/Sys/Syslog/Syslog.pm @@ -4,7 +4,7 @@ use Carp; require 5.006; require Exporter; -our $VERSION = '0.11'; +our $VERSION = '0.13'; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( @@ -53,7 +53,7 @@ Sys::Syslog - Perl interface to the UNIX syslog(3) calls =head1 VERSION -Version 0.11 +Version 0.13 =head1 SYNOPSIS @@ -436,6 +436,8 @@ was unable to find an appropriate an appropriate device. L<syslog(3)> +I<Syslogging with Perl>, L<http://lexington.pm.org/meetings/022001.html> + =head1 AUTHOR @@ -797,20 +799,12 @@ sub connect { my($old) = select(SYSLOG); $| = 1; select($old); } else { @fallbackMethods = (); - foreach my $err (@errs) { - carp $err; - } - croak "no connection to syslog available"; + croak join "\n\t- ", "no connection to syslog available", @errs } } sub connect_tcp { my ($errs) = @_; - unless ($host) { - require Sys::Hostname; - my($host_uniq) = Sys::Hostname::hostname(); - ($host) = $host_uniq =~ /([A-Za-z0-9_.-]+)/; # allow FQDN (inc _) - } my $tcp = getprotobyname('tcp'); if (!defined $tcp) { push(@{$errs}, "getprotobyname failed for tcp"); @@ -819,16 +813,23 @@ sub connect_tcp { my $syslog = getservbyname('syslog','tcp'); $syslog = getservbyname('syslogng','tcp') unless (defined $syslog); if (!defined $syslog) { - push(@{$errs}, "getservbyname failed for tcp"); + push(@{$errs}, "getservbyname failed for syslog/tcp and syslogng/tcp"); return 0; } my $this = sockaddr_in($syslog, INADDR_ANY); - my $that = sockaddr_in($syslog, inet_aton($host)); - if (!$that) { - push(@{$errs}, "can't lookup $host"); - return 0; + my $that; + if (defined $host) { + $that = inet_aton($host); + if (!$that) { + push(@{$errs}, "can't lookup $host"); + return 0; + } + } else { + $that = INADDR_LOOPBACK; } + $that = sockaddr_in($syslog, $that); + if (!socket(SYSLOG,AF_INET,SOCK_STREAM,$tcp)) { push(@{$errs}, "tcp socket: $!"); return 0; @@ -845,11 +846,6 @@ sub connect_tcp { sub connect_udp { my ($errs) = @_; - unless ($host) { - require Sys::Hostname; - my($host_uniq) = Sys::Hostname::hostname(); - ($host) = $host_uniq =~ /([A-Za-z0-9_.-]+)/; # allow FQDN (inc _) - } my $udp = getprotobyname('udp'); if (!defined $udp) { push(@{$errs}, "getprotobyname failed for udp"); @@ -857,15 +853,22 @@ sub connect_udp { } my $syslog = getservbyname('syslog','udp'); if (!defined $syslog) { - push(@{$errs}, "getservbyname failed for udp"); + push(@{$errs}, "getservbyname failed for syslog/udp"); return 0; } my $this = sockaddr_in($syslog, INADDR_ANY); - my $that = sockaddr_in($syslog, inet_aton($host)); - if (!$that) { - push(@{$errs}, "can't lookup $host"); - return 0; + my $that; + if (defined $host) { + $that = inet_aton($host); + if (!$that) { + push(@{$errs}, "can't lookup $host"); + return 0; + } + } else { + $that = INADDR_LOOPBACK; } + $that = sockaddr_in($syslog, $that); + if (!socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp)) { push(@{$errs}, "udp socket: $!"); return 0; @@ -910,6 +913,10 @@ sub connect_unix { push(@{$errs}, "_PATH_LOG not available in syslog.h"); return 0; } + if (! -S $syslog_path) { + push(@{$errs}, "$syslog_path is not a socket"); + return 0; + } my $that = sockaddr_un($syslog_path); if (!$that) { push(@{$errs}, "can't locate $syslog_path"); diff --git a/ext/Sys/Syslog/t/constants.t b/ext/Sys/Syslog/t/constants.t index 061d018a26..d7c7b0c7df 100644 --- a/ext/Sys/Syslog/t/constants.t +++ b/ext/Sys/Syslog/t/constants.t @@ -1,46 +1,41 @@ #!/usr/bin/perl -T use strict; +use File::Spec; use Test::More; -my @names; -BEGIN { - if(open(MACROS, 'macros.all')) { - @names = map {chomp;$_} <MACROS>; - close(MACROS); - plan tests => @names + 3; - } else { - plan skip_all => "can't read 'macros.all': $!" - } -} -use Sys::Syslog; -eval "use Test::Exception"; my $has_test_exception = !$@; +my $macrosall = $ENV{PERL_CORE} ? File::Spec->catfile(qw(.. ext Sys Syslog macros.all)) + : 'macros.all'; +open(MACROS, $macrosall) or plan skip_all => "can't read '$macrosall': $!"; +my @names = map {chomp;$_} <MACROS>; +close(MACROS); +plan tests => @names * 2 + 2; -# Testing error messages -SKIP: { - skip "Test::Exception not available", 1 unless $has_test_exception; - - # constant() errors - throws_ok(sub { - Sys::Syslog::constant() - }, '/^Usage: Sys::Syslog::constant\(sv\)/', - "calling constant() with no argument"); -} +my $callpack = my $testpack = 'Sys::Syslog'; +eval "use $callpack"; -# Testing constant() -like( Sys::Syslog::constant('This'), - '/^This is not a valid Sys::Syslog macro/', - "calling constant() with a non existing name" ); +eval "${callpack}::This()"; +like( $@, "/^This is not a valid $testpack macro/", "trying a non-existing macro"); -like( Sys::Syslog::constant('NOSUCHNAME'), - '/^NOSUCHNAME is not a valid Sys::Syslog macro/', - "calling constant() with a non existing name" ); +eval "${callpack}::NOSUCHNAME()"; +like( $@, "/^NOSUCHNAME is not a valid $testpack macro/", "trying a non-existing macro"); # Testing all macros if(@names) { for my $name (@names) { - like( Sys::Syslog::constant($name), - '/^(?:\d+|Your vendor has not defined Sys::Syslog macro '.$name.', used)$/', - "checking that $name is a number (".Sys::Syslog::constant($name).")" ); + SKIP: { + $name =~ /^(\w+)$/ or skip "invalid name '$name'", 2; + $name = $1; + my $v = eval "${callpack}::$name()"; + + if(defined($v) && $v =~ /^\d+$/) { + is( $@, '', "calling the constant $name as a function" ); + like( $v, '/^\d+$/', "checking that $name is a number ($v)" ); + + } else { + like( $@, "/^Your vendor has not defined $testpack macro $name/", + "calling the constant via its name" ); + skip "irrelevant test in this case", 1 + } + } } } - diff --git a/ext/Sys/Syslog/t/distchk.t b/ext/Sys/Syslog/t/distchk.t deleted file mode 100644 index 2db740b264..0000000000 --- a/ext/Sys/Syslog/t/distchk.t +++ /dev/null @@ -1,4 +0,0 @@ -use strict; -use Test::More; -eval "use Test::Distribution not => [qw(versions podcover use)]"; -plan skip_all => "Test::Distribution required for checking distribution" if $@; diff --git a/ext/Sys/Syslog/t/pod.t b/ext/Sys/Syslog/t/pod.t deleted file mode 100644 index 976d7cdfb2..0000000000 --- a/ext/Sys/Syslog/t/pod.t +++ /dev/null @@ -1,6 +0,0 @@ -#!perl -T - -use Test::More; -eval "use Test::Pod 1.14"; -plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; -all_pod_files_ok(); diff --git a/ext/Sys/Syslog/t/podcover.t b/ext/Sys/Syslog/t/podcover.t deleted file mode 100644 index a33cb859e7..0000000000 --- a/ext/Sys/Syslog/t/podcover.t +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/perl -T -use strict; -use Test::More; -eval "use Test::Pod::Coverage 1.06"; -plan skip_all => "Test::Pod::Coverage 1.06 required for testing POD coverage" if $@; -all_pod_coverage_ok({also_private => [qw(^constant$ ^connect ^disconnect$ ^xlate$ ^LOG_)]}); diff --git a/ext/Sys/Syslog/t/portfs.t b/ext/Sys/Syslog/t/portfs.t deleted file mode 100644 index 80d57b07bf..0000000000 --- a/ext/Sys/Syslog/t/portfs.t +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/perl -T -use strict; -use Test::More; -eval "use Test::Portability::Files"; -plan skip_all => "Test::Portability::Files required for testing filenames portability" if $@; - -# run the selected tests -run_tests(); |