selftest/target/Samba3.pm setup_nt4_dc_schannel trust...
authorStefan Metzmacher <metze@samba.org>
Sat, 10 Jun 2017 10:22:18 +0000 (12:22 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 16 Mar 2018 12:54:23 +0000 (13:54 +0100)
selftest/target/Samba3.pm

index ae872b6c40c8c04672d5748970091966bacc1dfb..b6279d8123e70201bef10f0bbfb09ac10c254421 100755 (executable)
@@ -169,7 +169,7 @@ sub check_env($$)
 %Samba3::ENV_DEPS = (
        # name              => [dep_1, dep_2, ...],
        nt4_dc              => [],
-       nt4_dc_schannel     => [],
+       nt4_dc_schannel     => ["nt4_dc"],
 
        simpleserver        => [],
        fileserver          => [],
@@ -237,7 +237,7 @@ sub setup_nt4_dc
 
 sub setup_nt4_dc_schannel
 {
-       my ($self, $path) = @_;
+       my ($self, $path, $trust_vars) = @_;
 
        print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
 
@@ -269,6 +269,76 @@ sub setup_nt4_dc_schannel
 
        $vars or return undef;
 
+       my $rc = 0;
+       my $count = 0;
+       my $nmblookup = Samba::bindir_path($self, "nmblookup");
+       do {
+               print "Waiting for the LOGON SERVER registration ...\n";
+               my $cmd = "";
+               $cmd .= "$nmblookup $vars->{CONFIGURATION} $trust_vars->{DOMAIN}\#1c";
+               $rc = system("$cmd");
+               if ($rc != 0) {
+                       sleep(1);
+               }
+               $count++;
+       } while ($rc != 0 && $count < 10);
+       if ($count == 10) {
+               print "NMBD not reachable after 10 retries\n";
+               teardown_env($self, $vars);
+               return 0;
+       }
+       do {
+               print "Waiting for the PDC SERVER registration ...\n";
+               my $cmd = "";
+               $cmd .= "$nmblookup $vars->{CONFIGURATION} $trust_vars->{DOMAIN}\#1b";
+               $rc = system("$cmd");
+               if ($rc != 0) {
+                       sleep(1);
+               }
+               $count++;
+       } while ($rc != 0 && $count < 10);
+       if ($count == 10) {
+               print "NMBD not reachable after 10 retries\n";
+               teardown_env($self, $vars);
+               return 0;
+       }
+
+       my $net = Samba::bindir_path($self, "net");
+
+       my $trustpw = "TrUsTpW";
+       $trustpw .= "$vars->{SOCKET_WRAPPER_DEFAULT_IFACE}";
+       $trustpw .= "$trust_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}";
+
+       #
+       # First we create the trust account
+       #
+       my $cmd = "";
+       $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$vars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
+       $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$vars->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
+       $cmd .= "$net rpc trustdom add $vars->{DOMAIN} $trustpw $trust_vars->{CONFIGURATION}";
+       $cmd .= " -I$trust_vars->{SERVER_IP}";
+       $cmd .= " -U$trust_vars->{USERNAME}\%$trust_vars->{PASSWORD}";
+
+       if (system($cmd) != 0) {
+               warn("add failed\n$cmd");
+               return undef;
+       }
+
+       #
+       # Then we establish the trust
+       #
+       my $cmd = "";
+       $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$vars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
+       $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$vars->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
+       $cmd .= "$net rpc trustdom establish $trust_vars->{DOMAIN} $vars->{CONFIGURATION}";
+       $cmd .= " -I$trust_vars->{SERVER_IP}";
+       $cmd .= " -U%$trustpw";
+
+       if (system($cmd) != 0) {
+               warn("establish failed\n$cmd");
+               return undef;
+       }
+
        if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
               return undef;
        }
@@ -280,6 +350,14 @@ sub setup_nt4_dc_schannel
        $vars->{DC_USERNAME} = $vars->{USERNAME};
        $vars->{DC_PASSWORD} = $vars->{PASSWORD};
 
+       $ret->{TRUST_E_OUT_SERVER} = $trust_vars->{SERVER};
+       $ret->{TRUST_E_OUT_SERVER_IP} = $trust_vars->{SERVER_IP};
+       $ret->{TRUST_E_OUT_SERVER_IPV6} = $trust_vars->{SERVER_IPV6};
+       $ret->{TRUST_E_OUT_NETBIOSNAME} = $trust_vars->{NETBIOSNAME};
+       $ret->{TRUST_E_OUT_DOMAIN} = $trust_vars->{DOMAIN};
+       $ret->{TRUST_E_OUT_USERNAME} = $trust_vars->{USERNAME};
+       $ret->{TRUST_E_OUT_PASSWORD} = $trust_vars->{PASSWORD};
+
        return $vars;
 }