From e75d99818dd3940be997520e64db8c9e3b207e39 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 21 May 2024 07:05:26 +0200 Subject: Merging upstream version 15.7. Signed-off-by: Daniel Baumann --- src/test/ldap/t/001_auth.pl | 88 ++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 25 deletions(-) (limited to 'src/test/ldap/t/001_auth.pl') diff --git a/src/test/ldap/t/001_auth.pl b/src/test/ldap/t/001_auth.pl index 2a7435e..3dd56e9 100644 --- a/src/test/ldap/t/001_auth.pl +++ b/src/test/ldap/t/001_auth.pl @@ -16,44 +16,77 @@ if ($ENV{with_ldap} ne 'yes') { plan skip_all => 'LDAP not supported by this build'; } -elsif ($^O eq 'darwin' && -d '/opt/homebrew/opt/openldap') +# Find the OpenLDAP server binary and directory containing schema +# definition files. +elsif ($^O eq 'darwin') { - # typical paths for Homebrew on ARM - $slapd = '/opt/homebrew/opt/openldap/libexec/slapd'; - $ldap_schema_dir = '/opt/homebrew/etc/openldap/schema'; -} -elsif ($^O eq 'darwin' && -d '/usr/local/opt/openldap') -{ - # typical paths for Homebrew on Intel - $slapd = '/usr/local/opt/openldap/libexec/slapd'; - $ldap_schema_dir = '/usr/local/etc/openldap/schema'; -} -elsif ($^O eq 'darwin' && -d '/opt/local/etc/openldap') -{ - # typical paths for MacPorts - $slapd = '/opt/local/libexec/slapd'; - $ldap_schema_dir = '/opt/local/etc/openldap/schema'; + if (-d '/opt/homebrew/opt/openldap') + { + # typical paths for Homebrew on ARM + $slapd = '/opt/homebrew/opt/openldap/libexec/slapd'; + $ldap_schema_dir = '/opt/homebrew/etc/openldap/schema'; + } + elsif (-d '/usr/local/opt/openldap') + { + # typical paths for Homebrew on Intel + $slapd = '/usr/local/opt/openldap/libexec/slapd'; + $ldap_schema_dir = '/usr/local/etc/openldap/schema'; + } + elsif (-d '/opt/local/etc/openldap') + { + # typical paths for MacPorts + $slapd = '/opt/local/libexec/slapd'; + $ldap_schema_dir = '/opt/local/etc/openldap/schema'; + } + else + { + plan skip_all => "OpenLDAP server installation not found"; + } } elsif ($^O eq 'linux') { - $slapd = '/usr/sbin/slapd'; - $ldap_schema_dir = '/etc/ldap/schema' if -d '/etc/ldap/schema'; - $ldap_schema_dir = '/etc/openldap/schema' if -d '/etc/openldap/schema'; + if (-d '/etc/ldap/schema') + { + $slapd = '/usr/sbin/slapd'; + $ldap_schema_dir = '/etc/ldap/schema'; + } + elsif (-d '/etc/openldap/schema') + { + $slapd = '/usr/sbin/slapd'; + $ldap_schema_dir = '/etc/openldap/schema'; + } + else + { + plan skip_all => "OpenLDAP server installation not found"; + } } elsif ($^O eq 'freebsd') { - $slapd = '/usr/local/libexec/slapd'; - $ldap_schema_dir = '/usr/local/etc/openldap/schema'; + if (-d '/usr/local/etc/openldap/schema') + { + $slapd = '/usr/local/libexec/slapd'; + $ldap_schema_dir = '/usr/local/etc/openldap/schema'; + } + else + { + plan skip_all => "OpenLDAP server installation not found"; + } } elsif ($^O eq 'openbsd') { - $slapd = '/usr/local/libexec/slapd'; - $ldap_schema_dir = '/usr/local/share/examples/openldap/schema'; + if (-d '/usr/local/share/examples/openldap/schema') + { + $slapd = '/usr/local/libexec/slapd'; + $ldap_schema_dir = '/usr/local/share/examples/openldap/schema'; + } + else + { + plan skip_all => "OpenLDAP server installation not found"; + } } else { - plan skip_all => - "ldap tests not supported on $^O or dependencies not installed"; + plan skip_all => "ldap tests not supported on $^O"; } # make your own edits here @@ -130,7 +163,12 @@ system_or_bail $slapd, '-f', $slapd_conf,'-s0', '-h', "$ldap_url $ldaps_url"; END { + # take care not to change the script's exit value + my $exit_code = $?; + kill 'INT', `cat $slapd_pidfile` if -f $slapd_pidfile; + + $? = $exit_code; } append_to_file($ldap_pwfile, $ldap_rootpw); -- cgit v1.2.3