dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0131-AD-SUBDOMAINS-Fix-search-bases-for-child-domains.patch

bb7cd1
From f994343e9ffc8f8d2917678ae61bcdf68c316a20 Mon Sep 17 00:00:00 2001
bb7cd1
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
bb7cd1
Date: Tue, 9 May 2017 11:21:02 +0200
bb7cd1
Subject: [PATCH 131/131] AD SUBDOMAINS: Fix search bases for child domains
bb7cd1
bb7cd1
When using direct AD integration, child domains did not respect
bb7cd1
the sssd.conf configuration of search bases.
bb7cd1
bb7cd1
There were few issues all of which are fixed in this small
bb7cd1
patch.
bb7cd1
bb7cd1
First problem was that the sdap domain list was not properly
bb7cd1
inherited from the parent in the child domains and the children
bb7cd1
always created their own sdap domains lists that were disconnected
bb7cd1
from the parent context and never used.
bb7cd1
bb7cd1
Second issue was that the child domain did not call the function
bb7cd1
to reinit the search bases after the sdap_domain was added to the
bb7cd1
list of sdap domains. This caused that child domains always used
bb7cd1
automatically detected search bases and never used the configured
bb7cd1
ones even though they were properly read into the ID options
bb7cd1
context attached to the subdomain.
bb7cd1
bb7cd1
Also there has been an issue that the sdap search bases
bb7cd1
were rewritten by the new child domain initialization
bb7cd1
(this only happened with more than one child domain)
bb7cd1
because the sdap domain list was 'updated' every time
bb7cd1
a new child domain was initialized, which caused that
bb7cd1
only the main domain and the last child domain had proper
bb7cd1
search bases, the others only the auto-discovered ones
bb7cd1
(because they were overwritten with the 'update').
bb7cd1
bb7cd1
Resolves:
bb7cd1
https://pagure.io/SSSD/sssd/issue/3397
bb7cd1
bb7cd1
Reviewed-by: Sumit Bose <sbose@redhat.com>
bb7cd1
---
bb7cd1
 src/providers/ad/ad_subdomains.c | 17 +++++++++++++++++
bb7cd1
 src/providers/ldap/sdap_domain.c |  5 +++++
bb7cd1
 2 files changed, 22 insertions(+)
bb7cd1
bb7cd1
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
bb7cd1
index ef166446e837c3f7cd824c1abf4b5cc587aec9da..c9b79dd9d6840802cddc067eef9d5110cf8d0778 100644
bb7cd1
--- a/src/providers/ad/ad_subdomains.c
bb7cd1
+++ b/src/providers/ad/ad_subdomains.c
bb7cd1
@@ -221,6 +221,9 @@ ad_subdom_ad_ctx_new(struct be_ctx *be_ctx,
bb7cd1
     ad_id_ctx->sdap_id_ctx->opts = ad_options->id;
bb7cd1
     ad_options->id_ctx = ad_id_ctx;
bb7cd1
 
bb7cd1
+    /* We need to pass the sdap list from parent */
bb7cd1
+    ad_id_ctx->sdap_id_ctx->opts->sdom = id_ctx->sdap_id_ctx->opts->sdom;
bb7cd1
+
bb7cd1
     /* use AD plugin */
bb7cd1
     srv_ctx = ad_srv_plugin_ctx_init(be_ctx, be_ctx->be_res,
bb7cd1
                                      default_host_dbs,
bb7cd1
@@ -257,6 +260,13 @@ ad_subdom_ad_ctx_new(struct be_ctx *be_ctx,
bb7cd1
     ad_id_ctx->sdap_id_ctx->opts->idmap_ctx =
bb7cd1
         id_ctx->sdap_id_ctx->opts->idmap_ctx;
bb7cd1
 
bb7cd1
+    ret = ad_set_search_bases(ad_options->id, sdom);
bb7cd1
+    if (ret != EOK) {
bb7cd1
+        DEBUG(SSSDBG_MINOR_FAILURE, "Failed to set LDAP search bases for "
bb7cd1
+              "domain '%s'. Will try to use automatically detected search "
bb7cd1
+              "bases.", subdom->name);
bb7cd1
+    }
bb7cd1
+
bb7cd1
     *_subdom_id_ctx = ad_id_ctx;
bb7cd1
     return EOK;
bb7cd1
 }
bb7cd1
@@ -621,6 +631,13 @@ ads_store_sdap_subdom(struct ad_subdomains_ctx *ctx,
bb7cd1
         return ret;
bb7cd1
     }
bb7cd1
 
bb7cd1
+    ret = ad_set_search_bases(ctx->ad_id_ctx->ad_options->id, ctx->sdom);
bb7cd1
+    if (ret != EOK) {
bb7cd1
+        DEBUG(SSSDBG_MINOR_FAILURE, "failed to set ldap search bases for "
bb7cd1
+              "domain '%s'. will try to use automatically detected search "
bb7cd1
+              "bases.", ctx->sdom->dom->name);
bb7cd1
+    }
bb7cd1
+
bb7cd1
     DLIST_FOR_EACH(sditer, ctx->sdom) {
bb7cd1
         if (IS_SUBDOMAIN(sditer->dom) && sditer->pvt == NULL) {
bb7cd1
             ret = ad_subdom_ad_ctx_new(ctx->be_ctx, ctx->ad_id_ctx,
bb7cd1
diff --git a/src/providers/ldap/sdap_domain.c b/src/providers/ldap/sdap_domain.c
bb7cd1
index 5cba9df0fd5fb320a57adc39093283aed865f57f..d384b2e4a0ec3a7c8d0b05e0ce735feb2189085f 100644
bb7cd1
--- a/src/providers/ldap/sdap_domain.c
bb7cd1
+++ b/src/providers/ldap/sdap_domain.c
bb7cd1
@@ -154,6 +154,11 @@ sdap_domain_subdom_add(struct sdap_id_ctx *sdap_id_ctx,
bb7cd1
                     parent->name, ret, strerror(ret));
bb7cd1
                 return ret;
bb7cd1
             }
bb7cd1
+        } else if (sditer->search_bases != NULL) {
bb7cd1
+            DEBUG(SSSDBG_TRACE_FUNC,
bb7cd1
+                  "subdomain %s has already initialized search bases\n",
bb7cd1
+                  dom->name);
bb7cd1
+            continue;
bb7cd1
         } else {
bb7cd1
             sdom = sditer;
bb7cd1
         }
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1