Blame SOURCES/0032-AD-Refresh-subdomain-data-structures-on-startup.patch

2fc102
From 1213f1a45e222b3c1b304262c51900d8ab2a886a Mon Sep 17 00:00:00 2001
2fc102
From: Jakub Hrozek <jhrozek@redhat.com>
2fc102
Date: Fri, 13 Dec 2013 19:11:47 +0100
2fc102
Subject: [PATCH 32/34] AD: Refresh subdomain data structures on startup
2fc102
2fc102
Previously, if no changes were done to the list of subdomains, the SSSD
2fc102
didn't update its list of sdap_domain mappings for the new subdomain.
2fc102
This resulted in errors as no id_ctx was present for the subdomain
2fc102
during lookup.
2fc102
2fc102
This patch moves the block of code performed during update to a function
2fc102
of its own and calls it during provider initialization as well.
2fc102
---
2fc102
 src/providers/ad/ad_subdomains.c | 49 ++++++++++++++++++++++++++--------------
2fc102
 1 file changed, 32 insertions(+), 17 deletions(-)
2fc102
2fc102
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
2fc102
index 100fb13e99f7bf4b3946b1f5c5f9c626674bfb46..e438a688c364084a3f2bbca338a39d61aa86b5d6 100644
2fc102
--- a/src/providers/ad/ad_subdomains.c
2fc102
+++ b/src/providers/ad/ad_subdomains.c
2fc102
@@ -414,6 +414,31 @@ done:
2fc102
     return ret;
2fc102
 }
2fc102
 
2fc102
+static errno_t ad_subdom_reinit(struct ad_subdomains_ctx *ctx)
2fc102
+{
2fc102
+    errno_t ret;
2fc102
+
2fc102
+    ret = sysdb_update_subdomains(ctx->be_ctx->domain);
2fc102
+    if (ret != EOK) {
2fc102
+        DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_subdomains failed.\n"));
2fc102
+        return ret;
2fc102
+    }
2fc102
+
2fc102
+    ret = sss_write_domain_mappings(ctx->be_ctx->domain, false);
2fc102
+    if (ret != EOK) {
2fc102
+        DEBUG(SSSDBG_MINOR_FAILURE, ("sss_krb5_write_mappings failed.\n"));
2fc102
+        /* Just continue */
2fc102
+    }
2fc102
+
2fc102
+    ret = ads_store_sdap_subdom(ctx, ctx->be_ctx->domain);
2fc102
+    if (ret != EOK) {
2fc102
+        DEBUG(SSSDBG_OP_FAILURE, ("ads_store_sdap_subdom failed.\n"));
2fc102
+        return ret;
2fc102
+    }
2fc102
+
2fc102
+    return EOK;
2fc102
+}
2fc102
+
2fc102
 static void ad_subdomains_get_conn_done(struct tevent_req *req);
2fc102
 static void ad_subdomains_master_dom_done(struct tevent_req *req);
2fc102
 static errno_t ad_subdomains_get_slave(struct ad_subdomains_req_ctx *ctx);
2fc102
@@ -619,25 +644,15 @@ static void ad_subdomains_get_slave_domain_done(struct tevent_req *req)
2fc102
         goto done;
2fc102
     }
2fc102
 
2fc102
+    DEBUG(SSSDBG_TRACE_LIBS, ("There are %schanges\n",
2fc102
+                    refresh_has_changes ? "" : "no "));
2fc102
+
2fc102
     if (refresh_has_changes) {
2fc102
-        ret = sysdb_update_subdomains(ctx->sd_ctx->be_ctx->domain);
2fc102
+        ret = ad_subdom_reinit(ctx->sd_ctx);
2fc102
         if (ret != EOK) {
2fc102
-            DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_subdomains failed.\n"));
2fc102
+            DEBUG(SSSDBG_OP_FAILURE, ("Could not reinitialize subdomains\n"));
2fc102
             goto done;
2fc102
         }
2fc102
-
2fc102
-        ret = ads_store_sdap_subdom(ctx->sd_ctx, ctx->sd_ctx->be_ctx->domain);
2fc102
-        if (ret != EOK) {
2fc102
-            DEBUG(SSSDBG_OP_FAILURE, ("ads_store_sdap_subdom failed.\n"));
2fc102
-            goto done;
2fc102
-        }
2fc102
-
2fc102
-        ret = sss_write_domain_mappings(ctx->sd_ctx->be_ctx->domain, false);
2fc102
-        if (ret != EOK) {
2fc102
-            DEBUG(SSSDBG_MINOR_FAILURE,
2fc102
-                  ("sss_krb5_write_mappings failed.\n"));
2fc102
-            /* Just continue */
2fc102
-        }
2fc102
     }
2fc102
 
2fc102
     ret = EOK;
2fc102
@@ -783,9 +798,9 @@ int ad_subdom_init(struct be_ctx *be_ctx,
2fc102
         return EFAULT;
2fc102
     }
2fc102
 
2fc102
-    ret = sysdb_update_subdomains(be_ctx->domain);
2fc102
+    ret = ad_subdom_reinit(ctx);
2fc102
     if (ret != EOK) {
2fc102
-        DEBUG(SSSDBG_MINOR_FAILURE, ("Could not load the list of subdomains. "
2fc102
+        DEBUG(SSSDBG_MINOR_FAILURE, ("Could not reinitialize subdomains. "
2fc102
               "Users from trusted domains might not be resolved correctly\n"));
2fc102
         /* Ignore this error and try to discover the subdomains later */
2fc102
     }
2fc102
-- 
2fc102
1.8.4.2
2fc102