]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
net ads dns: Use A/AAAA records if the NS query gave them
authorVolker Lendecke <vl@samba.org>
Mon, 11 May 2026 19:23:56 +0000 (21:23 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 3 Jul 2026 08:08:36 +0000 (08:08 +0000)
Windows tends to give us the addresses in the NS response, so try to
avoid additional round-trips. As before, just use the first record we
were given.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/utils/net_ads_join_dns.c

index 9473ab23dd3be48a687add5900161f552128dcae..a6ea8b4b33eaea899e980ed5b770a25dbc75ef39 100644 (file)
@@ -50,7 +50,6 @@ static NTSTATUS net_update_dns_internal(struct net_context *c,
        size_t ns_count = 0, i;
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        DNS_ERROR dns_err;
-       fstring dns_server;
        const char *dnsdomain = NULL;
        char *root_domain = NULL;
        uint32_t ttl = 3600;
@@ -155,6 +154,8 @@ static NTSTATUS net_update_dns_internal(struct net_context *c,
 
 do_update:
        for (i=0; i < ns_count; i++) {
+               struct dns_rr_ns *ns = &nameservers[i];
+               struct ssaddr_buf addstrbuf;
 
                uint32_t flags = DNS_UPDATE_SIGNED |
                                 DNS_UPDATE_UNSIGNED |
@@ -177,13 +178,20 @@ do_update:
 
                status = NT_STATUS_UNSUCCESSFUL;
 
+               if (talloc_array_length(ns->ss_s) == 0) {
+                       /*
+                        * ads_dns_lookup_ns gave no addresses even
+                        * though it tries to find them if they did
+                        * not come with the NS query reply
+                        */
+                       continue;
+               }
+
                /* Now perform the dns update - we'll try non-secure and if we fail,
                   we'll follow it up with a secure update */
 
-               fstrcpy( dns_server, nameservers[i].hostname );
-
-               dns_err = DoDNSUpdate(dns_server,
-                                     dns_server,
+               dns_err = DoDNSUpdate(ssaddr_str_buf(&ns->ss_s[0], &addstrbuf),
+                                     ns->hostname,
                                      dnsdomain,
                                      machine_name,
                                      creds,