dsdb: Audit group membership changes
[nivanova/samba-autobuild/.git] / selftest / target / Samba4.pm
index ea23c66c3dcf643bc9fc21df80f430be062b984f..7abc16e1a7af5fd7a3428f5bb96d59fabdf19c5b 100755 (executable)
@@ -215,14 +215,6 @@ sub wait_for_start($$)
 
        # Ensure we have the first RID Set before we start tests.  This makes the tests more reliable.
        if ($testenv_vars->{SERVER_ROLE} eq "domain controller") {
-               # Add hosts file for name lookups
-               $ENV{NSS_WRAPPER_HOSTS} = $testenv_vars->{NSS_WRAPPER_HOSTS};
-               if (defined($testenv_vars->{RESOLV_WRAPPER_CONF})) {
-                       $ENV{RESOLV_WRAPPER_CONF} = $testenv_vars->{RESOLV_WRAPPER_CONF};
-               } else {
-                       $ENV{RESOLV_WRAPPER_HOSTS} = $testenv_vars->{RESOLV_WRAPPER_HOSTS};
-               }
-
                print "waiting for working LDAP and a RID Set to be allocated\n";
                my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
                my $count = 0;
@@ -234,7 +226,21 @@ sub wait_for_start($$)
                        $search_dn = "cn=RID Set,cn=$testenv_vars->{NETBIOSNAME},ou=domain controllers,$base_dn";
                }
                my $max_wait = 60;
-               my $cmd = "$ldbsearch $testenv_vars->{CONFIGURATION} -H ldap://$testenv_vars->{SERVER} -U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} -s base -b \"$search_dn\"";
+
+               # Add hosts file for name lookups
+               my $cmd = "NSS_WRAPPER_HOSTS='$testenv_vars->{NSS_WRAPPER_HOSTS}' ";
+               if (defined($testenv_vars->{RESOLV_WRAPPER_CONF})) {
+                       $cmd .= "RESOLV_WRAPPER_CONF='$testenv_vars->{RESOLV_WRAPPER_CONF}' ";
+               } else {
+                       $cmd .= "RESOLV_WRAPPER_HOSTS='$testenv_vars->{RESOLV_WRAPPER_HOSTS}' ";
+               }
+
+               $cmd .= "$ldbsearch ";
+               $cmd .= "$testenv_vars->{CONFIGURATION} ";
+               $cmd .= "-H ldap://$testenv_vars->{SERVER} ";
+               $cmd .= "-U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} ";
+               $cmd .= "-s base ";
+               $cmd .= "-b '$search_dn' ";
                while (system("$cmd >/dev/null") != 0) {
                        $count++;
                        if ($count > $max_wait) {
@@ -372,6 +378,7 @@ sub setup_trust($$$$$)
        $localenv->{TRUST_PASSWORD} = $remoteenv->{PASSWORD};
        $localenv->{TRUST_DOMAIN} = $remoteenv->{DOMAIN};
        $localenv->{TRUST_REALM} = $remoteenv->{REALM};
+       $localenv->{TRUST_DOMSID} = $remoteenv->{DOMSID};
 
        my $samba_tool =  Samba::bindir_path($self, "samba-tool");
        # setup the trust
@@ -398,13 +405,27 @@ sub setup_trust($$$$$)
                return undef;
        }
 
+       my $groupname = "g_$localenv->{TRUST_DOMAIN}";
+       my $groupadd = $cmd_env;
+       $groupadd .= " $samba_tool group add '$groupname' --group-scope=Domain $cmd_config";
+       unless (system($groupadd) == 0) {
+               warn("Failed to create group \n$groupadd");
+               return undef;
+       }
+       my $groupmem = $cmd_env;
+       $groupmem .= " $samba_tool group addmembers '$groupname' '$localenv->{TRUST_DOMSID}-513' $cmd_config";
+       unless (system($groupmem) == 0) {
+               warn("Failed to add group member \n$groupmem");
+               return undef;
+       }
+
        return $localenv
 }
 
