]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
net: Fill in _nameserver.ss_s when -S has been given to net ads join
authorVolker Lendecke <vl@samba.org>
Sat, 13 Jun 2026 13:14:48 +0000 (15:14 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 3 Jul 2026 08:08:36 +0000 (08:08 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/utils/net_ads_join_dns.c

index e35635f2bd0e646c61db863300621c63b54b0a5c..9473ab23dd3be48a687add5900161f552128dcae 100644 (file)
@@ -26,6 +26,7 @@
 #include "passdb.h"
 #include "utils/net_dns.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/libsmb/namequery.h"
 
 #ifdef HAVE_ADS
 
@@ -67,13 +68,22 @@ 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.
-                */
+               bool ok;
+
                _nameserver.hostname = c->opt_host;
+               _nameserver.ss_s = talloc(ctx, struct samba_sockaddr);
+               if (_nameserver.ss_s == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto done;
+               }
+
+               ok = resolve_name(c->opt_host, _nameserver.ss_s, 0x20, false);
+               if (!ok) {
+                       DBG_WARNING("Host %s not found\n", c->opt_host);
+                       status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+                       goto done;
+               }
+
                nameservers = &_nameserver;
                ns_count = 1;
                goto do_update;