andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 77c1fde4eddbfec35f1d01a6c242951e1898324d Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Mon, 9 Jun 2014 12:27:04 -0400
dc8c34
Subject: [PATCH 218/225] Ticket 47813 - managed entry plugin fails to update
dc8c34
 member  pointer on modrdn operation
dc8c34
dc8c34
Bug Description:  A modrdn on an existing managed entry failed to update
dc8c34
                  the entry pointer becuase part of the update is to add
dc8c34
                  the managed entry objectclass - which already exists
dc8c34
                  in the managed entry.  This caused the new pointer value
dc8c34
                  to not be added to the managed entry.
dc8c34
dc8c34
Fix Description:  During a modrdn operation perform the objectclass addition
dc8c34
                  in a separate operation, as we don't know if the entry
dc8c34
                  already has the objectclass or not.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47813
dc8c34
dc8c34
TET: passed
dc8c34
Jenkins: passed
dc8c34
dc8c34
Reviewed by: rmeggins(Thanks!)
dc8c34
dc8c34
(cherry picked from commit 0fe78df27bea0ed29f5f74266bc530832e0d8906)
dc8c34
(cherry picked from commit 7a3fd98b0a0cd17736b1662a9bbcbfdd75eddb7b)
dc8c34
---
dc8c34
 ldap/servers/plugins/mep/mep.c | 41 ++++++++++++++++++++++++++++++-----------
dc8c34
 1 file changed, 30 insertions(+), 11 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
dc8c34
index d81ecf4..dfff42b 100644
dc8c34
--- a/ldap/servers/plugins/mep/mep.c
dc8c34
+++ b/ldap/servers/plugins/mep/mep.c
dc8c34
@@ -1462,38 +1462,57 @@ mep_add_managed_entry(struct configEntry *config,
dc8c34
             /* Add forward link to origin entry. */
dc8c34
             LDAPMod oc_mod;
dc8c34
             LDAPMod pointer_mod;
dc8c34
-            LDAPMod *mods[3];
dc8c34
+            LDAPMod *mods[2];
dc8c34
             char *oc_vals[2];
dc8c34
             char *pointer_vals[2];
dc8c34
 
dc8c34
             /* Clear out the pblock for reuse. */
dc8c34
             slapi_pblock_init(mod_pb);
dc8c34
 
dc8c34
-            /* Add the origin entry objectclass. */
dc8c34
+            /*
dc8c34
+             * Add the origin entry objectclass.  Do not check the result
dc8c34
+             * as we could be here because of a modrdn operation - in which
dc8c34
+             * case the objectclass already exists.
dc8c34
+             */
dc8c34
             oc_vals[0] = MEP_ORIGIN_OC;
dc8c34
             oc_vals[1] = 0;
dc8c34
             oc_mod.mod_op = LDAP_MOD_ADD;
dc8c34
             oc_mod.mod_type = SLAPI_ATTR_OBJECTCLASS;
dc8c34
             oc_mod.mod_values = oc_vals;
dc8c34
+            mods[0] = &oc_mod;
dc8c34
+            mods[1] = NULL;
dc8c34
 
dc8c34
-            /* Add a pointer to the managed entry. */
dc8c34
+            /* add the objectclass */
dc8c34
+            slapi_modify_internal_set_pb_ext(mod_pb, slapi_entry_get_sdn(origin),
dc8c34
+                                             mods, 0, 0, mep_get_plugin_id(), 0);
dc8c34
+            slapi_modify_internal_pb(mod_pb);
dc8c34
+            slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
dc8c34
+            if (result != LDAP_SUCCESS && result != LDAP_TYPE_OR_VALUE_EXISTS){
dc8c34
+                slapi_log_error(SLAPI_LOG_FATAL, MEP_PLUGIN_SUBSYSTEM,
dc8c34
+                                "mep_add_managed_entry: Failed to add managed entry "
dc8c34
+                                "objectclass in origin entry \"%s\", error (%s)\n",
dc8c34
+                                slapi_entry_get_dn(origin), ldap_err2string(result));
dc8c34
+                goto bail;
dc8c34
+            }
dc8c34
+            slapi_pblock_init(mod_pb);
dc8c34
+
dc8c34
+            /*
dc8c34
+             * Now, add a pointer to the managed entry.
dc8c34
+             */
dc8c34
             pointer_vals[0] = managed_dn;
dc8c34
             pointer_vals[1] = 0;
dc8c34
             pointer_mod.mod_op = LDAP_MOD_ADD;
dc8c34
             pointer_mod.mod_type = MEP_MANAGED_ENTRY_TYPE;
dc8c34
             pointer_mod.mod_values = pointer_vals;
dc8c34
+            mods[0] = &pointer_mod;
dc8c34
+            mods[1] = NULL;
dc8c34
 
dc8c34
-            mods[0] = &oc_mod;
dc8c34
-            mods[1] = &pointer_mod;
dc8c34
-            mods[2] = 0;
dc8c34
-
dc8c34
-            /* Perform the modify operation. */
dc8c34
             slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
dc8c34
                     "Adding %s pointer to \"%s\" in entry \"%s\"\n.",
dc8c34
                     MEP_MANAGED_ENTRY_TYPE, managed_dn, slapi_entry_get_dn(origin));
dc8c34
-            slapi_modify_internal_set_pb_ext(mod_pb, 
dc8c34
-                                            slapi_entry_get_sdn(origin),
dc8c34
-                                            mods, 0, 0, mep_get_plugin_id(), 0);
dc8c34
+
dc8c34
+            slapi_modify_internal_set_pb_ext(mod_pb, slapi_entry_get_sdn(origin),
dc8c34
+                                             mods, 0, 0, mep_get_plugin_id(), 0);
dc8c34
             slapi_modify_internal_pb(mod_pb);
dc8c34
             slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
dc8c34
 
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34