diff options
| author | Nathan Kinder <nkinder@boraras.localdomain> | 2009-07-31 22:53:48 -0700 |
|---|---|---|
| committer | Nathan Kinder <nkinder@boraras.localdomain> | 2009-07-31 22:53:48 -0700 |
| commit | cbed8a2780469cdbf298c30e7f10da01c4356d03 (patch) | |
| tree | 42c9841aee7985a5ac882ac7d930dda54019171f | |
| parent | 2d0bceab08f9dd3b1fce47a2bf2da1f78f70e216 (diff) | |
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.
| -rw-r--r-- | 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 b198ef3a..b8e21f0e 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); |