-sub provision_raw_prepare($$$$$$$$$$$)
+sub provision_raw_prepare($$$$$$$$$$$$)
 {
        my ($self, $prefix, $server_role, $hostname,
-           $domain, $realm, $functional_level,
+           $domain, $realm, $samsid, $functional_level,
            $password, $kdc_ipv4, $kdc_ipv6) = @_;
        my $ctx;
        my $netbiosname = uc($hostname);
@@ -448,6 +469,7 @@ sub provision_raw_prepare($$$$$$$$$$$)
        $ctx->{domain} = $domain;
        $ctx->{realm} = uc($realm);
        $ctx->{dnsname} = lc($realm);
+       $ctx->{samsid} = $samsid;
 
        $ctx->{functional_level} = $functional_level;
 
@@ -543,6 +565,9 @@ sub provision_raw_prepare($$$$$$$$$$$)
        push (@provision_options, "--quiet");
        push (@provision_options, "--domain=$ctx->{domain}");
        push (@provision_options, "--realm=$ctx->{realm}");
+       if (defined($ctx->{samsid})) {
+               push (@provision_options, "--domain-sid=$ctx->{samsid}");
+       }
        push (@provision_options, "--adminpass=$ctx->{password}");
        push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
        push (@provision_options, "--machinepass=machine$ctx->{password}");
@@ -616,9 +641,12 @@ sub provision_raw_step1($$)
        rndc command = true
        dns update command = $ctx->{samba_dnsupdate}
        spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
+       gpo update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_gpoupdate -s $ctx->{smb_conf} -H $ctx->{privatedir}/sam.ldb --machine
        dreplsrv:periodic_startup_interval = 0
        dsdb:schema update allowed = yes
 
+        prefork children = 4
+
         vfs objects = dfs_samba4 acl_xattr fake_acls xattr_tdb streams_depot
 
         idmap_ldb:use rfc2307=yes
@@ -719,6 +747,7 @@ nogroup:x:65534:nobody
                DOMAIN => $ctx->{domain},
                USERNAME => $ctx->{username},
                REALM => $ctx->{realm},
+               SAMSID => $ctx->{samsid},
                PASSWORD => $ctx->{password},
                LDAPDIR => $ctx->{ldapdir},
                LDAP_INSTANCE => $ctx->{ldap_instance},
@@ -754,6 +783,10 @@ nogroup:x:65534:nobody
                $ret->{RESOLV_WRAPPER_HOSTS} = $ctx->{dns_host_file};
        }
 
+       if ($ctx->{server_role} eq "domain controller") {
+               $ret->{DOMSID} = $ret->{SAMSID};
+       }
+
        return $ret;
 }
 
@@ -844,7 +877,7 @@ userPrincipalName: testdenied_upn\@$ctx->{realm}.upn
        }
 
        # Create to users alice and bob!
-       my $user_account_array = ["alice", "bob"];
+       my $user_account_array = ["alice", "bob", "jane"];
 
        foreach my $user_account (@{$user_account_array}) {
                my $samba_tool_cmd = "";
@@ -859,6 +892,23 @@ userPrincipalName: testdenied_upn\@$ctx->{realm}.upn
                }
        }
 
+       my $ldbmodify = "";
+       $ldbmodify .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
+       $ldbmodify .= "KRB5CCNAME=\"$ret->{KRB5_CCACHE}\" ";
+       $ldbmodify .= Samba::bindir_path($self, "ldbmodify");
+
+       my $base_dn = "DC=".join(",DC=", split(/\./, $ctx->{realm}));
+       my $user_dn = "cn=jane,cn=users,$base_dn";
+
+       open(LDIF, "|$ldbmodify -H $ctx->{privatedir}/sam.ldb");
+       print LDIF "dn: $user_dn
+changetype: modify
+replace: userPrincipalName
+userPrincipalName: jane.doe\@$ctx->{realm}
+-
+";
+       close(LDIF);
+
        return $ret;
 }
 
