>From cbed8a2780469cdbf298c30e7f10da01c4356d03 Mon Sep 17 00:00:00 2001 From: Nathan Kinder Date: Fri, 31 Jul 2009 22:53:48 -0700 Subject: [PATCH] Bug 514955 - Make DNA handle multiple mods DNA doesn't handle multiple mods to a managed attribute in the same modify operation properly. If an operation such as deleting a managed value triggers generation, we aren't checking if another mod in the same operation is actually adding a new value. This triggers us to generate a value when we really shouldn't. The fix is to unset the generate flag if we find a subsequent mod to the same managed type. It will be reset if we truly need to generate a new value. --- ldap/servers/plugins/dna/dna.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c index b198ef3..b8e21f0 100644 --- a/ldap/servers/plugins/dna/dna.c +++ b/ldap/servers/plugins/dna/dna.c @@ -2683,15 +2683,24 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype) /* This is either adding or replacing a value */ struct berval *bv = slapi_mod_get_first_value(smod); + /* If generate is already set, a previous mod in + * this same modify operation either removed all + * values or set the magic value. It's possible + * that this mod is adding a valid value, which + * means we would not want to generate a new value. + * It is safe to unset generate since it will be + * reset here if necessary. */ + generate = 0; + /* If we have a value, see if it's the magic value. */ if (bv) { int len = strlen(config_entry->generate); if (len == bv->bv_len) { if (!slapi_UTF8NCASECMP(bv->bv_val, config_entry->generate, - len)) + len)) { generate = 1; - break; + } } } else { /* This is a replace with no new values, so we need @@ -2783,9 +2792,7 @@ static int dna_pre_op(Slapi_PBlock * pb, int modtype) bailmod: if (LDAP_CHANGETYPE_MODIFY == modtype) { - /* these are the mods you made, really, - * I didn't change them, honest, just had a quick look - */ + /* Put the updated mods back into place. */ mods = slapi_mods_get_ldapmods_passout(smods); slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods); slapi_mods_free(&smods); -- 1.6.2.5