s4:torture/smb2/read: add test for cancelling SMB aio
[nivanova/samba-autobuild/.git] / selftest / target / Samba3.pm
index e6c95fa991a5b01b849a240dcae37b4748b56e40..f8fda35366b719dc87ed2ada8ce965a72f6ed10b 100755 (executable)
@@ -225,6 +225,7 @@ sub setup_nt4_dc
               return undef;
        }
 
+       $vars->{DOMSID} = $vars->{SAMSID};
        $vars->{DC_SERVER} = $vars->{SERVER};
        $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
        $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
@@ -273,6 +274,7 @@ sub setup_nt4_dc_schannel
               return undef;
        }
 
+       $vars->{DOMSID} = $vars->{SAMSID};
        $vars->{DC_SERVER} = $vars->{SERVER};
        $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
        $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
@@ -322,7 +324,8 @@ sub setup_nt4_member
        }
 
        my $net = Samba::bindir_path($self, "net");
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
        $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
@@ -333,7 +336,8 @@ sub setup_nt4_member
            return undef;
        }
 
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
        $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
@@ -347,6 +351,7 @@ sub setup_nt4_member
               return undef;
        }
 
+       $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
        $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
        $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
@@ -429,6 +434,7 @@ sub setup_ad_member
        close(USERMAP);
        $ret->{DOMAIN} = $dcvars->{DOMAIN};
        $ret->{REALM} = $dcvars->{REALM};
+       $ret->{DOMSID} = $dcvars->{DOMSID};
 
        my $ctx;
        $ctx = {};
