2017-03-01 23:18:00 +01:00
|
|
|
# Try to launch an LDAP server
|
|
|
|
|
2019-11-20 16:52:04 +01:00
|
|
|
my $slapd_bin;
|
|
|
|
my $slapadd_bin;
|
|
|
|
my $slapd_schema_dir;
|
|
|
|
|
2017-03-03 18:25:03 +01:00
|
|
|
if ( $ENV{LLNGTESTLDAP} ) {
|
2019-11-20 16:52:04 +01:00
|
|
|
$slapd_bin = $ENV{LLNGTESTLDAP_SLAPD_BIN} || '/usr/sbin/slapd';
|
|
|
|
$slapadd_bin = $ENV{LLNGTESTLDAP_SLAPADD_BIN} || '/usr/sbin/slapadd';
|
|
|
|
$slapd_schema_dir = (
|
|
|
|
( $ENV{LLNGTESTLDAP_SCHEMA_DIR} and -d $ENV{LLNGTESTLDAP_SCHEMA_DIR} )
|
|
|
|
? $ENV{LLNGTESTLDAP_SCHEMA_DIR}
|
|
|
|
: -d '/etc/openldap/schema' ? '/etc/openldap/schema'
|
2019-07-02 20:03:40 +02:00
|
|
|
: '/etc/ldap/schema'
|
|
|
|
);
|
2019-11-20 16:52:04 +01:00
|
|
|
|
2017-03-02 17:50:13 +01:00
|
|
|
eval { mkdir 't/testslapd/slapd.d' };
|
2017-03-01 23:18:00 +01:00
|
|
|
eval { mkdir 't/testslapd/data' };
|
2017-03-02 17:50:13 +01:00
|
|
|
system('cp t/testslapd/slapd.ldif t/testslapd/slapd-test.ldif');
|
2017-03-03 18:25:03 +01:00
|
|
|
system(
|
|
|
|
"/bin/sed -i 's:__SCHEMA_DIR__:$slapd_schema_dir:' t/testslapd/slapd-test.ldif"
|
|
|
|
);
|
|
|
|
system( $slapadd_bin
|
|
|
|
. ' -F t/testslapd/slapd.d -n 0 -l t/testslapd/slapd-test.ldif' );
|
|
|
|
system( $slapadd_bin
|
|
|
|
. ' -F t/testslapd/slapd.d -n 1 -l t/testslapd/users.ldif' );
|
|
|
|
system( $slapd_bin
|
|
|
|
. ' -s 256 -h "ldap://127.0.0.1:19389/" -F t/testslapd/slapd.d' );
|
2017-03-01 23:18:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub stopLdapServer {
|
2017-03-03 18:25:03 +01:00
|
|
|
if ( $ENV{LLNGTESTLDAP} ) {
|
2017-03-01 23:18:00 +01:00
|
|
|
open F, 't/testslapd/slapd.pid';
|
|
|
|
my $pid = join '', <F>;
|
2019-11-20 16:52:04 +01:00
|
|
|
close F;
|
2017-03-01 23:18:00 +01:00
|
|
|
system "kill $pid";
|
2017-03-02 17:50:13 +01:00
|
|
|
system 'rm -rf t/testslapd/slapd.d';
|
2017-03-01 23:18:00 +01:00
|
|
|
system 'rm -rf t/testslapd/data';
|
2017-03-02 17:50:13 +01:00
|
|
|
system 'rm -rf t/testslapd/slapd-test.ldif';
|
2017-03-01 23:18:00 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-20 16:52:04 +01:00
|
|
|
|
|
|
|
sub tempStopLdapServer {
|
|
|
|
if ( $ENV{LLNGTESTLDAP} ) {
|
|
|
|
open F, 't/testslapd/slapd.pid';
|
|
|
|
my $pid = join '', <F>;
|
|
|
|
close F;
|
|
|
|
system "kill $pid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub tempStartLdapServer {
|
|
|
|
if ( $ENV{LLNGTESTLDAP} ) {
|
|
|
|
system( $slapd_bin
|
|
|
|
. ' -s 256 -h "ldap://127.0.0.1:19389/" -F t/testslapd/slapd.d' );
|
|
|
|
}
|
|
|
|
}
|
2017-03-01 23:18:00 +01:00
|
|
|
1;
|