[389-commits] Branch '389-ds-base-1.2.10' - 3 commits - ldap/servers VERSION.sh

Richard Allen Megginson rmeggins at fedoraproject.org
Tue Jul 17 00:15:41 UTC 2012


 VERSION.sh                                  |    2 
 ldap/servers/plugins/referint/referint.c    |   38 ++++++-------
 ldap/servers/plugins/uiduniq/plugin-utils.h |    4 -
 ldap/servers/plugins/uiduniq/uid.c          |   81 ++++++++++++++--------------
 ldap/servers/plugins/uiduniq/utils.c        |   10 +--
 ldap/servers/slapd/back-ldbm/ldbm_search.c  |    4 -
 ldap/servers/slapd/entry.c                  |   35 ++++++------
 ldap/servers/slapd/opshared.c               |   31 +++++++---
 ldap/servers/slapd/slapi-plugin.h           |    2 
 9 files changed, 113 insertions(+), 94 deletions(-)

New commits:
commit ac92b8fb6bf46f958a18bf5ffa404e1b1d3cf1f0
Author: Rich Megginson <rmeggins at redhat.com>
Date:   Mon Jul 16 16:39:40 2012 -0600

    bump version to 1.2.10.13

diff --git a/VERSION.sh b/VERSION.sh
index 8fe4140..7ddc2b8 100644
--- a/VERSION.sh
+++ b/VERSION.sh
@@ -10,7 +10,7 @@ vendor="389 Project"
 # PACKAGE_VERSION is constructed from these
 VERSION_MAJOR=1
 VERSION_MINOR=2
-VERSION_MAINT=10.12
+VERSION_MAINT=10.13
 # if this is a PRERELEASE, set VERSION_PREREL
 # otherwise, comment it out
 # be sure to include the dot prefix in the prerel


commit 93011a3426a4547ed2aaaa780bcf83266a1155ca
Author: Rich Megginson <rmeggins at redhat.com>
Date:   Thu Jul 12 19:56:55 2012 -0600

    Ticket #406 - Impossible to rename entry (modrdn) with Attribute Uniqueness plugin enabled
    
    https://fedorahosted.org/389/ticket/406
    Resolves: Ticket #406
    Bug Description: Impossible to rename entry (modrdn) with Attribute Uniqueness plugin enabled
    Reviewed by: mreynolds (Thanks!)
    Branch: 389-ds-base-1.2.10
    Fix Description: Convert attribute uniqueness to use Slapi_DN* instead of
    char *.  Also found that op_shared_search was always freeing the passed
    in SEARCH_TARGET_SDN, so made that conditional.
    Platforms tested: RHEL6 x86_64
    Flag Day: no
    Doc impact: no
    (cherry picked from commit 832a52d81b8ccc89e765c8cd2e3be801a11db0f4)

diff --git a/ldap/servers/plugins/uiduniq/plugin-utils.h b/ldap/servers/plugins/uiduniq/plugin-utils.h
index 9c5eeb1..bab4616 100644
--- a/ldap/servers/plugins/uiduniq/plugin-utils.h
+++ b/ldap/servers/plugins/uiduniq/plugin-utils.h
@@ -86,11 +86,11 @@
 #define END } while(0);
 
 int op_error(int internal_error);
-Slapi_PBlock *readPblockAndEntry( const char *baseDN, const char *filter,
+Slapi_PBlock *readPblockAndEntry( Slapi_DN *baseDN, const char *filter,
 								  char *attrs[], void *txn, void *pluginid );
 int entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
 						const char *objectClass);
-Slapi_PBlock *dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn, void *pluginid );
+Slapi_PBlock *dnHasObjectClass( Slapi_DN *baseDN, const char *objectClass, void *txn, void *pluginid  );
 Slapi_PBlock *dnHasAttribute( const char *baseDN, const char *attrName, void *txn, void *pluginid );
 
 #endif /* _PLUGIN_UTILS_H_ */
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index e1b855c..28ba895 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -69,8 +69,8 @@ int ldap_quote_filter_value(
       int *outLen);
 
 
