浏览代码

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.
Nathan Kinder 16 年之前
父节点
当前提交
cbed8a2780
共有 1 个文件被更改,包括 12 次插入5 次删除
  1. 12 5
      ldap/servers/plugins/dna/dna.c

+ 12 - 5
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 */
                             /* This is either adding or replacing a value */
                             struct berval *bv = slapi_mod_get_first_value(smod);
                             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 we have a value, see if it's the magic value. */
                             if (bv) {
                             if (bv) {
                                 int len = strlen(config_entry->generate);
                                 int len = strlen(config_entry->generate);
                                 if (len == bv->bv_len) {
                                 if (len == bv->bv_len) {
                                     if (!slapi_UTF8NCASECMP(bv->bv_val,
                                     if (!slapi_UTF8NCASECMP(bv->bv_val,
                                                             config_entry->generate,
                                                             config_entry->generate,
-                                                            len))
+                                                            len)) {
                                         generate = 1;
                                         generate = 1;
-                                    break;
+                                    }
                                 }
                                 }
                             } else {
                             } else {
                                 /* This is a replace with no new values, so we need
                                 /* 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:
   bailmod:
     if (LDAP_CHANGETYPE_MODIFY == modtype) {
     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);
         mods = slapi_mods_get_ldapmods_passout(smods);
         slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods);
         slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods);
         slapi_mods_free(&smods);
         slapi_mods_free(&smods);