]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libads: fix get_kdc_ip_string()
authorRalph Boehme <slow@samba.org>
Tue, 22 Jul 2025 17:22:31 +0000 (19:22 +0200)
committerJule Anger <janger@samba.org>
Fri, 22 Aug 2025 12:07:09 +0000 (12:07 +0000)
Correctly handle the interaction between optionally passed in DC via
pss and DC lookup.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit 23f100f67c0586a940e91e9e1e6f42b804401322)

source3/libads/kerberos.c

index c1f3f3ce35674824de7a2c173e88855e5f8b635c..deafe1c4fce93a0cbfac31058aea16e47435a2ba 100644 (file)
@@ -1180,10 +1180,12 @@ static char *get_kdc_ip_string(char *mem_ctx,
        DBG_DEBUG("%zu additional KDCs to test\n", num_dcs);
        if (num_dcs == 0) {
                /*
-                * We do not have additional KDCs, but we have the one passed
-                * in via `pss`. So just use that one and leave.
+                * We do not have additional KDCs, but if we have one passed
+                * in via `pss` just use that one, otherwise fail
                 */
-               result = talloc_move(mem_ctx, &kdc_str);
+               if (pss != NULL) {
+                       result = talloc_move(mem_ctx, &kdc_str);
+               }
                goto out;
        }
 
@@ -1230,7 +1232,13 @@ static char *get_kdc_ip_string(char *mem_ctx,
 
        if (!NT_STATUS_IS_OK(status)) {
                DBG_DEBUG("netlogon_pings failed: %s\n", nt_errstr(status));
-               result = talloc_move(mem_ctx, &kdc_str);
+               /*
+                * netlogon_pings() failed, but if we have one passed
+                * in via `pss` just just use that one, otherwise fail
+                */
+               if (pss != NULL) {
+                       result = talloc_move(mem_ctx, &kdc_str);
+               }
                goto out;
        }