Blame SOURCES/0028-views-allow-override-added-for-non-default-views-at-.patch

b2d430
From 845e3a3acea6f83b15ed3d887fcc4ed42cb3eb5a Mon Sep 17 00:00:00 2001
b2d430
From: Sumit Bose <sbose@redhat.com>
b2d430
Date: Mon, 11 Jul 2016 15:04:32 +0200
b2d430
Subject: [PATCH 28/31] views: allow override added for non-default views at
b2d430
 runtime
b2d430
MIME-Version: 1.0
b2d430
Content-Type: text/plain; charset=UTF-8
b2d430
Content-Transfer-Encoding: 8bit
b2d430
b2d430
Currently a new override for a non-default view cannot be displayed at
b2d430
run-time. It even does not only require a restart but the view must be
b2d430
un-applied and applied again to make the changes visible.
b2d430
b2d430
This patch fixes this and makes non-default view behave like the default
b2d430
view where the data from a newly added override are displayed after the
b2d430
cached entry of the related object is expired.
b2d430
b2d430
Resolves https://fedorahosted.org/sssd/ticket/3092
b2d430
b2d430
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
b2d430
(cherry picked from commit 26a3d4f2ef35a088e4c5fc928290052c89a2ff43)
b2d430
---
b2d430
 src/db/sysdb_views.c | 26 ++++++++++++++++++--------
b2d430
 1 file changed, 18 insertions(+), 8 deletions(-)
b2d430
b2d430
diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c
b2d430
index 7adc1523050243b8936cb98be3c71ce4364a03db..2b89e5ca41f719e1217ef3b9e0fd683656e05d42 100644
b2d430
--- a/src/db/sysdb_views.c
b2d430
+++ b/src/db/sysdb_views.c
b2d430
@@ -454,15 +454,23 @@ errno_t sysdb_store_override(struct sss_domain_info *domain,
b2d430
     obj_override_dn = ldb_msg_find_attr_as_string(msgs[0], SYSDB_OVERRIDE_DN,
b2d430
                                                   NULL);
b2d430
     if (obj_override_dn != NULL) {
b2d430
+        /* obj_override_dn can either point to the object itself, i.e there is
b2d430
+         * no override, or to a overide object. This means it can change from
b2d430
+         * the object DN to a override DN and back but not from one override
b2d430
+         * DN to a different override DN. If the new and the old DN are the
b2d430
+         * same we do not need to update the original object.  */
b2d430
         if (strcmp(obj_override_dn, override_dn_str) != 0) {
b2d430
-            DEBUG(SSSDBG_CRIT_FAILURE,
b2d430
-                  "Existing [%s] and new [%s] override DN do not match.\n",
b2d430
-                   obj_override_dn, override_dn_str);
b2d430
-            ret = EINVAL;
b2d430
-            goto done;
b2d430
+            if (strcmp(obj_override_dn, obj_dn_str) != 0
b2d430
+                    && strcmp(override_dn_str, obj_dn_str) != 0) {
b2d430
+                DEBUG(SSSDBG_CRIT_FAILURE,
b2d430
+                      "Existing [%s] and new [%s] override DN do not match.\n",
b2d430
+                       obj_override_dn, override_dn_str);
b2d430
+                ret = EINVAL;
b2d430
+                goto done;
b2d430
+            }
b2d430
+        } else {
b2d430
+            add_ref = false;
b2d430
         }
b2d430
-
b2d430
-        add_ref = false;
b2d430
     }
b2d430
 
b2d430
     ret = ldb_transaction_start(domain->sysdb->ldb);
b2d430
@@ -580,7 +588,9 @@ errno_t sysdb_store_override(struct sss_domain_info *domain,
b2d430
 
b2d430
         msg->dn = obj_dn;
b2d430
 
b2d430
-        ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN, LDB_FLAG_MOD_ADD,
b2d430
+        ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN,
b2d430
+                                obj_override_dn == NULL ? LDB_FLAG_MOD_ADD
b2d430
+                                                        : LDB_FLAG_MOD_REPLACE,
b2d430
                                 NULL);
b2d430
         if (ret != LDB_SUCCESS) {
b2d430
             DEBUG(SSSDBG_OP_FAILURE, "ldb_msg_add_empty failed.\n");
b2d430
-- 
b2d430
2.4.11
b2d430