@@ -444,7 +450,8 @@ sub setup_ad_member
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
        my $net = Samba::bindir_path($self, "net");
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        if (defined($ret->{RESOLV_WRAPPER_CONF})) {
                $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
@@ -521,6 +528,7 @@ sub setup_ad_member_rfc2307
        close(USERMAP);
        $ret->{DOMAIN} = $dcvars->{DOMAIN};
        $ret->{REALM} = $dcvars->{REALM};
+       $ret->{DOMSID} = $dcvars->{DOMSID};
 
        my $ctx;
        my $prefix_abs = abs_path($prefix);
@@ -537,7 +545,8 @@ sub setup_ad_member_rfc2307
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
        my $net = Samba::bindir_path($self, "net");
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        if (defined($ret->{RESOLV_WRAPPER_CONF})) {
                $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
@@ -606,6 +615,7 @@ sub setup_ad_member_idmap_rid
        close(USERMAP);
        $ret->{DOMAIN} = $dcvars->{DOMAIN};
        $ret->{REALM} = $dcvars->{REALM};
+       $ret->{DOMSID} = $dcvars->{DOMSID};
 
        my $ctx;
        my $prefix_abs = abs_path($prefix);
@@ -622,7 +632,8 @@ sub setup_ad_member_idmap_rid
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
        my $net = Samba::bindir_path($self, "net");
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        if (defined($ret->{RESOLV_WRAPPER_CONF})) {
                $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
@@ -692,6 +703,7 @@ sub setup_ad_member_idmap_ad
        close(USERMAP);
        $ret->{DOMAIN} = $dcvars->{DOMAIN};
        $ret->{REALM} = $dcvars->{REALM};
+       $ret->{DOMSID} = $dcvars->{DOMSID};
 
        my $ctx;
        my $prefix_abs = abs_path($prefix);
@@ -708,7 +720,8 @@ sub setup_ad_member_idmap_ad
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
        my $net = Samba::bindir_path($self, "net");
-       my $cmd = "";
+       # Add hosts file for name lookups
+       my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
        $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
        if (defined($ret->{RESOLV_WRAPPER_CONF})) {
                $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
@@ -755,13 +768,58 @@ sub setup_simpleserver
        my $simpleserver_options = "
        lanman auth = yes
        ntlm auth = yes
-       vfs objects = xattr_tdb streams_depot time_audit full_audit
+       vfs objects = xattr_tdb streams_depot
        change notify = no
        smb encrypt = off
 
-       full_audit:syslog = no
-       full_audit:success = none
-       full_audit:failure = none
+[vfs_aio_pthread]
+       path = $prefix_abs/share
+       read only = no
+       vfs objects = aio_pthread
+       aio_pthread:aio open = yes
+       smbd:async dosmode = no
+
+[vfs_aio_pthread_async_dosmode_default1]
+       path = $prefix_abs/share
+       read only = no
+       vfs objects = aio_pthread
+       store dos attributes = yes
+       aio_pthread:aio open = yes
+       smbd:async dosmode = yes
+
+[vfs_aio_pthread_async_dosmode_default2]
+       path = $prefix_abs/share
+       read only = no
+       vfs objects = aio_pthread xattr_tdb
+       store dos attributes = yes
+       aio_pthread:aio open = yes
+       smbd:async dosmode = yes
+
+[vfs_aio_pthread_async_dosmode_force_sync1]
+       path = $prefix_abs/share
+       read only = no
+       vfs objects = aio_pthread
+       store dos attributes = yes
+       aio_pthread:aio open = yes
+       smbd:async dosmode = yes
+       # This simulates non linux systems
+       smbd:force sync user path safe threadpool = yes
+       smbd:force sync user chdir safe threadpool = yes
+       smbd:force sync root path safe threadpool = yes
+       smbd:force sync root chdir safe threadpool = yes
+
+[vfs_aio_pthread_async_dosmode_force_sync2]
+       path = $prefix_abs/share
+       read only = no
+       vfs objects = aio_pthread xattr_tdb
+       store dos attributes = yes
+       aio_pthread:aio open = yes
+       smbd:async dosmode = yes
+       # This simulates non linux systems
+       smbd:force sync user path safe threadpool = yes
+       smbd:force sync user chdir safe threadpool = yes
+       smbd:force sync root path safe threadpool = yes
+       smbd:force sync root chdir safe threadpool = yes
 
 [vfs_aio_fork]
        path = $prefix_abs/share
@@ -829,6 +887,9 @@ sub setup_fileserver
        push(@dirs, "$dfree_share_dir/subdir2");
        push(@dirs, "$dfree_share_dir/subdir3");
 
+       my $quotadir_dir="$share_dir/quota";
+       push(@dirs, $quotadir_dir);
+
        my $valid_users_sharedir="$share_dir/valid_users";
        push(@dirs,$valid_users_sharedir);
 
@@ -855,6 +916,8 @@ sub setup_fileserver
        usershare allow guests = yes
        usershare prefix allow list = $usershare_sharedir
 
+       get quota command = $prefix_abs/getset_quota.py
+       set quota command = $prefix_abs/getset_quota.py
 [lowercase]
        path = $lower_case_share_dir
        comment = smb username is [%U]
@@ -1029,6 +1092,8 @@ $ret->{USERNAME} = KTEST\\Administrator
 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
 #Samba4 DC with the same parameters as are being used here.  The
 #domain SID is S-1-5-21-1071277805-689288055-3486227160
+       $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
+       $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
 
        system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
        chmod 0600, "$prefix/private/secrets.tdb";
@@ -1364,6 +1429,7 @@ sub provision($$$$$$$$$)
        ## setup the various environment variables we need
        ##
 
+       my $samsid = Samba::random_domain_sid();
        my $swiface = Samba::get_interface($server);
        my %ret = ();
        my %createuser_env = ();
@@ -1702,7 +1768,11 @@ sub provision($$$$$$$$$)
        dos filemode = yes
        strict rename = yes
        strict sync = yes
-       vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
+       vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
+
+       full_audit:syslog = no
+       full_audit:success = none
+       full_audit:failure = none
 
        printing = vlp
        print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
@@ -1889,6 +1959,16 @@ sub provision($$$$$$$$$)
 
 [vfs_fruit]
        path = $shrdir
+       vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
+       fruit:resource = file
+       fruit:metadata = netatalk
+       fruit:locking = netatalk
+       fruit:encoding = native
+       fruit:veto_appledouble = no
+
+[vfs_fruit_xattr]
+       path = $shrdir
+        # This is used by vfs.fruit tests that require real fs xattr
        vfs objects = catia fruit streams_xattr acl_xattr
        fruit:resource = file
        fruit:metadata = netatalk
@@ -1898,34 +1978,52 @@ sub provision($$$$$$$$$)
 
 [vfs_fruit_metadata_stream]
        path = $shrdir
-       vfs objects = fruit streams_xattr acl_xattr
+       vfs objects = fruit streams_xattr acl_xattr xattr_tdb
        fruit:resource = file
        fruit:metadata = stream
        fruit:veto_appledouble = no
 
 [vfs_fruit_stream_depot]
        path = $shrdir
-       vfs objects = fruit streams_depot acl_xattr
+       vfs objects = fruit streams_depot acl_xattr xattr_tdb
        fruit:resource = stream
        fruit:metadata = stream
        fruit:veto_appledouble = no
 
 [vfs_wo_fruit]
        path = $shrdir
-       vfs objects = streams_xattr acl_xattr
+       vfs objects = streams_xattr acl_xattr xattr_tdb
 
 [vfs_wo_fruit_stream_depot]
        path = $shrdir
-       vfs objects = streams_depot acl_xattr
+       vfs objects = streams_depot acl_xattr xattr_tdb
 
 [vfs_fruit_timemachine]
        path = $shrdir
-       vfs objects = fruit streams_xattr acl_xattr
+       vfs objects = fruit streams_xattr acl_xattr xattr_tdb
        fruit:resource = file
        fruit:metadata = stream
        fruit:time machine = yes
        fruit:time machine max size = 32K
 
+[vfs_fruit_wipe_intentionally_left_blank_rfork]
+       path = $shrdir
+       vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+       fruit:resource = file
+       fruit:metadata = stream
+       fruit:wipe_intentionally_left_blank_rfork = true
+       fruit:delete_empty_adfiles = false
+       fruit:veto_appledouble = no
+
+[vfs_fruit_delete_empty_adfiles]
+       path = $shrdir
+       vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+       fruit:resource = file
+       fruit:metadata = stream
+       fruit:wipe_intentionally_left_blank_rfork = true
+       fruit:delete_empty_adfiles = true
+       fruit:veto_appledouble = no
+
 [badname-tmp]
        path = $badnames_shrdir
        guest ok = yes
@@ -2090,11 +2188,21 @@ sub provision($$$$$$$$$)
        vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
        admin users = $unix_name
        include = $dfqconffile
+[dfq_cache]
+       path = $shrdir/dfree
+       vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
+       admin users = $unix_name
+       include = $dfqconffile
+       dfree cache time = 60
 [dfq_owner]
        path = $shrdir/dfree
        vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
        inherit owner = yes
        include = $dfqconffile
+[quotadir]
+       path = $shrdir/quota
+       admin users = $unix_name
+
 [acl_xattr_ign_sysacl_posix]
        copy = tmp
        acl_xattr:ignore system acls = yes
@@ -2123,6 +2231,10 @@ sub provision($$$$$$$$$)
        kernel oplocks = yes
        vfs objects = streams_xattr xattr_tdb
 
+[streams_xattr]
+       copy = tmp
+       vfs objects = streams_xattr xattr_tdb
+
 [compound_find]
        copy = tmp
        smbd:find async delay usec = 10000
@@ -2130,9 +2242,33 @@ sub provision($$$$$$$$$)
        copy = tmp
        vfs objects = error_inject
        include = $libdir/error_inject.conf
+
+[delay_inject]
+       copy = tmp
+       vfs objects = delay_inject
+       kernel share modes = no
+       kernel oplocks = no
+       posix locking = no
+       include = $libdir/delay_inject.conf
+
+[aio_delay_inject]
+       copy = tmp
+       vfs objects = delay_inject
+       delay_inject:pread_send = 2000
+       delay_inject:pwrite_send = 2000
        ";
        close(CONF);
 
+       my $net = Samba::bindir_path($self, "net");
+       my $cmd = "";
+       $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
+       $cmd .= "$net setlocalsid $samsid";
+
+       if (system($cmd) != 0) {
+           warn("Join failed\n$cmd");
+           return undef;
+       }
+
        unless (open(DFQCONF, ">$dfqconffile")) {
                warn("Unable to open $dfqconffile");
                return undef;
@@ -2223,9 +2359,9 @@ force_user:x:$gid_force_user:
        $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
        $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
        if ($ENV{SAMBA_DNS_FAKING}) {
-               $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
-       } else {
                $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
+       } else {
+               $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
        }
 
        createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
@@ -2256,6 +2392,7 @@ force_user:x:$gid_force_user:
        $ret{USERNAME} = $unix_name;
        $ret{USERID} = $unix_uid;
        $ret{DOMAIN} = $domain;
+       $ret{SAMSID} = $samsid;
        $ret{NETBIOSNAME} = $server;
        $ret{PASSWORD} = $password;
        $ret{PIDDIR} = $piddir;
@@ -2371,6 +2508,9 @@ sub wait_for_start($$$$$)
        $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
        $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
 
+       $cmd = $netcmd . "groupmap delete ntgroup=domusers";
+       $ret = system($cmd);
+
        $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
        $ret = system($cmd);
        if ($ret != 0) {
@@ -2378,6 +2518,9 @@ sub wait_for_start($$$$$)
                return 1;
        }
 
+       $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
+       $ret = system($cmd);
+
        $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
        $ret = system($cmd);
        if ($ret != 0) {
@@ -2385,6 +2528,9 @@ sub wait_for_start($$$$$)
                return 1;
        }
 
+       $cmd = $netcmd . "groupmap delete ntgroup=everyone";
+       $ret = system($cmd);
+
        $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
        $ret = system($cmd);
        if ($ret != 0) {