]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: use correct DNS domain name for wrapper hosts file
authorRalph Boehme <slow@samba.org>
Thu, 14 Jan 2021 07:14:46 +0000 (08:14 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 21 Jan 2021 21:48:30 +0000 (21:48 +0000)
For some reason the join fails to register the DNS records when provisioning the
member env:

   Using short domain name -- SAMBA2008R2
   Joined 'IDMAPADMEMBER' to dns domain 'samba2008r2.example.com'
   DNS Update for idmapadmember.samba.example.com failed: ERROR_DNS_UPDATE_FAILED

At the same time the hosts file used by the wrappers contains the wrong fqdn. As
a result the test that the next commit is going do add fails due do the broken
DNS resolution:

...
UNEXPECTED(failure): samba3.blackbox.winbind_ignore_domain.test_winbind_ignore_domains_ok_krb5(ad_member_idmap_ad:local)
REASON: Exception: Exception: do_connect: Connection to idmapadmember.samba2008r2.example.com failed (Error NT_STATUS_UNSUCCESSFUL)
...

Checking DNS in the testenv, first the working record for the main DC:

testenv$ dig @10.53.57.64 dc7.samba2008r2.example.com +short
10.53.57.27

testenv$ bin/samba-tool dns query dc7 samba2008r2.example.com dc7 A -U Administrator%locDCpass7
  Name=, Records=1, Children=0
    A: 10.53.57.27 (flags=f0, serial=1, ttl=900)

Now the failing idmapadmember:

testenv$ dig @10.53.57.64 idmapadmember.samba2008r2.example.com +short

testenv$ bin/samba-tool dns query dc7 samba2008r2.example.com idmapadmember A -U Administrator%locDCpass7
ERROR: Record or zone does not exist.

Fixing the hosts file lets the tests work, fixing the broken DNS record
registration is a task for another day.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14602

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/target/Samba3.pm

index ee20528a325a179690c42019139b30e81a9b926a..b3f0bca01102dd77cb6cd7d41e680ce6ce91b936 100755 (executable)
@@ -761,6 +761,7 @@ sub provision_ad_member
        my $ret = $self->provision(
            prefix => $prefix,
            domain => $dcvars->{DOMAIN},
+           realm => $dcvars->{REALM},
            server => "LOCALADMEMBER",
            password => "loCalMemberPass",
            extra_options => $member_options,
@@ -911,6 +912,7 @@ sub setup_ad_member_rfc2307
        my $ret = $self->provision(
            prefix => $prefix,
            domain => $dcvars->{DOMAIN},
+           realm => $dcvars->{REALM},
            server => "RFC2307MEMBER",
            password => "loCalMemberPass",
            extra_options => $member_options,
@@ -1008,6 +1010,7 @@ sub setup_ad_member_idmap_rid
        my $ret = $self->provision(
            prefix => $prefix,
            domain => $dcvars->{DOMAIN},
+           realm => $dcvars->{REALM},
            server => "IDMAPRIDMEMBER",
            password => "loCalMemberPass",
            extra_options => $member_options,
@@ -1107,6 +1110,7 @@ sub setup_ad_member_idmap_ad
        my $ret = $self->provision(
            prefix => $prefix,
            domain => $dcvars->{DOMAIN},
+           realm => $dcvars->{REALM},
            server => "IDMAPADMEMBER",
            password => "loCalMemberPass",
            extra_options => $member_options,
@@ -1965,6 +1969,7 @@ sub provision($$)
 
        my $prefix = $args{prefix};
        my $domain = $args{domain};
+       my $realm = $args{realm};
        my $server = $args{server};
        my $password = $args{password};
        my $extra_options = $args{extra_options};
@@ -1982,6 +1987,12 @@ sub provision($$)
        my %createuser_env = ();
        my $server_ip = Samba::get_ipv4_addr($server);
        my $server_ipv6 = Samba::get_ipv6_addr($server);
+       my $dns_domain;
+       if (defined($realm)) {
+           $dns_domain = lc($realm);
+       } else {
+           $dns_domain = "samba.example.com";
+       }
 
        my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
        chomp $unix_name;
@@ -2987,8 +2998,8 @@ force_user:x:$gid_force_user:
                warn("Unable to open $nss_wrapper_hosts");
                return undef;
        }
-       print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
-       print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
+       print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
+       print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
        close(HOSTS);
 
        $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);