Blame SOURCES/0186-SDAP-Update-parent-sdap_list.patch

bb7cd1
From 69b69d84ca9fd3453fa83281fc90e34f413a32f9 Mon Sep 17 00:00:00 2001
bb7cd1
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
bb7cd1
Date: Wed, 14 Jun 2017 19:02:10 +0200
bb7cd1
Subject: [PATCH 186/186] SDAP: Update parent sdap_list
bb7cd1
bb7cd1
Update parent sdap_list with newly created subdomain sdap domain.
bb7cd1
bb7cd1
Preiously, we inherited the parent sdap_list and used it also in the
bb7cd1
subdomain's context (this was introduced recently with commit
bb7cd1
c4ddb9ccab670f9c0d0377680237b62f9f91c496), but it caused problems
bb7cd1
that were difficult to debug (we somewhere rewrite part of the list
bb7cd1
incorrectly).
bb7cd1
bb7cd1
This patch reverses to the previous bahavior, where every subdomain
bb7cd1
has it's own sdap_list, however this time the parrent domain's
bb7cd1
sdap_list is updated so that it has correct information about
bb7cd1
search bases of the child domains.
bb7cd1
bb7cd1
We should ideally have just one sdap_list to avoid the updating
bb7cd1
completely, but this would require more refactoring in the sdap
bb7cd1
code.
bb7cd1
bb7cd1
Resolves:
bb7cd1
https://pagure.io/SSSD/sssd/issue/3421
bb7cd1
bb7cd1
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
bb7cd1
(cherry picked from commit 630aea13063c4b242b3433d16ca4346a1a38429b)
bb7cd1
---
bb7cd1
 src/providers/ad/ad_subdomains.c | 38 +++++++++++++++++++++++++++++++++++---
bb7cd1
 1 file changed, 35 insertions(+), 3 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
bb7cd1
index c9b79dd9d6840802cddc067eef9d5110cf8d0778..e35041c5ad73cb0fcaaaad96333fc17dd3a17638 100644
bb7cd1
--- a/src/providers/ad/ad_subdomains.c
bb7cd1
+++ b/src/providers/ad/ad_subdomains.c
bb7cd1
@@ -141,6 +141,35 @@ static bool is_domain_enabled(const char *domain,
bb7cd1
 }
bb7cd1
 
bb7cd1
 static errno_t
bb7cd1
+update_parent_sdap_list(struct sdap_domain *parent_list,
bb7cd1
+                        struct sdap_domain *child_sdap)
bb7cd1
+{
bb7cd1
+    struct sdap_domain *sditer;
bb7cd1
+
bb7cd1
+    DLIST_FOR_EACH(sditer, parent_list) {
bb7cd1
+        if (sditer->dom == child_sdap->dom) {
bb7cd1
+            break;
bb7cd1
+        }
bb7cd1
+    }
bb7cd1
+
bb7cd1
+    if (sditer == NULL) {
bb7cd1
+        /* Nothing to do */
bb7cd1
+        return EOK;
bb7cd1
+    }
bb7cd1
+
bb7cd1
+    /* Update the search bases */
bb7cd1
+    sditer->search_bases = child_sdap->search_bases;
bb7cd1
+    sditer->user_search_bases = child_sdap->user_search_bases;
bb7cd1
+    sditer->group_search_bases = child_sdap->group_search_bases;
bb7cd1
+    sditer->netgroup_search_bases = child_sdap->netgroup_search_bases;
bb7cd1
+    sditer->sudo_search_bases = child_sdap->sudo_search_bases;
bb7cd1
+    sditer->service_search_bases = child_sdap->service_search_bases;
bb7cd1
+    sditer->autofs_search_bases = child_sdap->autofs_search_bases;
bb7cd1
+
bb7cd1
+    return EOK;
bb7cd1
+}
bb7cd1
+
bb7cd1
+static errno_t
bb7cd1
 ad_subdom_ad_ctx_new(struct be_ctx *be_ctx,
bb7cd1
                      struct ad_id_ctx *id_ctx,
bb7cd1
                      struct sss_domain_info *subdom,
bb7cd1
@@ -221,9 +250,6 @@ 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
@@ -267,6 +293,12 @@ ad_subdom_ad_ctx_new(struct be_ctx *be_ctx,
bb7cd1
               "bases.", subdom->name);
bb7cd1
     }
bb7cd1
 
bb7cd1
+    ret = update_parent_sdap_list(id_ctx->sdap_id_ctx->opts->sdom,
bb7cd1
+                                  sdom);
bb7cd1
+    if (ret != EOK) {
bb7cd1
+        return ret;
bb7cd1
+    }
bb7cd1
+
bb7cd1
     *_subdom_id_ctx = ad_id_ctx;
bb7cd1
     return EOK;
bb7cd1
 }
bb7cd1
-- 
bb7cd1
2.9.4
bb7cd1