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