Blame SOURCES/0038-ad-remove-subdomain-that-has-been-disabled-through-a.patch

8d3578
From c9c2b60128b7faa29615123de79ed206491396a9 Mon Sep 17 00:00:00 2001
8d3578
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
8d3578
Date: Thu, 30 May 2019 10:48:07 +0200
8d3578
Subject: [PATCH 38/44] ad: remove subdomain that has been disabled through
8d3578
 ad_enabled_domains from sysdb
8d3578
8d3578
If previously enabled subdomain was disabled by removing it from ad_enabled_domains
8d3578
option in sssd.conf, its cached content (including the domain object itself)
8d3578
was kept in sysdb. Therefore eventhough the domain was effectively disabled in
8d3578
backed its cached data was still available in responders.
8d3578
8d3578
Subdomains that are disabled on server side are correctly removed from sysdb in
8d3578
`ad_subdomains_refresh()` so this issue is related only to the configuration
8d3578
option.
8d3578
8d3578
Resolves:
8d3578
https://pagure.io/SSSD/sssd/issue/4009
8d3578
8d3578
Reviewed-by: Sumit Bose <sbose@redhat.com>
8d3578
(cherry picked from commit 815957cd10a82aca6742b0bd56c7e7f199596cd4)
8d3578
---
8d3578
 src/providers/ad/ad_subdomains.c | 9 +++++++++
8d3578
 1 file changed, 9 insertions(+)
8d3578
8d3578
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
8d3578
index b4e09fb7e..a3906e994 100644
8d3578
--- a/src/providers/ad/ad_subdomains.c
8d3578
+++ b/src/providers/ad/ad_subdomains.c
8d3578
@@ -825,6 +825,15 @@ static errno_t ad_subdomains_process(TALLOC_CTX *mem_ctx,
8d3578
 
8d3578
         if (is_domain_enabled(sd_name, enabled_domains_list) == false) {
8d3578
             DEBUG(SSSDBG_TRACE_FUNC, "Disabling subdomain %s\n", sd_name);
8d3578
+
8d3578
+            /* The subdomain is now disabled in configuraiton file, we
8d3578
+             * need to delete its cached content so it is not returned
8d3578
+             * by responders. The subdomain shares sysdb with its parent
8d3578
+             * domain so it is OK to use domain->sysdb. */
8d3578
+            ret = sysdb_subdomain_delete(domain->sysdb, sd_name);
8d3578
+            if (ret != EOK) {
8d3578
+                goto fail;
8d3578
+            }
8d3578
             continue;
8d3578
         } else {
8d3578
             DEBUG(SSSDBG_TRACE_FUNC, "Enabling subdomain %s\n", sd_name);
8d3578
-- 
8d3578
2.20.1
8d3578