selftest: Add plugin_s4_dc environment
authorAndrew Bartlett <abartlet@samba.org>
Sun, 8 May 2011 04:55:33 +0000 (06:55 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 8 May 2011 17:00:28 +0000 (19:00 +0200)
This environment uses pdb_samba4 and auth_samba4 to plug these
critical subsystems into a mixed Samba3/Samba4 DC, in a similar way to
the 'Franky' proposal.

Andrew Barltett

selftest/target/Samba3.pm
selftest/target/Samba4.pm

index a563653fb466292d5b1c4fdebe962a5dde99b0e5..66ae8b5ec70dd6aab1fcd51d1dfe0c1c3eae2a46 100644 (file)
@@ -269,6 +269,56 @@ sub setup_admember($$$$)
        return $ret;
 }
 
+sub setup_plugin_s4_dc($$$$)
+{
+       my ($self, $prefix, $dcvars, $iface) = @_;
+
+       print "PROVISIONING S4 PLUGIN AD DC$iface...";
+
+       my $plugin_s4_dc_options = "
+        workgroup = $dcvars->{DOMAIN}
+        realm = $dcvars->{REALM}
+        security=ads
+        passdb backend = samba4
+        auth methods = guest samba4
+        domain logons = yes
+        rpc_server:lsarpc = external
+        rpc_server:netlogon = external
+        rpc_server:samr = external
+       server signing = on
+";
+
+       my $ret = $self->provision($prefix,
+                                  "plugindc",
+                                  $iface,
+                                  "pluGin${iface}Pass",
+                                  $plugin_s4_dc_options);
+
+       $ret or return undef;
+
+       close(USERMAP);
+       $ret->{DOMAIN} = $dcvars->{DOMAIN};
+       $ret->{REALM} = $dcvars->{REALM};
+       $ret->{KRB5_CONFIG} = $dcvars->{KRB5_CONFIG};
+       $ret->{DC_USERNAME} = $dcvars->{USERNAME};
+       $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
+
+       # We need world access to this share, as otherwise the domain
+       # administrator from the AD domain provided by Samba4 can't
+       # access the share for tests.
+       chmod 0777, "$prefix/share";
+
+       $self->check_or_start($ret,
+                             "no", "yes", "yes");
+
+       $self->wait_for_start($ret);
+
+       # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
+       $ret->{target} = $self;
+
+       return $ret;
+}
+
 sub setup_secshare($$)
 {
        my ($self, $path) = @_;
index 84ef576b381ae34856e305d2976a69f8cec1bab2..e5ee391be2ecf10313b7a81eb7cd5879c6efa376 100644 (file)
@@ -611,6 +611,7 @@ sub provision_raw_step1($$)
         spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate
         resolv:host file = $ctx->{dns_host_file}
        dreplsrv:periodic_startup_interval = 0
+        ncalrpc dir = $ctx->{lockdir}/ncalrpc
 ";
 
        if (defined($ctx->{sid_generator}) && $ctx->{sid_generator} ne "internal") {
@@ -1157,6 +1158,40 @@ sub provision_rodc($$$)
        return $ret;
 }
 
+sub provision_plugin_s4_dc($$)
+{
+       my ($self, $prefix) = @_;
+
+       my $extra_smbconf_options = "
+server services = -winbind, -smb
+";
+
+       print "PROVISIONING PLUGIN S4 DC...";
+       my $ret = $self->provision($prefix,
+                                  "domain controller",
+                                  "plugindc",
+                                  "PLUGINDOMAIN",
+                                  "plugin.samba.example.com",
+                                  "2008",
+                                  30,
+                                  "locDCpass1",
+                                  undef, $extra_smbconf_options);
+
+       return undef unless(defined $ret);
+       unless($self->add_wins_config("$prefix/private")) {
+               warn("Unable to add wins configuration");
+               return undef;
+       }
+
+       $ret->{DC_SERVER} = $ret->{SERVER};
+       $ret->{DC_SERVER_IP} = $ret->{SERVER_IP};
+       $ret->{DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
+       $ret->{DC_USERNAME} = $ret->{USERNAME};
+       $ret->{DC_PASSWORD} = $ret->{PASSWORD};
+
+       return $ret;
+}
+
 sub teardown_env($$)
 {
        my ($self, $envvars) = @_;
@@ -1261,6 +1296,8 @@ sub setup_env($$$)
                        $self->setup_dc("$path/dc");
                }
                return $target3->setup_admember("$path/s3member", $self->{vars}->{dc}, 29);
+       } elsif ($envname eq "plugin_s4_dc") {
+               return $self->setup_plugin_s4_dc("$path/plugin_s4_dc");
        } elsif ($envname eq "all") {
                if (not defined($self->{vars}->{dc})) {
                        $ENV{ENVNAME} = "dc";
@@ -1491,4 +1528,24 @@ sub setup_rodc($$$)
        return $env;
 }
 
+sub setup_plugin_s4_dc($$)
+{
+       my ($self, $path) = @_;
+
+       my $env = $self->provision_plugin_s4_dc($path);
+       if (defined $env) {
+               $self->check_or_start($env);
+
+               $self->wait_for_start($env);
+
+               my $s3_part_env = $self->{target3}->setup_plugin_s4_dc($path, $env, 30);
+               if (not defined($s3_part_env)) {
+                   return undef;
+               }
+
+               $self->{vars}->{plugin_s4_dc} = $s3_part_env;
+       }
+       return $env;
+}
+
 1;