selftest: Fix backup testenv creation on certain host machines
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 8 Nov 2018 22:49:12 +0000 (11:49 +1300)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 9 Nov 2018 16:52:30 +0000 (17:52 +0100)
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 <timbeale@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
selftest/target/Samba4.pm

index 567560036909cbc6a0a44da8f0ba7f7a71ca6484..5de0a706f35d2219937456cf2732b850b3d9c354 100755 (executable)
@@ -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");