@@ -869,9 +919,13 @@ sub provision($$$$$$$$$$)
            $password, $kdc_ipv4, $kdc_ipv6, $extra_smbconf_options, $extra_smbconf_shares,
            $extra_provision_options) = @_;
 
+       my $samsid = Samba::random_domain_sid();
+
        my $ctx = $self->provision_raw_prepare($prefix, $server_role,
                                               $hostname,
-                                              $domain, $realm, $functional_level,
+                                              $domain, $realm,
+                                              $samsid,
+                                              $functional_level,
                                               $password, $kdc_ipv4, $kdc_ipv6);
 
        if (defined($extra_provision_options)) {
@@ -1028,6 +1082,7 @@ winbindd:use external pipes = true
 
 # the source4 smb server doesn't allow signing by default
 server signing = enabled
+raw NTLMv2 auth = yes
 
 rpc_server:default = external
 rpc_server:svcctl = embedded
@@ -1045,8 +1100,8 @@ rpc_server:tcpip = no
        my $ret = $self->provision($prefix,
                                   "member server",
                                   $hostname,
-                                  "SAMBADOMAIN",
-                                  "samba.example.com",
+                                  $dcvars->{DOMAIN},
+                                  $dcvars->{REALM},
                                   "2008",
                                   "locMEMpass3",
                                   $dcvars->{SERVER_IP},
@@ -1082,6 +1137,7 @@ rpc_server:tcpip = no
        $ret->{MEMBER_USERNAME} = $ret->{USERNAME};
        $ret->{MEMBER_PASSWORD} = $ret->{PASSWORD};
 
+       $ret->{DOMSID} = $dcvars->{DOMSID};
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
@@ -1121,8 +1177,8 @@ sub provision_rpc_proxy($$$)
        my $ret = $self->provision($prefix,
                                   "member server",
                                   "localrpcproxy",
-                                  "SAMBADOMAIN",
-                                  "samba.example.com",
+                                  $dcvars->{DOMAIN},
+                                  $dcvars->{REALM},
                                   "2008",
                                   "locRPCproxypass4",
                                   $dcvars->{SERVER_IP},
@@ -1187,6 +1243,7 @@ sub provision_rpc_proxy($$$)
        $ret->{RPC_PROXY_USERNAME} = $ret->{USERNAME};
        $ret->{RPC_PROXY_PASSWORD} = $ret->{PASSWORD};
 
+       $ret->{DOMSID} = $dcvars->{DOMSID};
        $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
        $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
        $ret->{DC_SERVER_IPV6} = $dcvars->{DC_SERVER_IPV6};
@@ -1205,8 +1262,9 @@ sub provision_promoted_dc($$$)
        # We do this so that we don't run the provision.  That's the job of 'samba-tool domain dcpromo'.
        my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
                                               "promotedvdc",
-                                              "SAMBADOMAIN",
-                                              "samba.example.com",
+                                              $dcvars->{DOMAIN},
+                                              $dcvars->{REALM},
+                                              $dcvars->{SAMSID},
                                               "2008",
                                               $dcvars->{PASSWORD},
                                               $dcvars->{SERVER_IP},
@@ -1302,6 +1360,7 @@ sub provision_vampire_dc($$$)
                                               $name,
                                               $dcvars->{DOMAIN},
                                               $dcvars->{REALM},
+                                              $dcvars->{DOMSID},
                                               $fl,
                                               $dcvars->{PASSWORD},
                                               $dcvars->{SERVER_IP},
@@ -1344,6 +1403,7 @@ sub provision_vampire_dc($$$)
        $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
        $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} --domain-critical-only";
        $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs";
+       $cmd .= " --backend-store=mdb";
 
        unless (system($cmd) == 0) {
                warn("Join failed\n$cmd");
@@ -1378,10 +1438,12 @@ sub provision_subdom_dc($$$)
        print "PROVISIONING SUBDOMAIN DC...\n";
 
        # We do this so that we don't run the provision.  That's the job of 'net vampire'.
+       my $samsid = undef; # TODO pass the domain sid all the way down
        my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
                                               "localsubdc",
                                               "SAMBASUBDOM",
                                               "sub.samba.example.com",
+                                              $samsid,
                                               "2008",
                                               $dcvars->{PASSWORD},
                                               undef);
@@ -1458,9 +1520,14 @@ sub provision_ad_dc_ntvfs($$)
         server services = +winbind -winbindd
        ldap server require strong auth = allow_sasl_over_tls
        allow nt4 crypto = yes
+       raw NTLMv2 auth = yes
        lsa over netlogon = yes
         rpc server port = 1027
         auth event notification = true
+       dsdb event notification = true
+       dsdb password event notification = true
+       dsdb group change notification = true
+       server schannel = auto
        ";
        my $ret = $self->provision($prefix,
                                   "domain controller",
@@ -1503,6 +1570,12 @@ sub provision_fl2000dc($$)
        spnego:simulate_w2k=yes
        ntlmssp_server:force_old_spnego=yes
 ";
+       my $extra_provision_options = undef;
+       # This environment uses plain text secrets
+       # i.e. secret attributes are not encrypted on disk.
+       # This allows testing of the --plaintext-secrets option for
+       # provision
+       push (@{$extra_provision_options}, "--plaintext-secrets");
        my $ret = $self->provision($prefix,
                                   "domain controller",
                                   "dc5",
@@ -1514,7 +1587,7 @@ sub provision_fl2000dc($$)
                                   undef,
                                   $extra_conf_options,
                                   "",
-                                  undef);
+                                  $extra_provision_options);
        unless ($ret) {
                return undef;
        }
@@ -1639,8 +1712,9 @@ sub provision_rodc($$$)
        # We do this so that we don't run the provision.  That's the job of 'net join RODC'.
        my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
                                               "rodc",
-                                              "SAMBADOMAIN",
-                                              "samba.example.com",
+                                              $dcvars->{DOMAIN},
+                                              $dcvars->{REALM},
+                                              $dcvars->{DOMSID},
                                               "2008",
                                               $dcvars->{PASSWORD},
                                               $dcvars->{SERVER_IP},
@@ -1803,6 +1877,7 @@ sub provision_ad_dc($$$$$$)
        smbd:writetimeupdatedelay = 500000
        create mask = 755
        dos filemode = yes
+       check parent directory delete on close = yes
 
         dcerpc endpoint servers = -winreg -srvsvc
 
@@ -1822,7 +1897,11 @@ sub provision_ad_dc($$$$$$)
        lpq cache time = 0
        print notify backchannel = yes
 
+       server schannel = auto
         auth event notification = true
+       dsdb event notification = true
+       dsdb password event notification = true
+       dsdb group change notification = true
         $smbconf_args
 ";
 
@@ -1865,6 +1944,8 @@ sub provision_ad_dc($$$$$$)
        copy = print1
 ";
 
+       my $extra_provision_options = undef;
+       push (@{$extra_provision_options}, "--backend-store=mdb");
        print "PROVISIONING AD DC...\n";
        my $ret = $self->provision($prefix,
                                   "domain controller",
@@ -1877,7 +1958,7 @@ sub provision_ad_dc($$$$$$)
                                   undef,
                                   $extra_smbconf_options,
                                   $extra_smbconf_shares,
-                                  undef);
+                                  $extra_provision_options);
        unless (defined $ret) {
                return undef;
        }
@@ -2049,113 +2130,39 @@ sub check_env($$)
        } else {
            return 1;
        }