-static int search_one_berval(const char *baseDN, const char *attrName,
-		const struct berval *value, const char *requiredObjectClass, const char *target, void *txn);
+static int search_one_berval(Slapi_DN *baseDN, const char *attrName,
+		const struct berval *value, const char *requiredObjectClass, Slapi_DN *target, void *txn);
 
 /*
  * ISSUES:
@@ -224,16 +224,16 @@ create_filter(const char *attribute, const struct berval *value, const char *req
  *   LDAP_OPERATIONS_ERROR - a server failure.
  */
 static int
-search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
+search(Slapi_DN *baseDN, const char *attrName, Slapi_Attr *attr,
   struct berval **values, const char *requiredObjectClass,
-  const char *target, void *txn)
+  Slapi_DN *target, void *txn)
 {
   int result;
 
 #ifdef DEBUG
     slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
-      "SEARCH baseDN=%s attr=%s target=%s\n", baseDN, attrName, 
-      target?target:"None");
+                    "SEARCH baseDN=%s attr=%s target=%s\n", slapi_sdn_get_dn(baseDN), attrName, 
+                    target?slapi_sdn_get_dn(target):"None");
 #endif
 
   result = LDAP_SUCCESS;
@@ -282,9 +282,9 @@ search(const char *baseDN, const char *attrName, Slapi_Attr *attr,
 
 
 static int
-search_one_berval(const char *baseDN, const char *attrName,
+search_one_berval(Slapi_DN *baseDN, const char *attrName,
 		const struct berval *value, const char *requiredObjectClass,
-		const char *target, void *txn)
+		Slapi_DN *target, void *txn)
 {
 	int result;
     char *filter;
@@ -317,7 +317,7 @@ search_one_berval(const char *baseDN, const char *attrName,
       spb = slapi_pblock_new();
       if (!spb) { result = uid_op_error(2); break; }
 
-      slapi_search_internal_set_pb(spb, baseDN, LDAP_SCOPE_SUBTREE,
+      slapi_search_internal_set_pb_ext(spb, baseDN, LDAP_SCOPE_SUBTREE,
       	filter, attrs, 0 /* attrs only */, NULL, NULL, plugin_identity, 0 /* actions */);
       slapi_pblock_set(spb, SLAPI_TXN, txn);
       slapi_search_internal_pb(spb);
@@ -341,18 +341,16 @@ search_one_berval(const char *baseDN, const char *attrName,
        */
       for(;*entries;entries++)
       {
-        char *ndn = slapi_entry_get_ndn(*entries); /* get the normalized dn */
-
 #ifdef DEBUG
         slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name,
-          "SEARCH entry dn=%s\n", ndn);
+                        "SEARCH entry dn=%s\n", slapi_entry_get_dn(*entries));
 #endif
 
         /*
          * It is a Constraint Violation if any entry is found, unless
          * the entry is the target entry (if any).
          */
-        if (!target || strcmp(ndn, target) != 0)
+        if (!target || slapi_sdn_compare(slapi_entry_get_sdn(*entries), target) != 0)
         {
           result = LDAP_CONSTRAINT_VIOLATION;
           break;
@@ -395,7 +393,7 @@ search_one_berval(const char *baseDN, const char *attrName,
 static int
 searchAllSubtrees(int argc, char *argv[], const char *attrName,
   Slapi_Attr *attr, struct berval **values, const char *requiredObjectClass,
-  const char *dn, void *txn)
+  Slapi_DN *dn, void *txn)
 {
   int result = LDAP_SUCCESS;
 
@@ -405,13 +403,17 @@ searchAllSubtrees(int argc, char *argv[], const char *attrName,
    */
   for(;argc > 0;argc--,argv++)
   {
+    Slapi_DN *sufdn = slapi_sdn_new_dn_byref(*argv);
     /*
      * The DN should already be normalized, so we don't have to
      * worry about that here.
      */
-    if (slapi_dn_issuffix(dn, *argv)) {
-      result = search(*argv, attrName, attr, values, requiredObjectClass, dn, txn);
+    if (slapi_sdn_issuffix(dn, sufdn)) {
+      result = search(sufdn, attrName, attr, values, requiredObjectClass, dn, txn);
+      slapi_sdn_free(&sufdn);
       if (result) break;
+    } else {
+      slapi_sdn_free(&sufdn);
     }
   }
   return result;
@@ -498,27 +500,35 @@ getArguments(Slapi_PBlock *pb, char **attrName, char **markerObjectClass,
  *   LDAP_OPERATIONS_ERROR - a server failure.
  */
 static int
-findSubtreeAndSearch(char *parentDN, const char *attrName, Slapi_Attr *attr,
-  struct berval **values, const char *requiredObjectClass, const char *target,
+findSubtreeAndSearch(Slapi_DN *parentDN, const char *attrName, Slapi_Attr *attr,
+  struct berval **values, const char *requiredObjectClass, Slapi_DN *target,
   const char *markerObjectClass, void *txn)
 {
   int result = LDAP_SUCCESS;
   Slapi_PBlock *spb = NULL;
+  Slapi_DN *curpar = slapi_sdn_new();
+  Slapi_DN *newpar = NULL;
 
-  while (NULL != (parentDN = slapi_dn_parent(parentDN)))
+  slapi_sdn_get_parent(parentDN, curpar);
+  while ((curpar != NULL) && (slapi_sdn_get_dn(curpar) != NULL))
   {
-        if ((spb = dnHasObjectClass(parentDN, markerObjectClass, txn, plugin_identity)))
+        if ((spb = dnHasObjectClass(curpar, markerObjectClass, txn, plugin_identity)))
         {
           freePblock(spb);
           /*
            * Do the search.   There is no entry that is allowed
            * to have the attribute already.
            */
-          result = search(parentDN, attrName, attr, values, requiredObjectClass,
+          result = search(curpar, attrName, attr, values, requiredObjectClass,
                           target, txn);
           break;
         }
+        newpar = slapi_sdn_new();
+        slapi_sdn_copy(curpar, newpar);
+        slapi_sdn_get_parent(newpar, curpar);
+        slapi_sdn_free(&newpar);
   }
+  slapi_sdn_free(&curpar);
   return result;
 }
 
@@ -548,7 +558,6 @@ preop_add(Slapi_PBlock *pb)
     int err;
     char *markerObjectClass = NULL;
     char *requiredObjectClass = NULL;
-    const char *dn = NULL;
     Slapi_DN *sdn = NULL;
     int isupdatedn;
     Slapi_Entry *e;
@@ -596,10 +605,8 @@ preop_add(Slapi_PBlock *pb)
     err = slapi_pblock_get(pb, SLAPI_ADD_TARGET_SDN, &sdn);
     if (err) { result = uid_op_error(51); break; }
 
-    dn = slapi_sdn_get_dn(sdn);
-
 #ifdef DEBUG
-    slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name, "ADD target=%s\n", dn);
+    slapi_log_error(SLAPI_LOG_PLUGIN, plugin_name, "ADD target=%s\n", slapi_sdn_get_dn(sdn));
 #endif
 
        /*
@@ -632,14 +639,14 @@ preop_add(Slapi_PBlock *pb)
         if (NULL != markerObjectClass)
         {
           /* Subtree defined by location of marker object class */
-                result = findSubtreeAndSearch((char *)dn, attrName, attr, NULL,
-                                              requiredObjectClass, dn,
+                result = findSubtreeAndSearch(sdn, attrName, attr, NULL,
+                                              requiredObjectClass, sdn,
                                               markerObjectClass, txn);
         } else
         {
           /* Subtrees listed on invocation line */
           result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
-                                     requiredObjectClass, dn, txn);
+                                     requiredObjectClass, sdn, txn);
         }
   END
 
@@ -706,7 +713,6 @@ preop_modify(Slapi_PBlock *pb)
     int modcount = 0;
     int ii;
     LDAPMod *mod;
-    const char *dn = NULL;
     Slapi_DN *sdn = NULL;
     int isupdatedn;
     int argc;
@@ -780,12 +786,11 @@ preop_modify(Slapi_PBlock *pb)
     err = slapi_pblock_get(pb, SLAPI_MODIFY_TARGET_SDN, &sdn);
     if (err) { result = uid_op_error(11); break; }
 
-    dn = slapi_sdn_get_dn(sdn);
     /*
      * Check if it has the required object class
      */
     if (requiredObjectClass &&
-        !(spb = dnHasObjectClass(dn, requiredObjectClass, txn, plugin_identity))) {
+        !(spb = dnHasObjectClass(sdn, requiredObjectClass, txn, plugin_identity))) {
         break;
     }
 
@@ -803,14 +808,14 @@ preop_modify(Slapi_PBlock *pb)
         if (NULL != markerObjectClass)
         {
             /* Subtree defined by location of marker object class */
-            result = findSubtreeAndSearch((char *)dn, attrName, NULL, 
+            result = findSubtreeAndSearch(sdn, attrName, NULL, 
                                           mod->mod_bvalues, requiredObjectClass,
-                                          dn, markerObjectClass, txn);
+                                          sdn, markerObjectClass, txn);
         } else
         {
             /* Subtrees listed on invocation line */
             result = searchAllSubtrees(argc, argv, attrName, NULL,
-                                       mod->mod_bvalues, requiredObjectClass, dn, txn);
+                                       mod->mod_bvalues, requiredObjectClass, sdn, txn);
         }
     }
   END
@@ -953,7 +958,7 @@ preop_modrdn(Slapi_PBlock *pb)
     }
 
     /* Apply the rename operation to the dummy entry. */
-    err = slapi_entry_rename(e, rdn, deloldrdn, slapi_sdn_get_dn(superior));
+    err = slapi_entry_rename(e, rdn, deloldrdn, superior);
     if (err != LDAP_SUCCESS) { result = uid_op_error(36); break; }
 
         /*
@@ -976,14 +981,14 @@ preop_modrdn(Slapi_PBlock *pb)
         if (NULL != markerObjectClass)
         {
           /* Subtree defined by location of marker object class */
-                result = findSubtreeAndSearch(slapi_entry_get_dn(e), attrName, attr, NULL,
-                                              requiredObjectClass, dn,
+                result = findSubtreeAndSearch(slapi_entry_get_sdn(e), attrName, attr, NULL,
+                                              requiredObjectClass, sdn,
                                               markerObjectClass, txn);
         } else
         {
           /* Subtrees listed on invocation line */
           result = searchAllSubtrees(argc, argv, attrName, attr, NULL,
-                                     requiredObjectClass, dn, txn);
+                                     requiredObjectClass, sdn, txn);
         }
   END
   /* Clean-up */
diff --git a/ldap/servers/plugins/uiduniq/utils.c b/ldap/servers/plugins/uiduniq/utils.c
index 567218a..8e9c6ca 100644
--- a/ldap/servers/plugins/uiduniq/utils.c
+++ b/ldap/servers/plugins/uiduniq/utils.c
@@ -81,7 +81,7 @@ op_error(int internal_error) {
  *   A pblock containing the entry, or NULL
  */
 Slapi_PBlock *
-readPblockAndEntry( const char *baseDN, const char *filter,
+readPblockAndEntry( Slapi_DN *baseDN, const char *filter,
 					char *attrs[], void *txn, void *pluginid ) {
 	Slapi_PBlock *spb = NULL;
 
@@ -93,9 +93,9 @@ readPblockAndEntry( const char *baseDN, const char *filter,
 			op_error(20);
 			break;
 		}
-		slapi_search_internal_set_pb (spb, baseDN, LDAP_SCOPE_BASE, filter,
-									  attrs, 0, NULL, 
-									  NULL, pluginid, 0); 
+		slapi_search_internal_set_pb_ext (spb, baseDN, LDAP_SCOPE_BASE, filter,
+										  attrs, 0, NULL, 
+										  NULL, pluginid, 0); 
 		slapi_pblock_set(spb, SLAPI_TXN, txn);
 		slapi_search_internal_pb (spb);
  
@@ -153,7 +153,7 @@ entryHasObjectClass(Slapi_PBlock *pb, Slapi_Entry *e,
  *   A pblock containing the entry, or NULL
  */
 Slapi_PBlock *
-dnHasObjectClass( const char *baseDN, const char *objectClass, void *txn, void *pluginid ) {
+dnHasObjectClass( Slapi_DN *baseDN, const char *objectClass, void *txn, void *pluginid ) {
 	char *filter = NULL;
 	Slapi_PBlock *spb = NULL;
 
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 46309eb..69fee1d 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1381,10 +1381,6 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
     
     inst = (ldbm_instance *) be->be_instance_info;
 
-    if (NULL == basesdn) {
-        basesdn = slapi_sdn_new_normdn_byref(base);
-        slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, basesdn);
-    }
     /* Return to the cache the entry we handed out last time */
     /* If we are using the extension, the front end will tell
      * us when to do this so we don't do it now */
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index a292b87..08b9066 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3156,16 +3156,16 @@ slapi_entry_has_children(const Slapi_Entry *entry)
  * Renames an entry to simulate a MODRDN operation
  */
 int
-slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const char *newsuperior)
+slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, Slapi_DN *newsuperior)
 {
     int err = LDAP_SUCCESS;
-    char *newdn = NULL;
-    char *olddn = NULL;
-    Slapi_RDN *oldrdn = NULL;
+    Slapi_DN *olddn = NULL;
     Slapi_Mods *smods = NULL;
+    Slapi_DN newsrdn;
 
     LDAPDebug( LDAP_DEBUG_TRACE, "=> slapi_entry_rename\n", 0, 0, 0 );
 
+    slapi_sdn_init(&newsrdn);
     /* Check if entry or newrdn are NULL. */
     if (!e || !newrdn) {
         err = LDAP_PARAM_ERROR;
@@ -3173,7 +3173,7 @@ slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const c
     }
 
     /* Get the old DN. */
-    olddn = slapi_entry_get_dn(e);
+    olddn = slapi_entry_get_sdn(e);
 
     /* If deleteoldrdn, find old RDN values and remove them from the entry. */
     if (deleteoldrdn) {
@@ -3181,8 +3181,7 @@ slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const c
         char * val = NULL;
         int num_rdns = 0;
         int i = 0;
-
-        oldrdn = slapi_rdn_new_dn(olddn);
+        Slapi_RDN *oldrdn = slapi_rdn_new_sdn(olddn);
 
         /* Create mods based on the number of rdn elements. */
         num_rdns = slapi_rdn_get_num_components(oldrdn);
@@ -3195,6 +3194,7 @@ slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const c
                 slapi_mods_add(smods, LDAP_MOD_DELETE, type, strlen(val), val);
             }
         }
+        slapi_rdn_free(&oldrdn);
 
         /* Apply the mods to the entry. */
         if ((err = slapi_entry_apply_mods(e, slapi_mods_get_ldapmods_byref(smods))) != LDAP_SUCCESS) {
@@ -3210,29 +3210,32 @@ slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const c
 
     /* Build new DN.  If newsuperior is set, just use "newrdn,newsuperior".  If
      * newsuperior is not set, need to add newrdn to old superior. */
+    slapi_sdn_init_dn_byref(&newsrdn, newrdn);
     if (newsuperior) {
-        newdn = slapi_create_dn_string("%s,%s", newrdn, newsuperior);
+        slapi_sdn_set_parent(&newsrdn, newsuperior);
     } else {
-        char *oldsuperior = NULL;
-
-        oldsuperior = slapi_dn_parent(olddn);
-        newdn = slapi_create_dn_string("%s,%s", newrdn, oldsuperior);
+        Slapi_DN oldparent;
 
-        slapi_ch_free_string(&oldsuperior);
+        slapi_sdn_init(&oldparent);
+        slapi_sdn_get_parent(olddn, &oldparent);
+        slapi_sdn_set_parent(&newsrdn, &oldparent);
+        slapi_sdn_done(&oldparent);
     }
 
     /* Set the new DN in the entry.  This hands off the memory used by newdn to the entry. */
-    slapi_entry_set_normdn(e, newdn);
+    slapi_entry_set_sdn(e, &newsrdn);
 
     /* Set the RDN in the entry. */
-    slapi_entry_set_rdn(e, newdn);
+    /* note - there isn't a slapi_entry_set_rdn_from_sdn function */
+    slapi_rdn_done(slapi_entry_get_srdn(e));
+    slapi_rdn_init_all_sdn(slapi_entry_get_srdn(e),&newsrdn);
 
     /* Add RDN values to entry. */
     err = slapi_entry_add_rdn_values(e);
 
 done:
-    slapi_rdn_free(&oldrdn);
     slapi_mods_free(&smods);
+    slapi_sdn_done(&newsrdn);
 
     LDAPDebug( LDAP_DEBUG_TRACE, "<= slapi_entry_rename\n", 0, 0, 0 );
     return err;
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index ff17cd9..dffc2a5 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -229,6 +229,8 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
   Slapi_Backend *pr_be = NULL;
   void *pr_search_result = NULL;
   int pr_reset_processing = 0;
+  Slapi_DN *orig_sdn = NULL;
+  int free_sdn = 0;
 
   be_list[0] = NULL;
   referral_list[0] = NULL;
@@ -240,6 +242,11 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
   if (NULL == sdn) {
     sdn = slapi_sdn_new_dn_byval(base);
     slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, sdn);
+    free_sdn = 1;
+  } else {
+    /* save it so we can restore it later - may have to replace it internally
+       e.g. for onelevel and subtree searches, but need to restore it */
+    orig_sdn = sdn; 
   }
   normbase = slapi_sdn_get_dn(sdn);
 
@@ -674,10 +681,13 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
             int tmp_scope = LDAP_SCOPE_BASE;
             slapi_pblock_set(pb, SLAPI_SEARCH_SCOPE, &tmp_scope);
 
-            slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
-            slapi_sdn_free(&sdn);
+            if (free_sdn) {
+              slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
+              slapi_sdn_free(&sdn);
+            }
             sdn = slapi_sdn_dup(be_suffix);
             slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, (void *)sdn);
+            free_sdn = 1;
           }
           else if (slapi_sdn_issuffix(basesdn, be_suffix))
           {
@@ -698,10 +708,13 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
         {
           if (slapi_sdn_issuffix(be_suffix, basesdn))
           {
-            slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
-            slapi_sdn_free(&sdn);
+            if (free_sdn) {
+              slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
+              slapi_sdn_free(&sdn);
+            }
             sdn = slapi_sdn_dup(be_suffix);
             slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, (void *)sdn);
+            free_sdn = 1;
           }
         }
       }
@@ -917,11 +930,13 @@ free_and_return:
 free_and_return_nolock:
   slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &rc);
   index_subsys_filter_decoders_done(pb);
-  
-  slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
-  slapi_sdn_free(&sdn);
+
+  if (free_sdn) {
+    slapi_pblock_get(pb, SLAPI_SEARCH_TARGET_SDN, &sdn);
+    slapi_sdn_free(&sdn);
+  }
   slapi_sdn_free(&basesdn);
-  slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, NULL);
+  slapi_pblock_set(pb, SLAPI_SEARCH_TARGET_SDN, orig_sdn);
 
   slapi_ch_free_string(&proxydn);
   slapi_ch_free_string(&proxystr);
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 36683a4..1b1ed95 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -2060,7 +2060,7 @@ int slapi_entry_apply_mod(Slapi_Entry *e, LDAPMod *mod);
  * \return \c LDAP_SUCCESS if the rename was successful, otherwise an LDAP error
  *         is returned.
  */
-int slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, const char *newsuperior);
+int slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, Slapi_DN *newsuperior);
 
 
 /*------------------------


commit db69b14ace1c47db8e33dc2725f53b3fe72686c6
Author: Rich Megginson <rmeggins at redhat.com>
Date:   Mon Jul 9 15:24:25 2012 -0600

    Ticket #405 - referint modrdn not working if case is different
    
    https://fedorahosted.org/389/ticket/405
    Resolves: Ticket #405
    Bug Description: referint modrdn not working if case is different
    Reviewed by: nhosoi (Thanks!)
    Branch: 389-ds-base-1.2.10
    Fix Description: Pass the Slapi_DN to _update_all_per_mod() and
    _update_one_per_mod().  Use the case normalized dn (ndn) to compare against
    the case normalized member value.
    Platforms tested: RHEL6 x86_64
    Flag Day: no
    Doc impact: no
    (cherry picked from commit 8ef08f85fb29ffe4c17ed900378882e8eb127bc4)
    (cherry picked from commit 6ba24ebaa9d3ee50b025f4e3dacad04a07f0c6f8)

diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 4db5d6d..3c973d3 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -355,7 +355,7 @@ static int
 _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
                     Slapi_Attr *attr,        /* referred attribute */
                     char *attrName,
