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

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