From: Tim Beale Date: Thu, 8 Nov 2018 22:49:12 +0000 (+1300) Subject: selftest: Fix backup testenv creation on certain host machines X-Git-Tag: tdb-1.3.17~833 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55fa7bc01df1e167af8795bba37f12be6c2e5056;p=thirdparty%2Fsamba.git selftest: Fix backup testenv creation on certain host machines When we created the backup-file for the restoredc/renamedc/labdc testenvs we weren't explicitly a --configfile on the samba-tool command. This meant the command tried to use the smb.conf form the default install location, i.e. /usr/local/samba/etc/smb.conf. On the gitlab CI runner, there's no samba installed, so it ends up using the default settings, which is fine. However, if the host machine had an invalid smb.conf installed there, creating the testenv would fail with an error like: ERROR(runtime): uncaught exception - Unable to load default file File "bin/python/samba/netcmd/__init__.py", line 184, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/domain_backup.py", line 222, in run lp = sambaopts.get_loadparm() File "bin/python/samba/getopt.py", line 94, in get_loadparm self._lp.load_default() We can avoid this by always explictly specifying the backupfromdc's smb.conf when creating the backup file. Likewise, labdc/customdc also need the config specified when the admin password is reset. Signed-off-by: Tim Beale Reviewed-by: Andreas Schneider Reviewed-by: Alexander Bokovoy --- diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 56756003690..5de0a706f35 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -2670,6 +2670,7 @@ sub get_backup_server_args my $server = $dcvars->{DC_SERVER_IP}; my $server_args = "--server=$server "; $server_args .= "-U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}"; + $server_args .= " $dcvars->{CONFIGURATION}"; return $server_args; } @@ -2980,10 +2981,11 @@ sub setup_labdc my $samba_tool = Samba::bindir_path($self, "samba-tool"); my $cmd = "$samba_tool user setpassword $env->{USERNAME} "; $cmd .= "--newpassword=$env->{PASSWORD} -H $restore_dir/private/sam.ldb"; + $cmd .= " $env->{CONFIGURATION}"; unless(system($cmd) == 0) { warn("Failed to reset admin's password: \n$cmd"); - return -1; + return undef; } # start samba for the restored DC @@ -3073,6 +3075,7 @@ sub setup_customdc my $samba_tool = Samba::bindir_path($self, "samba-tool"); my $cmd = "$samba_tool user setpassword $env->{USERNAME} "; $cmd .= "--newpassword=$password -H $restore_dir/private/sam.ldb"; + $cmd .= " $env->{CONFIGURATION}"; unless(system($cmd) == 0) { warn("Failed to reset admin's password: \n$cmd");