-
 }
 
-sub setup_env($$$)
-{
-       my ($self, $envname, $path) = @_;
-       my $target3 = $self->{target3};
-
-       $ENV{ENVNAME} = $envname;
-
-       if (defined($self->{vars}->{$envname})) {
-               return $self->{vars}->{$envname};
-       }
-
-       if ($envname eq "ad_dc_ntvfs") {
-               return $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-       } elsif ($envname eq "fl2000dc") {
-               return $self->setup_fl2000dc("$path/fl2000dc");
-       } elsif ($envname eq "vampire_2000_dc") {
-               if (not defined($self->{vars}->{fl2000dc})) {
-                       $self->setup_fl2000dc("$path/fl2000dc");
-               }
-               return $self->setup_vampire_dc("$path/vampire_2000_dc", $self->{vars}->{fl2000dc}, "2000");
-       } elsif ($envname eq "fl2003dc") {
-               if (not defined($self->{vars}->{ad_dc})) {
-                       $self->setup_ad_dc("$path/ad_dc");
-               }
-               return $self->setup_fl2003dc("$path/fl2003dc", $self->{vars}->{ad_dc});
-       } elsif ($envname eq "fl2008r2dc") {
-               if (not defined($self->{vars}->{ad_dc})) {
-                       $self->setup_ad_dc("$path/ad_dc");
-               }
-               return $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars}->{ad_dc});
-       } elsif ($envname eq "rpc_proxy") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "vampire_dc") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars}->{ad_dc_ntvfs}, "2008");
-       } elsif ($envname eq "promoted_dc") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_promoted_dc("$path/promoted_dc", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "subdom_dc") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_subdom_dc("$path/subdom_dc", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "s4member_dflt_domain") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_s4member_dflt_domain("$path/s4member_dflt_domain", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "s4member") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_s4member("$path/s4member", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "rodc") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $self->setup_rodc("$path/rodc", $self->{vars}->{ad_dc_ntvfs});
-       } elsif ($envname eq "chgdcpass") {
-               return $self->setup_chgdcpass("$path/chgdcpass", $self->{vars}->{chgdcpass});
-       } elsif ($envname eq "ad_member") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $target3->setup_admember("$path/ad_member", $self->{vars}->{ad_dc_ntvfs}, 29);
-       } elsif ($envname eq "ad_dc") {
-               return $self->setup_ad_dc("$path/ad_dc");
-       } elsif ($envname eq "ad_dc_no_nss") {
-               return $self->setup_ad_dc_no_nss("$path/ad_dc_no_nss");
-       } elsif ($envname eq "ad_dc_no_ntlm") {
-               return $self->setup_ad_dc_no_ntlm("$path/ad_dc_no_ntlm");
-       } elsif ($envname eq "ad_member_rfc2307") {
-               if (not defined($self->{vars}->{ad_dc_ntvfs})) {
-                       $self->setup_ad_dc_ntvfs("$path/ad_dc_ntvfs");
-               }
-               return $target3->setup_admember_rfc2307("$path/ad_member_rfc2307",
-                                                       $self->{vars}->{ad_dc_ntvfs}, 34);
-       } elsif ($envname eq "ad_member_idmap_rid") {
-               if (not defined($self->{vars}->{ad_dc})) {
-                       $self->setup_ad_dc("$path/ad_dc");
-               }
-               return $target3->setup_ad_member_idmap_rid("$path/ad_member_idmap_rid",
-                                                          $self->{vars}->{ad_dc});
-       } elsif ($envname eq "ad_member_idmap_ad") {
-               if (not defined($self->{vars}->{ad_dc})) {
-                       $self->setup_ad_dc("$path/ad_dc");
-               }
-               return $target3->setup_ad_member_idmap_ad("$path/ad_member_idmap_ad",
-                                                         $self->{vars}->{ad_dc});
-       } elsif ($envname eq "none") {
-               return $self->setup_none("$path/none");
-       } else {
-               return "UNKNOWN";
-       }
-}
-
-sub setup_s4member($$$)
+# Declare the environments Samba4 makes available.
+# To be set up, they will be called as
+#   samba4->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
+%Samba4::ENV_DEPS = (
+       # name               => [dep_1, dep_2, ...],
+       ad_dc_ntvfs          => [],
+       ad_dc                => [],
+       ad_dc_no_nss         => [],
+       ad_dc_no_ntlm        => [],
+       ad_dc_ntvfs          => [],
+
+       fl2008r2dc           => ["ad_dc"],
+       fl2003dc             => ["ad_dc"],
+       fl2000dc             => [],
+
+       vampire_2000_dc      => ["fl2000dc"],
+       vampire_dc           => ["ad_dc_ntvfs"],
+       promoted_dc          => ["ad_dc_ntvfs"],
+       subdom_dc            => ["ad_dc_ntvfs"],
+
+       rodc                 => ["ad_dc_ntvfs"],
+       rpc_proxy            => ["ad_dc_ntvfs"],
+       chgdcpass            => [],
+
+       s4member_dflt_domain => ["ad_dc_ntvfs"],
+       s4member             => ["ad_dc_ntvfs"],
+
+       none                 => [],
+);
+
+sub setup_s4member
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2165,14 +2172,12 @@ sub setup_s4member($$$)
                if (not defined($self->check_or_start($env, "standard"))) {
                        return undef;
                }
