diff --git a/perl-LDAP.spec b/perl-LDAP.spec new file mode 100644 index 0000000..3586ff9 --- /dev/null +++ b/perl-LDAP.spec @@ -0,0 +1,189 @@ +%bcond_with perl_LDAP_enables_optional_test +# Support XML serialization of LDAP schemata (DSML languge) +%bcond_with perl_LDAP_enables_xml + +Name: perl-LDAP +Version: 0.68 +Release: 1 +Summary: LDAP Perl module +License: GPL+ or Artistic +URL: https://metacpan.org/release/perl-ldap +Source0: https://cpan.metacpan.org/authors/id/M/MA/MARSCHAP/perl-ldap-%{version}.tar.gz +# Optional tests need to know a location of an LDAP server executable +Patch0: perl-ldap-0.65-Configure-usr-sbin-slapd-for-tests.patch +# Remove an unreliable cancelling test +Patch1: perl-ldap-0.66-test-Remove-a-test-for-cancelling-asynchronous-calls.patch +# Fix resolving localhost on loopback-only machines +Patch2: perl-ldap-0.68-Do-not-default-IO-Socket-IP-to-AI_ADDRCONFIG-flag.patch +BuildArch: noarch +BuildRequires: coreutils +BuildRequires: make +BuildRequires: perl-generators +BuildRequires: perl-interpreter +BuildRequires: perl(Config) +BuildRequires: perl(inc::Module::Install) +BuildRequires: perl(Module::Install::AutoInstall) +BuildRequires: perl(Module::Install::Metadata) +BuildRequires: perl(Module::Install::WriteAll) +# Run-time: +BuildRequires: perl(base) +BuildRequires: perl(Carp) +BuildRequires: perl(constant) +BuildRequires: perl(Convert::ASN1) >= 0.2 +BuildRequires: perl(Encode) +BuildRequires: perl(Exporter) +BuildRequires: perl(IO::Select) +BuildRequires: perl(IO::Socket) +%if %{with perl_LDAP_enables_optional_test} +BuildRequires: perl(IO::Socket::SSL) >= 1.26 +%endif +BuildRequires: perl(Socket) +BuildRequires: perl(strict) +BuildRequires: perl(Text::Soundex) +BuildRequires: perl(Time::Local) +%if %{with perl_LDAP_enables_xml} +BuildRequires: perl(XML::SAX::Base) +BuildRequires: perl(XML::SAX::Writer) +%endif +# Tests: +BuildRequires: perl(File::Basename) +BuildRequires: perl(File::Compare) +BuildRequires: perl(File::Path) +BuildRequires: perl(File::Spec) +BuildRequires: perl(IO::File) +BuildRequires: perl(Test::More) +%if %{with perl_LDAP_enables_optional_test} +# Optional tests: +BuildRequires: openldap-servers +BuildRequires: perl(LWP::UserAgent) +%endif +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) +Requires: perl(Authen::SASL) >= 2.00 +Requires: perl(Convert::ASN1) >= 0.2 +Requires: perl(IO::Socket::SSL) >= 1.26 +Requires: perl(JSON) +%if %{with perl_LDAP_enables_xml} +Suggests: perl(Net::LDAP::DSML) +%endif +Requires: perl(MIME::Base64) +# Prefer core Text::Soundex +Requires: perl(Text::Soundex) +Requires: perl(Time::Local) + +# Remove under-specified dependencies +%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^perl\\(Net::LDAP::Filter\\)$ +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(Convert::ASN1\\)$ + +%description +Net::LDAP is a collection of modules that implements an LDAP services API +for Perl programs. The module may be used to search directories or perform +maintenance functions such as adding, deleting or modifying entries. + +%if %{with perl_LDAP_enables_xml} +%package -n perl-Net-LDAP-DSML +Summary: DSML Writer for Net::LDAP +Requires: perl-LDAP = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) +Requires: perl(MIME::Base64) +Requires: perl(Net::LDAP::Schema) +Requires: perl(XML::SAX::Writer) + +%description -n perl-Net-LDAP-DSML +Directory Service Markup Language (DSML) is the XML standard for representing +directory service information in XML. At the moment this Perl module only +writes DSML entry and schema entities. Reading DSML entities is a future +project. +%endif + +%package tests +Summary: Tests for %{name} +Requires: coreutils +Requires: perl-LDAP = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +Requires: perl(Convert::ASN1) >= 0.2 +Requires: perl(File::Spec) +Requires: perl(Net::LDAPI) +Requires: perl(Text::Soundex) +%if %{with perl_LDAP_enables_xml} +Requires: perl(XML::SAX::Base) +Requires: perl(XML::SAX::Writer) +%endif +%if %{with perl_LDAP_enables_optional_test} +# Optional tests: +Requires: openldap-servers +Requires: perl(IO::Socket::SSL) >= 1.26 +Requires: perl(Net::LDAPS) +Requires: perl(LWP::UserAgent) +%endif + +%description tests +Tests from %{name}-%{version}. Execute them with "%{_libexecdir}/%{name}/test". + + +%prep +%setup -q -n perl-ldap-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +chmod -c 644 bin/* contrib/* lib/Net/LDAP/DSML.pm +perl -pi -e 's|^#!/usr/local/bin/perl\b|#!%{__perl}|' contrib/* + +rm -rf inc +perl -i -ne 'print $_ unless m{^inc/}' MANIFEST + +%if !%{with perl_LDAP_enables_xml} +rm t/05dsml.t +perl -i -ne 'print $_ unless m{^t/05dsml\.t}' MANIFEST +%endif +find -type f \! -name 'regenerate_cert.sh' -exec chmod -x {} + +for F in t/*; do + perl -i -MConfig -pe 's/\A#!perl\b/$Config{startperl}/' "$F" + chmod +x "$F" +done + +%build +perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 < /dev/null +%{make_build} + +%install +%{make_install} +mkdir -p %{buildroot}/%{_libexecdir}/%{name} +cp -a data t test.cfg %{buildroot}/%{_libexecdir}/%{name} +cat > %{buildroot}/%{_libexecdir}/%{name}/test <<'EOF' +#!/bin/bash +set -e +DIR=$(mktemp -d) +pushd "$DIR" +cp -a %{_libexecdir}/%{name}/* ./ +prove -I . +popd +rm -rf "$DIR" +EOF +chmod +x %{buildroot}/%{_libexecdir}/%{name}/test +%{_fixperms} %{buildroot}/* + +%check +make test + +%files +%doc Changes CREDITS +%doc contrib/ bin/ +%{perl_vendorlib}/Bundle/ +%{perl_vendorlib}/LWP/ +%{perl_vendorlib}/Net/ +%exclude %{perl_vendorlib}/Net/LDAP/DSML.pm +%{_mandir}/man3/*.3pm* +%exclude %{_mandir}/man3/Net::LDAP::DSML.3pm* + +%if %{with perl_LDAP_enables_xml} +%files -n perl-Net-LDAP-DSML +%{perl_vendorlib}/Net/LDAP/DSML.pm +%{_mandir}/man3/Net::LDAP::DSML.3pm* +%endif + +%files tests +%{_libexecdir}/%{name} + +%changelog +* Thu Jun 30 2022 misaka00251 - 0.68-1 +- Init package (Thanks to fedora team) diff --git a/perl-ldap-0.65-Configure-usr-sbin-slapd-for-tests.patch b/perl-ldap-0.65-Configure-usr-sbin-slapd-for-tests.patch new file mode 100644 index 0000000..b63a43e --- /dev/null +++ b/perl-ldap-0.65-Configure-usr-sbin-slapd-for-tests.patch @@ -0,0 +1,58 @@ +From d35a08a77306210ed95a797d5a6ed1160df84b95 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 4 Apr 2019 17:03:01 +0200 +Subject: [PATCH] Configure /usr/sbin/slapd for tests +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The tests need to know slapd executable file name. + +The tests uses sssvlv overlay without loading its module. That's maybe +for statically built openldap. However, we have a dynamically built +server and we want to rely on a default module path because it varies +among architectures. Thus we just uncomment loading the module. + +Also enable SSL and IPC tests. + +Signed-off-by: Petr Písař +--- + data/slapd.conf.in | 2 +- + test.cfg | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/data/slapd.conf.in b/data/slapd.conf.in +index c6c06a3..3c7b6fb 100644 +--- a/data/slapd.conf.in ++++ b/data/slapd.conf.in +@@ -11,7 +11,7 @@ include $SLAPD_SCHEMA_DIR/openldap.schema + # get required dynmaic modules + #modulepath $SLAPD_MODULE_DIR + #moduleload back_$SLAPD_DB +-#moduleload sssvlv ++moduleload sssvlv + + # PID & args file + pidfile $TESTDB/slapd.pid +diff --git a/test.cfg b/test.cfg +index 0f951f6..ea5a50c 100644 +--- a/test.cfg ++++ b/test.cfg +@@ -4,12 +4,12 @@ + + # Set this to the full path of your LDAP server executable + # (e.g '/usr/sbin/slapd') +-$SERVER_EXE = ''; ++$SERVER_EXE = '/usr/sbin/slapd'; + + # This should be one of + # * openldap[+ssl][+ipc][+sasl] + # options are appended with '+' signs +-$SERVER_TYPE = 'openldap'; ++$SERVER_TYPE = 'openldap+ssl+ipc'; + + # Change this if your host cannot be contacted as localhost + # Some tests may fail if the name does not resolve to an IPv4 and an IPv6 address +-- +2.20.1 + diff --git a/perl-ldap-0.66-test-Remove-a-test-for-cancelling-asynchronous-calls.patch b/perl-ldap-0.66-test-Remove-a-test-for-cancelling-asynchronous-calls.patch new file mode 100644 index 0000000..71b0639 --- /dev/null +++ b/perl-ldap-0.66-test-Remove-a-test-for-cancelling-asynchronous-calls.patch @@ -0,0 +1,65 @@ +From 5a2388c895cfd7db5f6ca1cc4acb062dfde336bf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 25 Apr 2019 14:23:55 +0200 +Subject: [PATCH] test: Remove a test for cancelling asynchronous calls +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +t/60cancel.t performed a racy test when it started an asynchronous query, then +it canceled it and tested that the cancelling succeeded. However, if a server +finished the search before the cancelling order was issued, the cancel itself +failed because it referred an not running and thus then nonexisting query: + + t/60cancel.t .. 1/7 + # Failed test 'cancel a running operation: 119: message ID not found' + # at t/60cancel.t line 63. + # This test may have failed because the server was too fast + +The race was actually admitted in the diag message. + +This patch removes the unreliable test to prevent from false negatives. + +Signed-off-by: Petr Písař +--- + t/60cancel.t | 17 +---------------- + 1 file changed, 1 insertion(+), 16 deletions(-) + +diff --git a/t/60cancel.t b/t/60cancel.t +index c72bfa5..8a3074c 100644 +--- a/t/60cancel.t ++++ b/t/60cancel.t +@@ -11,7 +11,7 @@ BEGIN { require "t/common.pl" } + + + start_server() +-? plan tests => 7 ++? plan tests => 6 + : plan skip_all => 'no server'; + + +@@ -47,21 +47,6 @@ SKIP: { + # cancel the finished search => should fail + $cancel = $ldap->cancel($search); + ok($cancel->code, "cancel a finished operation: " . $cancel->code . ": " . $cancel->error); +- +- # switch to async mode +- $ldap->async(1); +- +- # perform a search (asynchronously) +- $search = $ldap->search( +- base => $BASEDN, +- filter => '(objectclass=*)', +- callback => \&process_entry, # Call this sub for each entry +- ); +- +- # cancel the running search => should work [may fail, as it depends on the server's speed] +- $cancel = $ldap->cancel($search); +- ok(!$cancel->code, "cancel a running operation: " . $cancel->code . ": " . $cancel->error) +- or diag("This test may have failed because the server was too fast"); + } + + +-- +2.20.1 + diff --git a/perl-ldap-0.68-Do-not-default-IO-Socket-IP-to-AI_ADDRCONFIG-flag.patch b/perl-ldap-0.68-Do-not-default-IO-Socket-IP-to-AI_ADDRCONFIG-flag.patch new file mode 100644 index 0000000..78bd8e6 --- /dev/null +++ b/perl-ldap-0.68-Do-not-default-IO-Socket-IP-to-AI_ADDRCONFIG-flag.patch @@ -0,0 +1,51 @@ +From 957a39309fa2f8a85a6b8a0a2c5b1751a151cb8b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Tue, 16 Feb 2021 15:29:58 +0100 +Subject: [PATCH] Do not default IO::Socket::IP to AI_ADDRCONFIG flag +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +t/40connect.t fails if the only available network interface is +loopback and IO::Socket::IP is installed: + + # perl -Ilib -I. t/40connect.t + 1..3 + ok 1 - client with IPv4/IPv6 auto-selection, bound to ::1 + ldap://localhost:9009/ Name or service not known at t/common.pl line 157. + # Looks like your test exited with 22 just after 1. + +The reason is that IO::Socket::IP by default resolves host names with +AI_ADDRCONFIG flag and in the particular case (no interfaces other +than loopback) a system resolver (glibc in my case) hides both IPv4 +and IPv6 addreses of the hostname (e.g. localhost). + +See for more +details. + +I applied a workaround similar to one found in IO-Socket-SSL. +I believe that other Socket implementations perl-ldap can use do not +suffer from this problem. + +Signed-off-by: Petr Písař +--- + lib/Net/LDAP.pm | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/Net/LDAP.pm b/lib/Net/LDAP.pm +index 5dfe3e3..be11d12 100644 +--- a/lib/Net/LDAP.pm ++++ b/lib/Net/LDAP.pm +@@ -167,6 +167,9 @@ sub connect_ldap { + LocalAddr => $arg->{localaddr} || undef, + Proto => 'tcp', + ($class eq 'IO::Socket::IP' ? 'Family' : 'Domain') => $domain, ++ # Work around IO::Socket::IP defaulting to AI_ADDRCONFIG which breaks ++ # resolution if only a loopback interface is available. CPAN RT#104793. ++ ($class eq 'IO::Socket::IP' and $domain ne AF_UNSPEC ? ('GetAddrInfoFlags' => 0) : ()), + MultiHomed => $arg->{multihomed}, + Timeout => defined $arg->{timeout} + ? $arg->{timeout} +-- +2.26.2 + diff --git a/perl-ldap-0.68.tar.gz b/perl-ldap-0.68.tar.gz new file mode 100644 index 0000000..e00da60 Binary files /dev/null and b/perl-ldap-0.68.tar.gz differ