-                    const char *origDN,      /* original DN that was modified */
+                    Slapi_DN *origDN,        /* original DN that was modified */
                     char *newRDN,            /* new RDN from modrdn */
                     const char *newsuperior, /* new superior from modrdn */
                     Slapi_PBlock *mod_pb, void *txn)
@@ -373,7 +373,7 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
     if (NULL == newRDN && NULL == newsuperior) {
         /* in delete mode */
         /* delete old dn so set that up */
-        values_del[0] = (char *)origDN;
+        values_del[0] = (char *)slapi_sdn_get_dn(origDN);
         values_del[1] = NULL;
         attribute1.mod_type = attrName;
         attribute1.mod_op = LDAP_MOD_DELETE;
@@ -385,7 +385,7 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
         if (rc) {
             slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
                 "_update_one_value: entry %s: deleting \"%s: %s\" failed (%d)"
-                "\n", slapi_sdn_get_dn(entrySDN), attrName, origDN, rc);
+                "\n", slapi_sdn_get_dn(entrySDN), attrName, slapi_sdn_get_dn(origDN), rc);
         }
     } else {
         /* in modrdn mode */
@@ -399,11 +399,11 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
             goto bail;
         }
         /* need to put together rdn into a dn */
-        dnParts = slapi_ldap_explode_dn( origDN, 0 );
+        dnParts = slapi_ldap_explode_dn( slapi_sdn_get_dn(origDN), 0 );
         if (NULL == dnParts) {
             slapi_log_error(SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
                             "_update_one_value: failed to explode dn %s\n",
-                            origDN);
+                            slapi_sdn_get_dn(origDN));
             goto bail;
         }
         if (NULL == newRDN) {
@@ -412,8 +412,8 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
         if (newsuperior) {
             superior = newsuperior;
         } else {
-            /* no need to free superior */
-            superior = slapi_dn_find_parent(origDN);
+            /* do not free superior */
+            superior = slapi_dn_find_parent(slapi_sdn_get_dn(origDN));
         }
         /* newRDN and superior are already normalized. */
         newDN = slapi_ch_smprintf("%s,%s", newRDN, superior);
@@ -454,7 +454,7 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
             }
             /* else: (rc < 0) Ignore the DN normalization error for now. */
 
