diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a428de8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/IO-Socket-IP-0.21.tar.gz diff --git a/.perl-IO-Socket-IP.metadata b/.perl-IO-Socket-IP.metadata new file mode 100644 index 0000000..4969854 --- /dev/null +++ b/.perl-IO-Socket-IP.metadata @@ -0,0 +1 @@ +5ef355e02221da9dd83d491a109a6efac6a13daf SOURCES/IO-Socket-IP-0.21.tar.gz diff --git a/SOURCES/IO-Socket-IP-0.21-Correct-prototol-family-in-hints.patch b/SOURCES/IO-Socket-IP-0.21-Correct-prototol-family-in-hints.patch new file mode 100644 index 0000000..4582c29 --- /dev/null +++ b/SOURCES/IO-Socket-IP-0.21-Correct-prototol-family-in-hints.patch @@ -0,0 +1,83 @@ +From 0714c89c318afdc869a6b6e6fe0832dc63cd4ca7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 18 Sep 2017 18:22:34 +0200 +Subject: [PATCH] Correct prototol family in hints +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This corrects a warning about undefined protocol passed to Perl +socket() function after applying the fix for a hostless constructor: + +$ ./Build test --verbose=1 --test_files t/19no-addrs.t +t/19no-addrs.t .. +ok 1 - $sock->fileno for Family => AF_INET +ok 2 - $sock->sockdomain for Family => AF_INET +ok 3 - $sock->socktype for Family => AF_INET +ok 4 - $sock->fileno for Family => AF_INET6 +ok 5 - $sock->sockdomain for Family => AF_INET6 +ok 6 - $sock->socktype for Family => AF_INET6 +ok 7 - $sock->fileno for Type => SOCK_STREAM +ok 8 - $sock->socktype for Type => SOCK_STREAM +1..8 +Use of uninitialized value $protocol in socket at /usr/lib64/perl5/IO/Socket.pm line 81. +ok +All tests successful. + +This a port of upstream changes from 0.29 to 0.21 that were described +as: + +0.29 2014/02/24 16:06:29 + [BUGFIXES] + * Workaround for OSes that disobey AI_ADDRCONFIG and yield AIs on + families the kernel will not support anyway (e.g. HPUX) + +Signed-off-by: Petr Písař +--- + lib/IO/Socket/IP.pm | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +diff --git a/lib/IO/Socket/IP.pm b/lib/IO/Socket/IP.pm +index 208d837..bea7d39 100644 +--- a/lib/IO/Socket/IP.pm ++++ b/lib/IO/Socket/IP.pm +@@ -521,24 +521,27 @@ sub _configure + if( !@infos ) { + + # If there was a Family hint then create a plain unbound, unconnected socket ++ if( defined $hints{family} ) { ++ @infos = ( { ++ family => $hints{family}, ++ socktype => $hints{socktype}, ++ protocol => $hints{protocol}, ++ } ); ++ } + # If there wasn't, use getaddrinfo()'s AI_ADDRCONFIG side-effect to guess a + # suitable family first. +- if( !defined $hints{family} ) { +- my ( $err, $addrinfo ) = getaddrinfo( "", "0", \%hints ); ++ else { ++ ( my $err, @infos ) = getaddrinfo( "", "0", \%hints ); + if( $err ) { + $@ = "$err"; + $! = EINVAL; + return; + } + +- $hints{family} = $addrinfo->{family}; ++ # We'll take all the @infos anyway, because some OSes (HPUX) are known to ++ # ignore the AI_ADDRCONFIG hint and return AF_INET6 even if they don't ++ # support them + } +- +- @infos = ( { +- family => $hints{family}, +- socktype => $hints{socktype}, +- protocol => $hints{protocol}, +- } ); + } + + # In the nonblocking case, caller will be calling ->setup multiple times. +-- +2.13.5 + diff --git a/SOURCES/IO-Socket-IP-0.21-Ensure-that-a-Host-Family-less-constructor-still-con.patch b/SOURCES/IO-Socket-IP-0.21-Ensure-that-a-Host-Family-less-constructor-still-con.patch new file mode 100644 index 0000000..5832012 --- /dev/null +++ b/SOURCES/IO-Socket-IP-0.21-Ensure-that-a-Host-Family-less-constructor-still-con.patch @@ -0,0 +1,104 @@ +From d6a3ed8299ac6d5cac8db2e0f8e438dcfb8964a2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 18 Sep 2017 17:21:26 +0200 +Subject: [PATCH] Ensure that a Host/Family-less constructor still constructs a + socket +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +An upstream fix ported from 0.25 version to 0.21: + +0.25 2014/01/11 17:19:29 + [BUGFIXES] + * Ensure that a Host/Family-less constructor still constructs a + socket, by using gai()s AI_ADDRCONFIG hint + +CPAN RT#91982 + +Signed-off-by: Petr Písař +--- + README | 6 ++++++ + lib/IO/Socket/IP.pm | 22 +++++++++++++++++++++- + t/19no-addrs.t | 9 +++++++++ + 3 files changed, 36 insertions(+), 1 deletion(-) + +diff --git a/README b/README +index 32ccc65..d09fe2b 100644 +--- a/README ++++ b/README +@@ -189,6 +189,12 @@ CONSTRUCTORS + compatibility with `IO::Socket::INET'. Other named arguments that are + not recognised are ignored. + ++ If neither `Family' nor any hosts or addresses are passed, nor any ++ `*AddrInfo', then the constructor has no information on which to decide ++ a socket family to create. In this case, it performs a `getaddinfo' call ++ with the `AI_ADDRCONFIG' flag, no host name, and a service name of ++ `"0"', and uses the family of the first returned result. ++ + If the constructor fails, it will set `$@' to an appropriate error + message; this may be from `$!' or it may be some other string; not every + failure necessarily has an associated `errno' value. +diff --git a/lib/IO/Socket/IP.pm b/lib/IO/Socket/IP.pm +index cc9c350..208d837 100644 +--- a/lib/IO/Socket/IP.pm ++++ b/lib/IO/Socket/IP.pm +@@ -311,6 +311,12 @@ C and C respectively will be set, to maintain + compatibility with C. Other named arguments that are not + recognised are ignored. + ++If neither C nor any hosts or addresses are passed, nor any ++C<*AddrInfo>, then the constructor has no information on which to decide a ++socket family to create. In this case, it performs a C call with ++the C flag, no host name, and a service name of C<"0">, and ++uses the family of the first returned result. ++ + If the constructor fails, it will set C<$@> to an appropriate error message; + this may be from C<$!> or it may be some other string; not every failure + necessarily has an associated C value. +@@ -512,8 +518,22 @@ sub _configure + } + } + +- if( !@infos and defined $hints{family} ) { ++ if( !@infos ) { ++ + # If there was a Family hint then create a plain unbound, unconnected socket ++ # If there wasn't, use getaddrinfo()'s AI_ADDRCONFIG side-effect to guess a ++ # suitable family first. ++ if( !defined $hints{family} ) { ++ my ( $err, $addrinfo ) = getaddrinfo( "", "0", \%hints ); ++ if( $err ) { ++ $@ = "$err"; ++ $! = EINVAL; ++ return; ++ } ++ ++ $hints{family} = $addrinfo->{family}; ++ } ++ + @infos = ( { + family => $hints{family}, + socktype => $hints{socktype}, +diff --git a/t/19no-addrs.t b/t/19no-addrs.t +index 65716cf..0ccb84f 100644 +--- a/t/19no-addrs.t ++++ b/t/19no-addrs.t +@@ -33,4 +33,13 @@ SKIP: { + is( $sock->socktype, SOCK_STREAM, '$sock->socktype for Family => AF_INET6' ); + } + ++# Lack of even a Family hint - _a_ socket is created but we don't guarantee ++# what family ++{ ++ my $sock = IO::Socket::IP->new( Type => SOCK_STREAM ); ++ ++ ok( defined $sock->fileno, '$sock->fileno for Type => SOCK_STREAM' ); ++ is( $sock->socktype, SOCK_STREAM, '$sock->socktype for Type => SOCK_STREAM' ); ++} ++ + done_testing; +-- +2.13.5 + diff --git a/SOURCES/IO-Socket-IP-so_reuseport.patch b/SOURCES/IO-Socket-IP-so_reuseport.patch new file mode 100644 index 0000000..9cf625b --- /dev/null +++ b/SOURCES/IO-Socket-IP-so_reuseport.patch @@ -0,0 +1,12 @@ +diff --git a/t/11sockopts.t b/t/11sockopts.t +index 02f733c..e11051a 100644 +--- a/t/11sockopts.t ++++ b/t/11sockopts.t +@@ -28,6 +28,7 @@ TODO: { + SKIP: { + # Some OSes don't implement SO_REUSEPORT + skip "No SO_REUSEPORT", 1 unless defined eval { SO_REUSEPORT }; ++ skip "Koji builders don't support SO_REUSEPORT", 1; + + my $sock = IO::Socket::IP->new( + LocalHost => "127.0.0.1", diff --git a/SPECS/perl-IO-Socket-IP.spec b/SPECS/perl-IO-Socket-IP.spec new file mode 100644 index 0000000..b376208 --- /dev/null +++ b/SPECS/perl-IO-Socket-IP.spec @@ -0,0 +1,127 @@ +Name: perl-IO-Socket-IP +Version: 0.21 +Release: 5%{?dist} +Summary: Drop-in replacement for IO::Socket::INET supporting both IPv4 and IPv6 +License: GPL+ or Artistic +Group: Development/Libraries +URL: http://search.cpan.org/dist/IO-Socket-IP/ +Source0: http://www.cpan.org/authors/id/P/PE/PEVANS/IO-Socket-IP-%{version}.tar.gz +Patch0: IO-Socket-IP-so_reuseport.patch +# 1/2 Fix constructing sockets without specifying host or family, bug #1492760, +# CPAN RT#91982, fixed in 0.25 +Patch1: IO-Socket-IP-0.21-Ensure-that-a-Host-Family-less-constructor-still-con.patch +# 2/2 Fix constructing sockets without specifying host or family, bug #1492760, +# fixed in 0.29 +Patch2: IO-Socket-IP-0.21-Correct-prototol-family-in-hints.patch +BuildArch: noarch +BuildRequires: perl +BuildRequires: perl(base) +BuildRequires: perl(Carp) +BuildRequires: perl(constant) +BuildRequires: perl(Errno) +BuildRequires: perl(IO::Socket) +BuildRequires: perl(IO::Socket::INET) +BuildRequires: perl(Module::Build) +BuildRequires: perl(POSIX) +BuildRequires: perl(Socket) >= 1.97 +BuildRequires: perl(Socket6) +BuildRequires: perl(strict) +BuildRequires: perl(Test::More) +BuildRequires: perl(Test::Pod) +BuildRequires: perl(warnings) +Requires: perl(:MODULE_COMPAT_%(eval "$(perl -V:version)"; echo $version)) + +%{?perl_default_filter} + +%description +This module provides a protocol-independent way to use IPv4 and IPv6 +sockets, as a drop-in replacement for IO::Socket::INET. Most constructor +arguments and methods are provided in a backward-compatible way. + +%prep +%setup -q -n IO-Socket-IP-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 + +%build +perl Build.PL installdirs=vendor +./Build + +%install +./Build install destdir=%{buildroot} create_packlist=0 +%{_fixperms} %{buildroot}/* + +%check +# Don't do the live test +rm -f t/21nonblocking-connect-internet.t +./Build test + +%files +%doc Changes examples LICENSE README +%{perl_vendorlib}/* +%{_mandir}/man3/* + +%changelog +* Mon Sep 18 2017 Petr Pisar - 0.21-5 +- Fix constructing sockets without specifying host or family (bug #1492760) + +* Fri Dec 27 2013 Daniel Mach - 0.21-4 +- Mass rebuild 2013-12-27 + +* Thu Jul 18 2013 Petr Šabata - 0.21-3 +- Disable the SO_REUSEPORT test; koji builders don't support this feature yet + +* Thu Jul 18 2013 Petr Pisar - 0.21-2 +- Perl 5.18 rebuild + +* Mon Apr 29 2013 Petr Šabata - 0.21-1 +- 0.21 bump + +* Wed Apr 17 2013 Petr Šabata - 0.20-1 +- 0.20 bump + +* Tue Mar 12 2013 Petr Šabata - 0.19-1 +- 0.19 bump + +* Thu Feb 14 2013 Fedora Release Engineering - 0.18-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Nov 30 2012 Petr Šabata - 0.18-1 +- 0.18 bump + +* Thu Nov 15 2012 Petr Šabata - 0.17-2 +- Fix a typo, sort the deps + +* Wed Aug 22 2012 Petr Šabata - 0.17-1 +- 0.17 bump + +* Fri Jul 20 2012 Fedora Release Engineering - 0.16-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Jun 28 2012 Petr Pisar - 0.16-2 +- Perl 5.16 rebuild + +* Mon Jun 25 2012 Petr Šabata - 0.16-1 +- 0.16 (IO::Socket::INET compatibility enhancement) + +* Thu Jun 21 2012 Petr Šabata - 0.15-1 +- 0.15 bump + +* Tue Jun 19 2012 Petr Šabata - 0.14-1 +- 0.14 bump + +* Mon Jun 11 2012 Petr Pisar - 0.11-2 +- Perl 5.16 rebuild + +* Wed Jun 06 2012 Petr Šabata - 0.11-1 +- 0.11 bump + +* Fri May 11 2012 Petr Šabata - 0.10-1 +- 0.10 bump + +* Wed Mar 14 2012 Petr Šabata - 0.09-1 +- 0.09 bump + +* Fri Jan 27 2012 Petr Šabata 0.08-1 +- Specfile autogenerated by cpanspec 1.78.