Re: [389-devel] Please Review: (514955) Don't replicate DNA generation mod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/31/2009 03:16 PM, Nathan Kinder wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=514955
The previous patch did not handle all cases.  This new patch takes a different approach
than the previous patch.  Instead of trimming the mod that triggered generation, we leave
it alone and make DNA check subsequent mods before commiting to generating a new
value.  This is easily done by just unsetting the generate flag if we find a subsequent
mod for the same attribute in the same operation.

-- 389-devel mailing list 389-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-directory-devel

>From cbed8a2780469cdbf298c30e7f10da01c4356d03 Mon Sep 17 00:00:00 2001
From: Nathan Kinder <nkinder@xxxxxxxxxxxxxxxxxxx>
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

--
389-devel mailing list
389-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-directory-devel

[Index of Archives]     [Fedora Directory Announce]     [Fedora Users]     [Older Fedora Users Mail]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Review]     [Fedora Art]     [Fedora Music]     [Fedora Packaging]     [CentOS]     [Fedora SELinux]     [Big List of Linux Books]     [KDE Users]     [Fedora Art]     [Fedora Docs]

  Powered by Linux