Tuesday, June 10, 2014

[389-commits] ldap/servers

ldap/servers/plugins/mep/mep.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)

New commits:
commit 0fe78df27bea0ed29f5f74266bc530832e0d8906
Author: Mark Reynolds <mreynolds@redhat.com>
Date: Mon Jun 9 12:27:04 2014 -0400

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!)

diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index 6dbddbc..76ba827 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -1442,38 +1442,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);


--
389 commits mailing list
389-commits@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/389-commits

No comments:

Post a Comment