-            p = PL_strstr(sval, origDN);
+            p = PL_strstr(sval, slapi_sdn_get_ndn(origDN));
             if (p == sval) {
                 /* (case 1) */
                 values_del[0] = sval;
@@ -477,7 +477,7 @@ _update_one_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
                         "_update_one_value: entry %s: replacing \"%s: %s\" "
                         "with \"%s: %s\" failed (%d)\n",
                         slapi_sdn_get_dn(entrySDN), attrName, 
-                        origDN, attrName, newDN, rc);
+                        slapi_sdn_get_dn(origDN), attrName, newDN, rc);
                 }
             } else if (p) {
                 char bak;
@@ -532,7 +532,7 @@ static int
 _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
                     Slapi_Attr *attr,        /* referred attribute */
                     char *attrName,
-                    const char *origDN,      /* original DN that was modified */
+                    Slapi_DN *origDN,        /* original DN that was modified */
                     char *newRDN,            /* new RDN from modrdn */
                     const char *newsuperior, /* new superior from modrdn */
                     Slapi_PBlock *mod_pb, void *txn)
@@ -554,7 +554,7 @@ _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
         LDAPMod attribute1;
 
         /* delete old dn so set that up */
-        values_del[0] = (char *)origDN;
+        values_del[0] = (char *)slapi_sdn_get_dn(origDN);
         values_del[1] = NULL;
         attribute1.mod_type = attrName;
         attribute1.mod_op = LDAP_MOD_DELETE;
