Blame SOURCES/0051-ipa-use-only-the-global-catalog-service-of-the-fores.patch

0d602d
From 74568bdde833f752187cb1a38b39715556c91279 Mon Sep 17 00:00:00 2001
0d602d
From: Sumit Bose <sbose@redhat.com>
0d602d
Date: Tue, 4 Dec 2018 13:06:23 +0100
0d602d
Subject: [PATCH 51/51] ipa: use only the global catalog service of the forest
0d602d
 root
0d602d
0d602d
While creating the domains and sub-domains each domain gets a global
0d602d
catalog services assigned but only one should be used because the global
0d602d
catalog is by definition responsible for the whole forest so it does not
0d602d
make sense to use a global catalog service for each domain and in the
0d602d
worst case connect to the same GC multiple times.
0d602d
0d602d
In the AD provider this is simple because the GC service of the
0d602d
configured domain AD_GC_SERVICE_NAME ("AD_GC") can be used. In the IPA
0d602d
case all domains from the trusted forest are on the level of sub-domains
0d602d
so we have to pick one. Since the forest root is linked from all domain
0d602d
of the same forest it will be the most straight forward choice.
0d602d
0d602d
Related to https://pagure.io/SSSD/sssd/issue/3902
0d602d
0d602d
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
0d602d
(cherry picked from commit 62d671b874a66101c0f4bff39fc6d7f49cb8fca6)
0d602d
---
0d602d
 src/providers/ipa/ipa_subdomains_id.c | 50 +++++++++++++++++++++++++--
0d602d
 1 file changed, 47 insertions(+), 3 deletions(-)
0d602d
0d602d
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
0d602d
index a16eed284..48cf74460 100644
0d602d
--- a/src/providers/ipa/ipa_subdomains_id.c
0d602d
+++ b/src/providers/ipa/ipa_subdomains_id.c
0d602d
@@ -713,6 +713,52 @@ int ipa_get_subdom_acct_recv(struct tevent_req *req, int *dp_error_out)
0d602d
     return EOK;
0d602d
 }
0d602d
 
0d602d
+static struct ad_id_ctx *ipa_get_ad_id_ctx(struct ipa_id_ctx *ipa_ctx,
0d602d
+                                           struct sss_domain_info *dom);
0d602d
+
0d602d
+static struct sdap_id_conn_ctx **
0d602d
+ipa_ad_gc_conn_list(TALLOC_CTX *mem_ctx, struct ipa_id_ctx *ipa_ctx,
0d602d
+                    struct ad_id_ctx *ad_ctx, struct sss_domain_info *dom)
0d602d
+{
0d602d
+    struct ad_id_ctx *forest_root_ad_id_ctx;
0d602d
+    struct sdap_id_conn_ctx **clist;
0d602d
+    int cindex = 0;
0d602d
+
0d602d
+    /* While creating the domains and sub-domains each domain gets a global
0d602d
+     * catalog services assigned but only one should be used because the
0d602d
+     * global catalog is by definition responsible for the whole forest so it
0d602d
+     * does not make sense to use a global catalog service for each domain and
0d602d
+     * in the worst case connect to the same GC multiple times.
0d602d
+     *
0d602d
+     * In the AD provider this is simple because the GC service of the
0d602d
+     * configured domain AD_GC_SERVICE_NAME ("AD_GC") can be used. In the IPA
0d602d
+     * case all domains from the trusted forest are on the level of
0d602d
+     * sub-domains so we have to pick one. Since the forest root is linked
0d602d
+     * from all domain of the same forest it will be the most straight forward
0d602d
+     * choice. */
0d602d
+    forest_root_ad_id_ctx = ipa_get_ad_id_ctx(ipa_ctx, dom->forest_root);
0d602d
+    if (forest_root_ad_id_ctx == NULL) {
0d602d
+        DEBUG(SSSDBG_OP_FAILURE, "Missing ad_id_ctx for forest root.\n");
0d602d
+        return NULL;
0d602d
+    }
0d602d
+
0d602d
+    clist = talloc_zero_array(mem_ctx, struct sdap_id_conn_ctx *, 3);
0d602d
+    if (clist == NULL) return NULL;
0d602d
+
0d602d
+    /* Always try GC first */
0d602d
+    if (dp_opt_get_bool(forest_root_ad_id_ctx->ad_options->basic,
0d602d
+                        AD_ENABLE_GC)) {
0d602d
+        clist[cindex] = forest_root_ad_id_ctx->gc_ctx;
0d602d
+        clist[cindex]->ignore_mark_offline = true;
0d602d
+        clist[cindex]->no_mpg_user_fallback = true;
0d602d
+        cindex++;
0d602d
+    }
0d602d
+
0d602d
+    clist[cindex] = ad_get_dom_ldap_conn(ad_ctx, dom);
0d602d
+
0d602d
+    return clist;
0d602d
+}
0d602d
+
0d602d
 /* IPA lookup for server mode. Directly to AD. */
0d602d
 struct ipa_get_ad_acct_state {
0d602d
     int dp_error;
0d602d
@@ -731,8 +777,6 @@ static errno_t ipa_get_ad_apply_override_step(struct tevent_req *req);
0d602d
 static errno_t ipa_get_ad_ipa_membership_step(struct tevent_req *req);
0d602d
 static void ipa_id_get_groups_overrides_done(struct tevent_req *subreq);
0d602d
 static void ipa_get_ad_acct_done(struct tevent_req *subreq);
0d602d
-static struct ad_id_ctx *ipa_get_ad_id_ctx(struct ipa_id_ctx *ipa_ctx,
0d602d
-                                           struct sss_domain_info *dom);
0d602d
 
0d602d
 static struct tevent_req *
0d602d
 ipa_get_ad_acct_send(TALLOC_CTX *mem_ctx,
0d602d
@@ -785,7 +829,7 @@ ipa_get_ad_acct_send(TALLOC_CTX *mem_ctx,
0d602d
     case BE_REQ_INITGROUPS:
0d602d
     case BE_REQ_BY_SECID:
0d602d
     case BE_REQ_GROUP:
0d602d
-        clist = ad_gc_conn_list(req, ad_id_ctx, state->obj_dom);
0d602d
+        clist = ipa_ad_gc_conn_list(req, ipa_ctx, ad_id_ctx, state->obj_dom);
0d602d
         break;
0d602d
     default:
0d602d
         clist = ad_ldap_conn_list(req, ad_id_ctx, state->obj_dom);
0d602d
-- 
0d602d
2.19.1
0d602d