-
-               $self->{vars}->{s4member} = $env;
        }
 
        return $env;
 }
 
-sub setup_s4member_dflt_domain($$$)
+sub setup_s4member_dflt_domain
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2183,14 +2188,12 @@ sub setup_s4member_dflt_domain($$$)
                if (not defined($self->check_or_start($env, "standard"))) {
                        return undef;
                }
-
-               $self->{vars}->{s4member_dflt_domain} = $env;
        }
 
        return $env;
 }
 
-sub setup_rpc_proxy($$$)
+sub setup_rpc_proxy
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2200,13 +2203,11 @@ sub setup_rpc_proxy($$$)
                if (not defined($self->check_or_start($env, "standard"))) {
                        return undef;
                }
-
-               $self->{vars}->{rpc_proxy} = $env;
        }
        return $env;
 }
 
-sub setup_ad_dc_ntvfs($$)
+sub setup_ad_dc_ntvfs
 {
        my ($self, $path) = @_;
 
@@ -2216,13 +2217,11 @@ sub setup_ad_dc_ntvfs($$)
                    warn("Failed to start ad_dc_ntvfs");
                        return undef;
                }
-
-               $self->{vars}->{ad_dc_ntvfs} = $env;
        }
        return $env;
 }
 
-sub setup_chgdcpass($$)
+sub setup_chgdcpass
 {
        my ($self, $path) = @_;
 
@@ -2231,13 +2230,11 @@ sub setup_chgdcpass($$)
                if (not defined($self->check_or_start($env, "standard"))) {
                        return undef;
                }
-
-               $self->{vars}->{chgdcpass} = $env;
        }
        return $env;
 }
 
