From 02e2933d081748705d94008837f23e3f2f4d1b57 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 22 Jul 2025 19:22:31 +0200 Subject: [PATCH] libads: fix get_kdc_ip_string() 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 Reviewed-by: Guenther Deschner (cherry picked from commit 23f100f67c0586a940e91e9e1e6f42b804401322) --- source3/libads/kerberos.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index c1f3f3ce356..deafe1c4fce 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -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; } -- 2.47.3