diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-07-06 15:39:09 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-07-06 08:10:18 +0200 |
commit | 2908bbe06a3905007864c6caeaa77fb46cc442ef (patch) | |
tree | c3c1bc2a5d27f9f4e9c4736cc2029f4394c998ce /selftest/target | |
parent | 1c86ab9c5056c457a40dc4c8e3b39c9b940c077b (diff) | |
download | samba-2908bbe06a3905007864c6caeaa77fb46cc442ef.tar.gz samba-2908bbe06a3905007864c6caeaa77fb46cc442ef.tar.bz2 samba-2908bbe06a3905007864c6caeaa77fb46cc442ef.zip |
s4-selftest: Test samba-tool domain dcpromo
This needs a new environment to test it properly. This requires a raise in the
number of socket wrapper interfaces.
Andrew Bartlett
Diffstat (limited to 'selftest/target')
-rw-r--r-- | selftest/target/Samba.pm | 1 | ||||
-rw-r--r-- | selftest/target/Samba4.pm | 131 |
2 files changed, 131 insertions, 1 deletions
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 72f26a5edd..ec6fc483d3 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -161,6 +161,7 @@ sub get_interface($) $interfaces{"plugindc"} = 30; $interfaces{"localsubdc"} = 31; $interfaces{"chgdcpass"} = 32; + $interfaces{"promotedvdc"} = 33; # update lib/socket_wrapper/socket_wrapper.c # #define MAX_WRAPPED_INTERFACES 32 diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index f472bb5ef3..b1998a6029 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -966,6 +966,78 @@ sub provision_rpc_proxy($$$) return $ret; } +sub provision_promoted_vampire_dc($$$) +{ + my ($self, $prefix, $dcvars) = @_; + print "PROVISIONING VAMPIRE DC..."; + + # We do this so that we don't run the provision. That's the job of 'net vampire'. + my $ctx = $self->provision_raw_prepare($prefix, "domain controller", + "promotedvdc", + "SAMBADOMAIN", + "samba.example.com", + "2008", + $dcvars->{PASSWORD}, + $dcvars->{SERVER_IP}); + + $ctx->{smb_conf_extra_options} = " + max xmit = 32K + server max protocol = SMB2 + +[sysvol] + path = $ctx->{statedir}/sysvol + read only = yes + +[netlogon] + path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts + read only = no + +"; + + my $ret = $self->provision_raw_step1($ctx); + unless ($ret) { + return undef; + } + + my $samba_tool = Samba::bindir_path($self, "samba-tool"); + my $cmd = ""; + $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; + $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; + $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} MEMBER --realm=$dcvars->{REALM}"; + $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}"; + $cmd .= " --machinepass=machine$ret->{password}"; + + unless (system($cmd) == 0) { + warn("Join failed\n$cmd"); + return undef; + } + + my $samba_tool = Samba::bindir_path($self, "samba-tool"); + my $cmd = ""; + $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; + $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; + $cmd .= "$samba_tool domain dcpromo $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}"; + $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}"; + $cmd .= " --machinepass=machine$ret->{password}"; + + unless (system($cmd) == 0) { + warn("Join failed\n$cmd"); + return undef; + } + + $ret->{PROMOTED_VAMPIRE_DC_SERVER} = $ret->{SERVER}; + $ret->{PROMOTED_VAMPIRE_DC_SERVER_IP} = $ret->{SERVER_IP}; + $ret->{PROMOTED_VAMPIRE_DC_NETBIOSNAME} = $ret->{NETBIOSNAME}; + + $ret->{DC_SERVER} = $dcvars->{DC_SERVER}; + $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP}; + $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME}; + $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME}; + $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD}; + + return $ret; +} + sub provision_vampire_dc($$$) { my ($self, $prefix, $dcvars) = @_; @@ -1486,6 +1558,11 @@ sub setup_env($$$) $self->setup_dc("$path/dc"); } return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars}->{dc}); + } elsif ($envname eq "promoted_vampire_dc") { + if (not defined($self->{vars}->{dc})) { + $self->setup_dc("$path/dc"); + } + return $self->setup_promoted_vampire_dc("$path/promoted_vampire_dc", $self->{vars}->{dc}); } elsif ($envname eq "subdom_dc") { if (not defined($self->{vars}->{dc})) { $self->setup_dc("$path/dc"); @@ -1659,7 +1736,59 @@ sub setup_vampire_dc($$$) my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM})); $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\""; $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\""; - $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{VAMPIRE_DC_SERVER}"; + $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}"; + $cmd .= " $dc_vars->{CONFIGURATION}"; + $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}"; + # replicate Configuration NC + my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\""; + unless(system($cmd_repl) == 0) { + warn("Failed to replicate\n$cmd_repl"); + return undef; + } + # replicate Default NC + $cmd_repl = "$cmd \"$base_dn\""; + unless(system($cmd_repl) == 0) { + warn("Failed to replicate\n$cmd_repl"); + return undef; + } + } + + return $env; +} + +sub setup_promoted_vampire_dc($$$) +{ + my ($self, $path, $dc_vars) = @_; + + my $env = $self->provision_promoted_vampire_dc($path, $dc_vars); + + if (defined $env) { + $self->check_or_start($env, "single"); + + $self->wait_for_start($env); + + $self->{vars}->{promoted_vampire_dc} = $env; + + # force replicated DC to update repsTo/repsFrom + # for vampired partitions + my $samba_tool = Samba::bindir_path($self, "samba-tool"); + my $cmd = ""; + $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\""; + $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\""; + $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}"; + $cmd .= " $env->{CONFIGURATION}"; + $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}"; + unless (system($cmd) == 0) { + warn("Failed to exec kcc\n$cmd"); + return undef; + } + + # as 'vampired' dc may add data in its local replica + # we need to synchronize data between DCs + my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM})); + $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\""; + $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\""; + $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}"; $cmd .= " $dc_vars->{CONFIGURATION}"; $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}"; # replicate Configuration NC |