-sub setup_fl2000dc($$)
+sub setup_fl2000dc
 {
        my ($self, $path) = @_;
 
@@ -2246,14 +2243,12 @@ sub setup_fl2000dc($$)
                if (not defined($self->check_or_start($env, "standard"))) {
                        return undef;
                }
-
-               $self->{vars}->{fl2000dc} = $env;
        }
 
        return $env;
 }
 
-sub setup_fl2003dc($$$)
+sub setup_fl2003dc
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2265,13 +2260,11 @@ sub setup_fl2003dc($$$)
                }
 
                $env = $self->setup_trust($env, $dc_vars, "external", "--no-aes-keys");
-
-               $self->{vars}->{fl2003dc} = $env;
        }
        return $env;
 }
 
-sub setup_fl2008r2dc($$$)
+sub setup_fl2008r2dc
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2288,14 +2281,22 @@ sub setup_fl2008r2dc($$$)
                $self->setup_namespaces($env, $upn_array, $spn_array);
 
                $env = $self->setup_trust($env, $dc_vars, "forest", "");
-
-               $self->{vars}->{fl2008r2dc} = $env;
        }
 
        return $env;
 }
 
-sub setup_vampire_dc($$$$)
+sub setup_vampire_dc
+{
+       return setup_generic_vampire_dc(@_, "2008");
+}
+
+sub setup_vampire_2000_dc
+{
+       return setup_generic_vampire_dc(@_, "2000");
+}
+
+sub setup_generic_vampire_dc
 {
        my ($self, $path, $dc_vars, $fl) = @_;
 
@@ -2306,8 +2307,6 @@ sub setup_vampire_dc($$$$)
                        return undef;
                }
 
