Blob Blame History Raw
From f60a6fc682646a8c16fa8875456300c61cf3e979 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Fri, 8 Oct 2021 13:49:01 +0200
Subject: [PATCH 80/83] ad: use already discovered forest name
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If the cldap-ping on the current connection does not return a reply with
the name of the forest root and the site of the client the stored values
from the DNS discovery step are used.

Resolves: https://github.com/SSSD/sssd/issues/5820

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit 99c4161910e542dd40c740032196d268c4163d07)

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
---
 src/providers/ad/ad_subdomains.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
index 8a331c503..562047a02 100644
--- a/src/providers/ad/ad_subdomains.c
+++ b/src/providers/ad/ad_subdomains.c
@@ -2095,6 +2095,23 @@ static void ad_subdomains_refresh_master_done(struct tevent_req *subreq)
         return;
     }
 
+    if (state->forest == NULL) {
+        DEBUG(SSSDBG_MINOR_FAILURE, "Forest name was not found, using the one "
+                                    "which was already discovered [%s].\n",
+                                    state->ad_options->current_forest != NULL ?
+                                        state->ad_options->current_forest :
+                                        "- not available-");
+        if (state->ad_options->current_forest != NULL) {
+            state->forest = talloc_strdup(state,
+                                          state->ad_options->current_forest);
+            if (state->forest == NULL) {
+                DEBUG(SSSDBG_OP_FAILURE, "Failed to copy forest name.\n");
+                tevent_req_error(req, ENOMEM);
+                return;
+            }
+        }
+    }
+
     realm = dp_opt_get_cstring(state->ad_options->basic, AD_KRB5_REALM);
     if (realm == NULL) {
         DEBUG(SSSDBG_CONF_SETTINGS, "Missing realm.\n");
-- 
2.26.3