dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0198-ipa-make-sure-view-name-is-initialized-at-startup.patch

60d7aa
From 2d39f46386fb36b5a68f41644ce22c15bf6ccb67 Mon Sep 17 00:00:00 2001
60d7aa
From: Sumit Bose <sbose@redhat.com>
60d7aa
Date: Thu, 31 Aug 2017 22:30:25 +0200
60d7aa
Subject: [PATCH 198/199] ipa: make sure view name is initialized at startup
60d7aa
60d7aa
sysdb_master_domain_update() can only set the view name properly if it was not
60d7aa
set before but it might be called multiple times before the view name is
60d7aa
available if the cache is empty. Since ipa_apply_view() keeps track if
60d7aa
the view name was already set at startup or not the name can safely be
60d7aa
cleaned here before sysdb_master_domain_update() is called.
60d7aa
60d7aa
Resolves:
60d7aa
https://pagure.io/SSSD/sssd/issue/3501
60d7aa
60d7aa
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
60d7aa
(cherry picked from commit f00591a4615720640cf01b1c408315b57dd397dc)
60d7aa
---
60d7aa
 src/providers/ipa/ipa_subdomains.c | 19 ++++++++++++++++++-
60d7aa
 1 file changed, 18 insertions(+), 1 deletion(-)
60d7aa
60d7aa
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
60d7aa
index 6f0ff50bde234f72d62f43635d9a787316c78430..0cb4d405e45689e9548ad3652e7260f2265bd1fe 100644
60d7aa
--- a/src/providers/ipa/ipa_subdomains.c
60d7aa
+++ b/src/providers/ipa/ipa_subdomains.c
60d7aa
@@ -739,6 +739,18 @@ done:
60d7aa
     return ret;
60d7aa
 }
60d7aa
 
60d7aa
+static void clean_view_name(struct sss_domain_info *domain)
60d7aa
+{
60d7aa
+    struct sss_domain_info *dom = domain;
60d7aa
+
60d7aa
+    while (dom) {
60d7aa
+        dom->has_views = false;
60d7aa
+        talloc_free(discard_const(dom->view_name));
60d7aa
+        dom->view_name = NULL;
60d7aa
+        dom = get_next_domain(dom, SSS_GND_DESCEND);
60d7aa
+    }
60d7aa
+}
60d7aa
+
60d7aa
 static errno_t ipa_apply_view(struct sss_domain_info *domain,
60d7aa
                               struct ipa_id_ctx *ipa_id_ctx,
60d7aa
                               const char *view_name,
60d7aa
@@ -831,7 +843,12 @@ static errno_t ipa_apply_view(struct sss_domain_info *domain,
60d7aa
     }
60d7aa
 
60d7aa
     if (!read_at_init) {
60d7aa
-        /* refresh view data of all domains at startup */
60d7aa
+        /* refresh view data of all domains at startup, since
60d7aa
+         * sysdb_master_domain_update and sysdb_update_subdomains might have
60d7aa
+         * been called earlier without the proper view name the name is
60d7aa
+         * cleaned here before the calls. This is acceptable because this is
60d7aa
+         * the initial setup (!read_at_init).  */
60d7aa
+        clean_view_name(domain);
60d7aa
         ret = sysdb_master_domain_update(domain);
60d7aa
         if (ret != EOK) {
60d7aa
             DEBUG(SSSDBG_OP_FAILURE, "sysdb_master_domain_update failed "
60d7aa
-- 
60d7aa
2.13.5
60d7aa