-               $self->{vars}->{vampire_dc} = $env;
-
                # force replicated DC to update repsTo/repsFrom
                # for vampired partitions
                my $samba_tool =  Samba::bindir_path($self, "samba-tool");
@@ -2371,7 +2370,7 @@ sub setup_vampire_dc($$$$)
        return $env;
 }
 
-sub setup_promoted_dc($$$)
+sub setup_promoted_dc
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2382,8 +2381,6 @@ sub setup_promoted_dc($$$)
                        return undef;
                }
 
-               $self->{vars}->{promoted_dc} = $env;
-
                # force source and replicated DC to update repsTo/repsFrom
                # for vampired partitions
                my $samba_tool =  Samba::bindir_path($self, "samba-tool");
@@ -2414,7 +2411,7 @@ sub setup_promoted_dc($$$)
        return $env;
 }
 
-sub setup_subdom_dc($$$)
+sub setup_subdom_dc
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2425,8 +2422,6 @@ sub setup_subdom_dc($$$)
                        return undef;
                }
 
-               $self->{vars}->{subdom_dc} = $env;
-
                # force replicated DC to update repsTo/repsFrom
                # for primary domain partitions
                my $samba_tool =  Samba::bindir_path($self, "samba-tool");
@@ -2458,7 +2453,7 @@ sub setup_subdom_dc($$$)
        return $env;
 }
 
-sub setup_rodc($$$)
+sub setup_rodc
 {
        my ($self, $path, $dc_vars) = @_;
 
@@ -2495,12 +2490,10 @@ sub setup_rodc($$$)
            return undef;
        }
 
-       $self->{vars}->{rodc} = $env;
-
        return $env;
 }
 
-sub setup_ad_dc($$)
+sub setup_ad_dc
 {
        my ($self, $path) = @_;
 
@@ -2524,11 +2517,10 @@ sub setup_ad_dc($$)
 
        $self->setup_namespaces($env, $upn_array, $spn_array);
 
-       $self->{vars}->{ad_dc} = $env;
        return $env;
 }
 
-sub setup_ad_dc_no_nss($$)
+sub setup_ad_dc_no_nss
 {
        my ($self, $path) = @_;
 
@@ -2555,11 +2547,10 @@ sub setup_ad_dc_no_nss($$)
 
        $self->setup_namespaces($env, $upn_array, $spn_array);
 
-       $self->{vars}->{ad_dc_no_nss} = $env;
        return $env;
 }
 
-sub setup_ad_dc_no_ntlm($$)
+sub setup_ad_dc_no_ntlm
 {
        my ($self, $path) = @_;
 
@@ -2575,7 +2566,7 @@ sub setup_ad_dc_no_ntlm($$)
                return undef;
        }
 
-       if (not defined($self->check_or_start($env, "single"))) {
+       if (not defined($self->check_or_start($env, "prefork"))) {
            return undef;
        }
 
@@ -2584,11 +2575,10 @@ sub setup_ad_dc_no_ntlm($$)
 
        $self->setup_namespaces($env, $upn_array, $spn_array);
 
-       $self->{vars}->{ad_dc_no_ntlm} = $env;
        return $env;
 }
 
-sub setup_none($$)
+sub setup_none
 {
        my ($self, $path) = @_;