Skip to content

Commit

Permalink
s4:selftest: explicitly set NSS/RESOLV_WAPPER_* in wait_for_start
Browse files Browse the repository at this point in the history
These variables were previously set directly on the selftest process
for the purpose of making this ldbsearch call, allowing them to leak
into other environments.

Signed-off-by: Jamie McClymont <[email protected]>
Reviewed-by: Gary Lockyer <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
  • Loading branch information
Jamie McClymont authored and cryptomilk committed Mar 22, 2018
1 parent 3966342 commit ba805dc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions selftest/target/Samba4.pm
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,6 @@ sub wait_for_start($$)

# Ensure we have the first RID Set before we start tests. This makes the tests more reliable.
if ($testenv_vars->{SERVER_ROLE} eq "domain controller") {
# Add hosts file for name lookups
$ENV{NSS_WRAPPER_HOSTS} = $testenv_vars->{NSS_WRAPPER_HOSTS};
if (defined($testenv_vars->{RESOLV_WRAPPER_CONF})) {
$ENV{RESOLV_WRAPPER_CONF} = $testenv_vars->{RESOLV_WRAPPER_CONF};
} else {
$ENV{RESOLV_WRAPPER_HOSTS} = $testenv_vars->{RESOLV_WRAPPER_HOSTS};
}

print "waiting for working LDAP and a RID Set to be allocated\n";
my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
my $count = 0;
Expand All @@ -234,7 +226,21 @@ sub wait_for_start($$)
$search_dn = "cn=RID Set,cn=$testenv_vars->{NETBIOSNAME},ou=domain controllers,$base_dn";
}
my $max_wait = 60;
my $cmd = "$ldbsearch $testenv_vars->{CONFIGURATION} -H ldap://$testenv_vars->{SERVER} -U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} -s base -b \"$search_dn\"";

# Add hosts file for name lookups
my $cmd = "NSS_WRAPPER_HOSTS='$testenv_vars->{NSS_WRAPPER_HOSTS}' ";
if (defined($testenv_vars->{RESOLV_WRAPPER_CONF})) {
$cmd .= "RESOLV_WRAPPER_CONF='$testenv_vars->{RESOLV_WRAPPER_CONF}' ";
} else {
$cmd .= "RESOLV_WRAPPER_HOSTS='$testenv_vars->{RESOLV_WRAPPER_HOSTS}' ";
}

$cmd .= "$ldbsearch ";
$cmd .= "$testenv_vars->{CONFIGURATION} ";
$cmd .= "-H ldap://$testenv_vars->{SERVER} ";
$cmd .= "-U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} ";
$cmd .= "-s base ";
$cmd .= "-b '$search_dn' ";
while (system("$cmd >/dev/null") != 0) {
$count++;
if ($count > $max_wait) {
Expand Down

0 comments on commit ba805dc

Please sign in to comment.