@@ -566,7 +566,7 @@ _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
         if (rc) {
             slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
                 "_update_all_per_mod: entry %s: deleting \"%s: %s\" failed (%d)"
-                "\n", slapi_sdn_get_dn(entrySDN), attrName, origDN, rc);
+                "\n", slapi_sdn_get_dn(entrySDN), attrName, slapi_sdn_get_dn(origDN), rc);
         }
     } else {
         /* in modrdn mode */
@@ -580,11 +580,11 @@ _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
             goto bail;
         }
         /* need to put together rdn into a dn */
-        dnParts = slapi_ldap_explode_dn( origDN, 0 );
+        dnParts = slapi_ldap_explode_dn( slapi_sdn_get_dn(origDN), 0 );
         if (NULL == dnParts) {
             slapi_log_error(SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
                             "_update_all_per_mod: failed to explode dn %s\n",
-                            origDN);
+                            slapi_sdn_get_dn(origDN));
             goto bail;
         }
         if (NULL == newRDN) {
@@ -593,8 +593,8 @@ _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
         if (newsuperior) {
             superior = newsuperior;
         } else {
-            /* no need to free superior */
-            superior = slapi_dn_find_parent(origDN);
+            /* do not free superior */
+            superior = slapi_dn_find_parent(slapi_sdn_get_dn(origDN));
         }
         /* newRDN and superior are already normalized. */
         newDN = slapi_ch_smprintf("%s,%s", newRDN, superior);
@@ -639,7 +639,7 @@ _update_all_per_mod(Slapi_DN *entrySDN,      /* DN of the searched entry */
             }
             /* else: (rc < 0) Ignore the DN normalization error for now. */
 
-            p = PL_strstr(sval, origDN);
+            p = PL_strstr(sval, slapi_sdn_get_ndn(origDN));
             if (p == sval) {
                 /* (case 1) */
                 slapi_mods_add_string(smods, LDAP_MOD_DELETE, attrName, sval);
@@ -774,13 +774,13 @@ update_integrity(char **argv, Slapi_DN *origSDN,
                                 if (nval > 128) {
                                     rc = _update_one_per_mod(
                                          slapi_entry_get_sdn(search_entries[j]),
-                                         attr, attrName, origDN, newrDN, 
+                                         attr, attrName, origSDN, newrDN, 
                                          slapi_sdn_get_dn(newsuperior),
                                          mod_pb, txn);
                                 } else {
                                     rc = _update_all_per_mod(
                                          slapi_entry_get_sdn(search_entries[j]),
-                                         attr, attrName, origDN, newrDN, 
+                                         attr, attrName, origSDN, newrDN, 
                                          slapi_sdn_get_dn(newsuperior),
                                          mod_pb, txn);
                                 }




More information about the 389-commits mailing list