works
[metze/samba/wip.git] / selftest / target / Samba3.pm
index 6c86701273874fc6c753c0a49e718a9545124a9a..d706b0d18d5e38bded66b4b27ee1bfbabd482c1a 100755 (executable)
@@ -3,6 +3,9 @@
 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
 # Published under the GNU GPL, v3 or later.
 
+# NOTE: Refer to the README for more details about the various testenvs,
+# and tips about adding new testenvs.
+
 package Samba3;
 
 use strict;
@@ -259,8 +262,6 @@ sub setup_nt4_dc_schannel
        rpc_daemon:lsasd = fork
 
        server schannel = yes
-       # used to reproduce bug #12772
-       server max protocol = SMB2_02
 ";
 
        my $vars = $self->provision($path, "NT4SCHANNEL",
@@ -298,6 +299,7 @@ sub setup_nt4_member
 
        my $member_options = "
        security = domain
+       server max protocol = SMB3_02
        dbwrap_tdb_mutexes:* = yes
        ${require_mutexes}
 ";
@@ -324,7 +326,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";
@@ -335,7 +338,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'";
@@ -446,9 +450,11 @@ sub setup_ad_member
        Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
+       $ret->{RESOLV_CONF} = $dcvars->{RESOLV_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}\" ";
@@ -540,9 +546,11 @@ sub setup_ad_member_rfc2307
        Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
+       $ret->{RESOLV_CONF} = $dcvars->{RESOLV_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}\" ";
@@ -597,6 +605,9 @@ sub setup_ad_member_idmap_rid
        idmap config * : range = 1000000-1999999
        idmap config $dcvars->{DOMAIN} : backend = rid
        idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
+       # Prevent overridding the provisioned lib/krb5.conf which sets certain
+       # values required for tests to succeed
+       create krb5 conf = no
 ";
 
        my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
@@ -626,9 +637,11 @@ sub setup_ad_member_idmap_rid
        Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
+       $ret->{RESOLV_CONF} = $dcvars->{RESOLV_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}\" ";
@@ -713,9 +726,11 @@ sub setup_ad_member_idmap_ad
        Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
+       $ret->{RESOLV_CONF} = $dcvars->{RESOLV_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}\" ";
@@ -762,19 +777,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
@@ -793,6 +847,10 @@ sub setup_simpleserver
        path = $prefix_abs/share
        vfs objects =
        smb encrypt = desired
+
+[hidenewfiles]
+       path = $prefix_abs/share
+       hide new files timeout = 5
 ";
 
        my $vars = $self->provision($path, "WORKGROUP",
@@ -842,6 +900,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);
 
@@ -868,6 +929,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]
@@ -920,6 +983,15 @@ sub setup_fileserver
        comment = inherit only unix owner
        inherit owner = unix only
        acl_xattr:ignore system acls = yes
+# BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
+[force_group_test]
+       path = $share_dir
+       comment = force group test
+#      force group = everyone
+[homes]
+       comment = Home directories
+       browseable = No
+       read only = No
 ";
 
        my $vars = $self->provision($path, "WORKGROUP",
@@ -1581,6 +1653,8 @@ sub provision($$$$$$$$$)
 
        my $conffile="$libdir/server.conf";
        my $dfqconffile="$libdir/dfq.conf";
+       my $errorinjectconf="$libdir/error_inject.conf";
+       my $delayinjectconf="$libdir/delay_inject.conf";
 
        my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
        my $nss_wrapper_passwd = "$privatedir/passwd";
@@ -1609,8 +1683,11 @@ sub provision($$$$$$$$$)
        my ($gid_force_user);
        my ($uid_user1);
        my ($uid_user2);
+       my ($uid_gooduser);
+       my ($uid_eviluser);
+       my ($uid_slashuser);
 
-       if ($unix_uid < 0xffff - 10) {
+       if ($unix_uid < 0xffff - 13) {
                $max_uid = 0xffff;
        } else {
                $max_uid = $unix_uid;
@@ -1626,6 +1703,9 @@ sub provision($$$$$$$$$)
        $uid_smbget = $max_uid - 8;
        $uid_user1 = $max_uid - 9;
        $uid_user2 = $max_uid - 10;
+       $uid_gooduser = $max_uid - 11;
+       $uid_eviluser = $max_uid - 12;
+       $uid_slashuser = $max_uid - 13;
 
        if ($unix_gids[0] < 0xffff - 8) {
                $max_gid = 0xffff;
@@ -1718,7 +1798,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
@@ -1952,6 +2036,24 @@ sub provision($$$$$$$$$)
        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
@@ -2111,16 +2213,35 @@ sub provision($$$$$$$$$)
        vfs objects = shadow_copy2
        shadow:mountpoint = $shadow_mntdir
        wide links = yes
+
+[shadow_write]
+       path = $shadow_tstdir
+       comment = previous versions snapshots under mount point
+       vfs objects = shadow_copy2 streams_xattr error_inject
+       aio write size = 0
+       error_inject:pwrite = EBADF
+       shadow:mountpoint = $shadow_tstdir
+
 [dfq]
        path = $shrdir/dfree
        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
@@ -2159,7 +2280,25 @@ sub provision($$$$$$$$$)
 [error_inject]
        copy = tmp
        vfs objects = error_inject
-       include = $libdir/error_inject.conf
+       include = $errorinjectconf
+
+[delay_inject]
+       copy = tmp
+       vfs objects = delay_inject
+       kernel share modes = no
+       kernel oplocks = no
+       posix locking = no
+       include = $delayinjectconf
+
+[aio_delay_inject]
+       copy = tmp
+       vfs objects = delay_inject
+       delay_inject:pread_send = 2000
+       delay_inject:pwrite_send = 2000
+
+[delete_readonly]
+       path = $prefix_abs/share
+       delete readonly = yes
        ";
        close(CONF);
 
@@ -2173,6 +2312,18 @@ sub provision($$$$$$$$$)
            return undef;
        }
 
+       unless (open(ERRORCONF, ">$errorinjectconf")) {
+               warn("Unable to open $errorinjectconf");
+               return undef;
+       }
+       close(ERRORCONF);
+
+       unless (open(DELAYCONF, ">$delayinjectconf")) {
+               warn("Unable to open $delayinjectconf");
+               return undef;
+       }
+       close(DELAYCONF);
+
        unless (open(DFQCONF, ">$dfqconffile")) {
                warn("Unable to open $dfqconffile");
                return undef;
@@ -2197,6 +2348,9 @@ force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/f
 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
+gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
+eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
+slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
 ";
        if ($unix_uid != 0) {
                print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
@@ -2263,9 +2417,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");
@@ -2273,6 +2427,9 @@ force_user:x:$gid_force_user:
        createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
        createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
        createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
+       createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
+       createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
+       createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
 
        open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
        print DNS_UPDATE_LIST "A $server. $server_ip\n";
@@ -2412,6 +2569,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) {
@@ -2419,6 +2579,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) {
@@ -2426,6 +2589,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) {