Blame SOURCES/0090-ad-add-fallback-in-ad_domain_info_send.patch

1ad1a2
From 410a3faa8cf1e358e53728fae7440a81763ab743 Mon Sep 17 00:00:00 2001
1ad1a2
From: Sumit Bose <sbose@redhat.com>
1ad1a2
Date: Mon, 23 May 2022 09:05:43 +0200
1ad1a2
Subject: [PATCH] ad: add fallback in ad_domain_info_send()
1ad1a2
MIME-Version: 1.0
1ad1a2
Content-Type: text/plain; charset=UTF-8
1ad1a2
Content-Transfer-Encoding: 8bit
1ad1a2
1ad1a2
Commit 51e92297157562511baf8902777f02a4aa2e70e6 allowed
1ad1a2
ad_domain_info_send() to handle multiple domains by searching for the
1ad1a2
matching sdap_domain data. Unfortunately it assumed that the configured
1ad1a2
name and the DNS domain name are always matching. This is true for all
1ad1a2
sub-domains discovered at runtime by DNS lookups but might not be true
1ad1a2
for the domain configured in sssd.conf. Since the configured domain is
1ad1a2
the first in the list of sdap_domain data it will be used as a fallback
1ad1a2
in case no data could be found by name.
1ad1a2
1ad1a2
Resolves: https://github.com/SSSD/sssd/issues/6170
1ad1a2
1ad1a2
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
1ad1a2
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
1ad1a2
(cherry picked from commit 71b14474bec82a0c57065ad45915ebfeb9e3d03e)
1ad1a2
---
1ad1a2
 src/providers/ad/ad_domain_info.c | 17 ++++++++++++++++-
1ad1a2
 1 file changed, 16 insertions(+), 1 deletion(-)
1ad1a2
1ad1a2
diff --git a/src/providers/ad/ad_domain_info.c b/src/providers/ad/ad_domain_info.c
1ad1a2
index f3a82a198..9583c74b9 100644
1ad1a2
--- a/src/providers/ad/ad_domain_info.c
1ad1a2
+++ b/src/providers/ad/ad_domain_info.c
1ad1a2
@@ -217,8 +217,23 @@ ad_domain_info_send(TALLOC_CTX *mem_ctx,
1ad1a2
     state->opts = conn->id_ctx->opts;
1ad1a2
     state->dom_name = dom_name;
1ad1a2
     state->sdom = sdap_domain_get_by_name(state->opts, state->dom_name);
1ad1a2
+    /* The first domain in the list is the domain configured in sssd.conf and
1ad1a2
+     * here it might be possible that the domain name from the config file and
1ad1a2
+     * the DNS domain name do not match. All other sub-domains are discovered
1ad1a2
+     * at runtime with the help of DNS lookups so it is expected that the
1ad1a2
+     * names matches. Hence it makes sense to fall back to the first entry in
1ad1a2
+     * the list if no matching domain was found since it is most probably
1ad1a2
+     * related to the configured domain. */
1ad1a2
+    if (state->sdom == NULL) {
1ad1a2
+        DEBUG(SSSDBG_OP_FAILURE, "No internal domain data found for [%s], "
1ad1a2
+                                 "falling back to first domain.\n",
1ad1a2
+                                 state->dom_name);
1ad1a2
+        state->sdom = state->opts->sdom;
1ad1a2
+    }
1ad1a2
     if (state->sdom == NULL || state->sdom->search_bases == NULL) {
1ad1a2
-        DEBUG(SSSDBG_OP_FAILURE, "Missing internal domain data.\n");
1ad1a2
+        DEBUG(SSSDBG_OP_FAILURE,
1ad1a2
+              "Missing internal domain data for domain [%s].\n",
1ad1a2
+              state->dom_name);
1ad1a2
         ret = EINVAL;
1ad1a2
         goto immediate;
1ad1a2
     }
1ad1a2
-- 
1ad1a2
2.35.3
1ad1a2