selftest: Allow a krb5.conf to be generated that covers multiple realms
authorAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2011 06:02:01 +0000 (16:02 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2011 12:06:07 +0000 (14:06 +0200)
selftest/target/Samba.pm
selftest/target/Samba3.pm
selftest/target/Samba4.pm

index 1b1eb53933618b4cacad712d3b1c2dfd7df62225..d993611eda8792f70364ced2de2a367c4bea8ed9 100644 (file)
@@ -59,14 +59,19 @@ sub bindir_path($$) {
        return $path;
 }
 
        return $path;
 }
 
-sub mk_krb5_conf($)
+sub mk_krb5_conf($$)
 {
 {
-       my ($ctx) = @_;
+       my ($ctx, $other_realms_stanza) = @_;
 
        unless (open(KRB5CONF, ">$ctx->{krb5_conf}")) {
                warn("can't open $ctx->{krb5_conf}$?");
                return undef;
        }
 
        unless (open(KRB5CONF, ">$ctx->{krb5_conf}")) {
                warn("can't open $ctx->{krb5_conf}$?");
                return undef;
        }
+
+       my $our_realms_stanza = mk_realms_stanza($ctx->{realm},
+                                                $ctx->{dnsname},
+                                                $ctx->{domain},
+                                                $ctx->{kdc_ipv4});
        print KRB5CONF "
 #Generated krb5.conf for $ctx->{realm}
 
        print KRB5CONF "
 #Generated krb5.conf for $ctx->{realm}
 
@@ -79,26 +84,11 @@ sub mk_krb5_conf($)
  allow_weak_crypto = yes
 
 [realms]
  allow_weak_crypto = yes
 
 [realms]
- $ctx->{realm} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
- $ctx->{dnsname} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
- $ctx->{domain} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
-
-[domain_realm]
- .$ctx->{dnsname} = $ctx->{realm}
+ $our_realms_stanza
+ $other_realms_stanza
 ";
 
 ";
 
+
         if (defined($ctx->{tlsdir})) {
               print KRB5CONF "
 
         if (defined($ctx->{tlsdir})) {
               print KRB5CONF "
 
@@ -115,4 +105,29 @@ sub mk_krb5_conf($)
        close(KRB5CONF);
 }
 
        close(KRB5CONF);
 }
 
+sub mk_realms_stanza($$$$)
+{
+       my ($realm, $dnsname, $domain, $kdc_ipv4) = @_;
+
+       my $realms_stanza = "
+ $realm = {
+  kdc = $kdc_ipv4:88
+  admin_server = $kdc_ipv4:88
+  default_domain = $dnsname
+ }
+ $dnsname = {
+  kdc = $kdc_ipv4:88
+  admin_server = $kdc_ipv4:88
+  default_domain = $dnsname
+ }
+ $domain = {
+  kdc = $kdc_ipv4:88
+  admin_server = $kdc_ipv4:88
+  default_domain = $dnsname
+ }
+
+";
+        return $realms_stanza;
+}
+
 1;
 1;
index bc8105a62c7c861407765c722e019da4af535d00..d0ca0a17de5ce8c9e468e931bea3aa99ef32552b 100755 (executable)
@@ -233,7 +233,7 @@ sub setup_admember($$$$)
        $ctx->{realm} = $dcvars->{REALM};
        $ctx->{dnsname} = lc($dcvars->{REALM});
        $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
        $ctx->{realm} = $dcvars->{REALM};
        $ctx->{dnsname} = lc($dcvars->{REALM});
        $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
-       Samba::mk_krb5_conf($ctx);
+       Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
@@ -417,7 +417,7 @@ sub setup_ktest($$$)
        $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
        $ctx->{dnsname} = lc($ctx->{realm});
        $ctx->{kdc_ipv4} = "0.0.0.0";
        $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
        $ctx->{dnsname} = lc($ctx->{realm});
        $ctx->{kdc_ipv4} = "0.0.0.0";
-       Samba::mk_krb5_conf($ctx);
+       Samba::mk_krb5_conf($ctx, "");
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
 
        $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
 
index b47fd725f234e675113ea9c3401b88d6abf5bf88..2b1472efef7bc62f516ed94d6bb134b2e7b2c198 100644 (file)
@@ -637,7 +637,7 @@ sub provision_raw_step1($$)
              $ctx->{kdc_ipv4} = $ctx->{ipv4};
         }
 
              $ctx->{kdc_ipv4} = $ctx->{ipv4};
         }
 
-       Samba::mk_krb5_conf($ctx);
+       Samba::mk_krb5_conf($ctx, "");
 
        open(PWD, ">$ctx->{nsswrap_passwd}");
        print PWD "
 
        open(PWD, ">$ctx->{nsswrap_passwd}");
        print PWD "