]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: let net_update_dns_internal() use c->opt_host to force a specific DC
authorStefan Metzmacher <metze@samba.org>
Thu, 21 May 2026 14:48:58 +0000 (16:48 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 22 May 2026 08:58:38 +0000 (08:58 +0000)
This means the server for dns updates can be provided by the admin.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>

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

index aaa0ca9885edb16ac7abc9465e4f38690f3c24e5..7b0bd644acd226eddf417cdec514d39213e8e797 100644 (file)
@@ -45,6 +45,7 @@ static NTSTATUS net_update_dns_internal(struct net_context *c,
                                        int num_addrs, bool remove_host)
 {
        struct dns_rr_ns *nameservers = NULL;
+       struct dns_rr_ns _nameserver = {};
        size_t ns_count = 0, i;
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        DNS_ERROR dns_err;
@@ -65,6 +66,19 @@ static NTSTATUS net_update_dns_internal(struct net_context *c,
        }
        dnsdomain++;
 
+       if (c->opt_host != NULL) {
+               /*
+                * _nameserver.ss is not used
+                * otherwise we would need
+                * ads_dns_lookup_a and
+                * ads_dns_lookup_aaaa here.
+                */
+               _nameserver.hostname = c->opt_host;
+               nameservers = &_nameserver;
+               ns_count = 1;
+               goto do_update;
+       }
+
        status = ads_dns_lookup_ns(ctx,
                                   dnsdomain,
                                   &nameservers,
@@ -127,6 +141,7 @@ static NTSTATUS net_update_dns_internal(struct net_context *c,
 
        }
 
+do_update:
        for (i=0; i < ns_count; i++) {
 
                uint32_t flags = DNS_UPDATE_SIGNED |