Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > 655a3b499c6651e9ecbb8a6afc4f0743 > files > 24

sssd-1.13.4-9.1.mga6.src.rpm

From 8fcc5d9f3631e543a643301ffd519241feff3fd6 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Mon, 11 Jul 2016 15:04:32 +0200
Subject: [PATCH 20/24] views: allow override added for non-default views at
 runtime
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently a new override for a non-default view cannot be displayed at
run-time. It even does not only require a restart but the view must be
un-applied and applied again to make the changes visible.

This patch fixes this and makes non-default view behave like the default
view where the data from a newly added override are displayed after the
cached entry of the related object is expired.

Resolves https://fedorahosted.org/sssd/ticket/3092

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit 26a3d4f2ef35a088e4c5fc928290052c89a2ff43)
(cherry picked from commit a77707fee46d9ffd9159780b58a797228889ad7f)
---
 src/db/sysdb_views.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c
index f0459fc174b94d7a735b7c416555eb5aaac42b7c..86c911032252b385aa32e29ced39b896aa142d74 100644
--- a/src/db/sysdb_views.c
+++ b/src/db/sysdb_views.c
@@ -478,15 +478,23 @@ errno_t sysdb_store_override(struct sss_domain_info *domain,
     obj_override_dn = ldb_msg_find_attr_as_string(msgs[0], SYSDB_OVERRIDE_DN,
                                                   NULL);
     if (obj_override_dn != NULL) {
+        /* obj_override_dn can either point to the object itself, i.e there is
+         * no override, or to a overide object. This means it can change from
+         * the object DN to a override DN and back but not from one override
+         * DN to a different override DN. If the new and the old DN are the
+         * same we do not need to update the original object.  */
         if (strcmp(obj_override_dn, override_dn_str) != 0) {
-            DEBUG(SSSDBG_CRIT_FAILURE,
-                  "Existing [%s] and new [%s] override DN do not match.\n",
-                   obj_override_dn, override_dn_str);
-            ret = EINVAL;
-            goto done;
+            if (strcmp(obj_override_dn, obj_dn_str) != 0
+                    && strcmp(override_dn_str, obj_dn_str) != 0) {
+                DEBUG(SSSDBG_CRIT_FAILURE,
+                      "Existing [%s] and new [%s] override DN do not match.\n",
+                       obj_override_dn, override_dn_str);
+                ret = EINVAL;
+                goto done;
+            }
+        } else {
+            add_ref = false;
         }
-
-        add_ref = false;
     }
 
     ret = ldb_transaction_start(domain->sysdb->ldb);
@@ -604,7 +612,9 @@ errno_t sysdb_store_override(struct sss_domain_info *domain,
 
         msg->dn = obj_dn;
 
-        ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN, LDB_FLAG_MOD_ADD,
+        ret = ldb_msg_add_empty(msg, SYSDB_OVERRIDE_DN,
+                                obj_override_dn == NULL ? LDB_FLAG_MOD_ADD
+                                                        : LDB_FLAG_MOD_REPLACE,
                                 NULL);
         if (ret != LDB_SUCCESS) {
             DEBUG(SSSDBG_OP_FAILURE, "ldb_msg_add_empty failed.\n");
-- 
2.7.4