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

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