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

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