From 3966342a1817b84d78e0c6687b4e7dc6d71f3c41 Mon Sep 17 00:00:00 2001 From: Jamie McClymont Date: Mon, 29 Jan 2018 18:59:34 +1300 Subject: [PATCH] selftest: Clear environment before provision Currently, if an environment is being provisioned after a test which used ad_member_rfc2307, the provisioning process has all of the following in its environment: { 'DC_NETBIOSNAME' => 'LOCALDC', 'DC_PASSWORD' => 'locDCpass1', 'DC_SERVER_IP' => '127.0.0.21', 'DC_SERVER_IPV6' => 'fd00:0000:0000:0000:0000:0000:5357:5f15', 'DC_SERVER' => 'localdc', 'DC_USERNAME' => 'Administrator', 'DOMAIN' => 'SAMBADOMAIN', 'LOCAL_PATH' => '/.../st/ad_member_rfc2307/share', 'LOCK_DIR' => '/.../st/ad_member_rfc2307/lockdir', 'NETBIOSNAME' => 'RFC2307MEMBER', 'NMBD_SOCKET_DIR' => '/.../st/ad_member_rfc2307/nmbd', 'NSS_WRAPPER_GROUP' => '/.../st/ad_member_rfc2307/private/group', 'NSS_WRAPPER_HOSTNAME' => 'rfc2307member.samba.example.com', 'NSS_WRAPPER_HOSTS' => '/.../st/hosts', 'NSS_WRAPPER_MODULE_FN_PREFIX' => 'winbind', 'NSS_WRAPPER_MODULE_SO_PATH' => '/.../bin/default/nsswitch/libnss-wrapper-winbind.so', 'NSS_WRAPPER_PASSWD' => '/.../st/ad_member_rfc2307/private/passwd', 'PASSWORD' => 'loCalMemberPass', 'REALM' => 'SAMBA.EXAMPLE.COM', 'RESOLV_WRAPPER_HOSTS' => '/.../st/dns_host_file', 'SELFTEST_WINBINDD_SOCKET_DIR' => '/.../st/ad_member_rfc2307/winbindd', 'SERVER_IP' => '127.0.0.34', 'SERVER_IPV6' => 'fd00:0000:0000:0000:0000:0000:5357:5f22', 'SERVER' => 'RFC2307MEMBER', 'USERID' => '55668', 'USERNAME' => 'jamiemcclymont', } Unsurprisingly, some of these can cause issues for the provisioning process, if a reduced subset of tests is being run which causes the provision to encounter never-before-seen pairs of adjacent environments. For example, a run with only TESTS='--include-env=vampire_dc --include-env=ad_member_rfc2307' would fail to start up the vampire_dc with: Could not find machine account in secrets database: Failed to fetch machine account password from secrets.ldb: Could not find entry to match filter: '(&(flatname=SAMBADOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4641 Signed-off-by: Jamie McClymont Reviewed-by: Andrew Bartlett Reviewed-by: Andreas Schneider --- selftest/selftest.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 42c1e62736f..a772613b8e1 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -942,6 +942,19 @@ sub setup_env($$) $option = "client" if $option eq ""; + # Initially clear out the environment for the provision, so previous envs' + # variables don't leak in. Provisioning steps must explicitly set their + # necessary variables when calling out to other executables + foreach (@exported_envvars) { + unless ($_ == "NSS_WRAPPER_HOSTS" || + $_ == "RESOLV_WRAPPER_HOSTS") + { + delete $ENV{$_}; + } + } + delete $ENV{SOCKET_WRAPPER_DEFAULT_IFACE}; + delete $ENV{SMB_CONF_PATH}; + $ENV{KRB5CCNAME} = "FILE:${selftest_krbt_ccache_path}.${envname}/ignore"; if (defined(get_running_env($envname))) { -- 2.11.4.GIT