dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0122-AD-Do-not-remove-non-root-domains-when-looking-up-ro.patch

9cb92d
From a3877f8eb322be17f7d08d74ad3cf655b96219b5 Mon Sep 17 00:00:00 2001
9cb92d
From: Jakub Hrozek <jhrozek@redhat.com>
9cb92d
Date: Tue, 13 May 2014 15:18:07 +0200
9cb92d
Subject: [PATCH 122/124] AD: Do not remove non-root domains when looking up
9cb92d
 root domain
9cb92d
9cb92d
https://fedorahosted.org/sssd/ticket/2322
9cb92d
9cb92d
When the AD subdomains code looked up the root domain subsequently
9cb92d
(after the domain list was already populated), the non-root domains
9cb92d
might have been removed along with their respective tasks, because the
9cb92d
root domain lookup only ever matched a single root domain.
9cb92d
9cb92d
This could cause havoc especially during login when different lookups
9cb92d
for different domains might be going on during user group refresh.
9cb92d
---
9cb92d
 src/providers/ad/ad_subdomains.c | 25 ++++++++++++++++++++++---
9cb92d
 1 file changed, 22 insertions(+), 3 deletions(-)
9cb92d
9cb92d
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
9cb92d
index 3c841788d5d88069d79a9438b72f57c8c2e0ffda..ee04cbbe048e55666db22c48cf22c4c0241a0e3c 100644
9cb92d
--- a/src/providers/ad/ad_subdomains.c
9cb92d
+++ b/src/providers/ad/ad_subdomains.c
9cb92d
@@ -325,13 +325,15 @@ done:
9cb92d
 }
9cb92d
 
9cb92d
 static errno_t ad_subdomains_refresh(struct ad_subdomains_ctx *ctx,
9cb92d
-                                     int count, struct sysdb_attrs **reply,
9cb92d
+                                     int count, bool root_domain,
9cb92d
+                                     struct sysdb_attrs **reply,
9cb92d
                                      bool *changes)
9cb92d
 {
9cb92d
     struct sdap_domain *sdom;
9cb92d
     struct sss_domain_info *domain, *dom;
9cb92d
     bool handled[count];
9cb92d
     const char *value;
9cb92d
+    const char *root_name = NULL;
9cb92d
     int c, h;
9cb92d
     int ret;
9cb92d
     bool enumerate;
9cb92d
@@ -340,10 +342,27 @@ static errno_t ad_subdomains_refresh(struct ad_subdomains_ctx *ctx,
9cb92d
     memset(handled, 0, sizeof(bool) * count);
9cb92d
     h = 0;
9cb92d
 
9cb92d
+    if (root_domain) {
9cb92d
+        ret = sysdb_attrs_get_string(reply[0], AD_AT_TRUST_PARTNER,
9cb92d
+                                     &root_name);
9cb92d
+        if (ret != EOK) {
9cb92d
+            DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
9cb92d
+            goto done;
9cb92d
+        }
9cb92d
+    }
9cb92d
+
9cb92d
     /* check existing subdomains */
9cb92d
     for (dom = get_next_domain(domain, true);
9cb92d
          dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
9cb92d
          dom = get_next_domain(dom, false)) {
9cb92d
+
9cb92d
+        /* If we are handling root domain, skip all the other domains. We don't
9cb92d
+         * want to accidentally remove non-root domains
9cb92d
+         */
9cb92d
+        if (root_name && strcmp(root_name, dom->name) != 0) {
9cb92d
+            continue;
9cb92d
+        }
9cb92d
+
9cb92d
         for (c = 0; c < count; c++) {
9cb92d
             if (handled[c]) {
9cb92d
                 continue;
9cb92d
@@ -719,7 +738,7 @@ static void ad_subdomains_get_root_domain_done(struct tevent_req *req)
9cb92d
         goto fail;
9cb92d
     }
9cb92d
 
9cb92d
-    ret = ad_subdomains_refresh(ctx->sd_ctx, 1, reply, &has_changes);
9cb92d
+    ret = ad_subdomains_refresh(ctx->sd_ctx, 1, true, reply, &has_changes);
9cb92d
     if (ret != EOK) {
9cb92d
         DEBUG(SSSDBG_OP_FAILURE, ("ad_subdomains_refresh failed.\n"));
9cb92d
         goto fail;
9cb92d
@@ -1013,7 +1032,7 @@ static void ad_subdomains_get_slave_domain_done(struct tevent_req *req)
9cb92d
     }
9cb92d
 
9cb92d
     /* Got all the subdomains, let's process them */
9cb92d
-    ret = ad_subdomains_refresh(ctx->sd_ctx, nsubdoms, subdoms,
9cb92d
+    ret = ad_subdomains_refresh(ctx->sd_ctx, nsubdoms, false, subdoms,
9cb92d
                                 &refresh_has_changes);
9cb92d
     if (ret != EOK) {
9cb92d
         DEBUG(SSSDBG_OP_FAILURE, ("Failed to refresh subdomains.\n"));
9cb92d
-- 
9cb92d
1.9.0
9cb92d