selftest: Make testenv NTVFS usage match --use-ntvfs
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 26 Nov 2018 01:28:59 +0000 (14:28 +1300)
committerTim Beale <timbeale@samba.org>
Tue, 27 Nov 2018 02:43:17 +0000 (03:43 +0100)
Regardless of whether the testenv uses --use-ntvfs as part of its
provision options, the s4 testenvs all default to using the NTVFS file
server.

It's not particularly obvious that this is happening. The new restore
DCS (restoredc, renamedc, labdc) were all using NTVFS unintentionally.

The problem is the s4 testenvs default to using services '-s3fs +smb".
provision_ad_dc() explicitly overrides this to use s3fs again
(technically it ends up with both in its smb.conf and just uses whatever
comes last).

This patch changes the testenv setup to check for the presence of the
'--use-ntvfs' option and to set the 'server services' config option
appropriately. This way, the provision command and the smb.conf options
should always line up, with respect to NTVFS.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/target/Samba4.pm

index b453d1c022fd19f501cc09989396aa7d80df5dcf..7fa323451cd02deea9b0416d8675518c86dd1342 100755 (executable)
@@ -592,6 +592,16 @@ sub provision_raw_prepare($$$$$$$$$$$$)
        return $ctx;
 }
 
+sub has_option
+{
+       my ($self, $keyword, @options_list) = @_;
+
+       # convert the options-list to a hash-map for easy keyword lookup
+       my %options_dict = map { $_ => 1 } @options_list;
+
+       return exists $options_dict{$keyword};
+}
+
 #
 # Step1 creates the basic configuration
 #
@@ -616,6 +626,13 @@ sub provision_raw_step1($$)
        my $crlfile = "$ctx->{tlsdir}/crl.pem";
        $crlfile = "" unless -e ${crlfile};
 
+       # work out which file server to use. Default to source3 smbd (s3fs),
+       # unless the source4 NTVFS (smb) file server has been specified
+       my $services = "-smb +s3fs";
+       if ($self->has_option("--use-ntvfs", @{$ctx->{provision_options}})) {
+               $services = "+smb -s3fs";
+       }
+
        print CONFFILE "
 [global]
        netbios name = $ctx->{netbiosname}
@@ -639,7 +656,7 @@ sub provision_raw_step1($$)
        panic action = $RealBin/gdb_backtrace \%d
        wins support = yes
        server role = $ctx->{server_role}
-       server services = +echo +smb -s3fs
+       server services = +echo $services
         dcerpc endpoint servers = +winreg +srvsvc
        notify:inotify = false
        ldb:nosync = true
@@ -1901,7 +1918,6 @@ sub provision_ad_dc($$$$$$)
        $password_hash_gpg_key_ids = "" unless defined($config_h->{HAVE_GPGME});
 
        my $extra_smbconf_options = "
-        server services = -smb +s3fs
         xattr_tdb:file = $prefix_abs/statedir/xattr.tdb
 
        dbwrap_tdb_mutexes:* = yes