Blame SOURCES/0020-Ticket-47897-Need-to-move-slapi_pblock_set-pb-SLAPI_.patch

f92ce9
From afe5e1ac7306fd5024dcb6550dce3b0c722cbe31 Mon Sep 17 00:00:00 2001
f92ce9
From: Noriko Hosoi <nhosoi@redhat.com>
f92ce9
Date: Wed, 8 Oct 2014 10:38:02 -0700
f92ce9
Subject: [PATCH 20/21] Ticket #47897 - Need to move slapi_pblock_set(pb,
f92ce9
 SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry) prior to
f92ce9
 original_entry overwritten
f92ce9
f92ce9
Bug Description: In the DEADLOCK retry code in ldbm_back_modrdn,
f92ce9
SLAPI_MODRDN_EXISTING_ENTRY in pblock is reset with the new entry
f92ce9
to be renamed.  The location of the setting entry was inappropriate,
f92ce9
thus instead of the entry, but its backup is set in pblock.
f92ce9
f92ce9
Fix Description: Moving the slapi_pblock_set(SLAPI_MODRDN_EXISTING_
f92ce9
ENTRY) to the correct position.
f92ce9
f92ce9
Plus, in the DEADLOCK retry code, original_entry is duplicated and
f92ce9
used for the next loop.  The source of the duplication has to be
f92ce9
the clean entry before updated in the backend code, but in ldbm_add,
f92ce9
ldbm_modify, and ldbm_modrdn, the current entry was duplicated and
f92ce9
set to the original entry, which could have been updated in the
f92ce9
previous loop.  This patch fixes it, as well.
f92ce9
f92ce9
https://fedorahosted.org/389/ticket/47897
f92ce9
f92ce9
Reviewed by tbordaz@redhat.com (Thank you, Theirry!!)
f92ce9
f92ce9
(cherry picked from commit 2aabb017bd4eec6d30bf00486eb027f59129cf74)
f92ce9
(cherry picked from commit 2393a48021944230f5ebcf5363c0095b1c4679ab)
f92ce9
---
f92ce9
 ldap/servers/slapd/back-ldbm/ldbm_add.c    | 2 +-
f92ce9
 ldap/servers/slapd/back-ldbm/ldbm_modify.c | 2 +-
f92ce9
 ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 4 ++--
f92ce9
 3 files changed, 4 insertions(+), 4 deletions(-)
f92ce9
f92ce9
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
f92ce9
index b74154a..75cb0dc 100644
f92ce9
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
f92ce9
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
f92ce9
@@ -225,7 +225,7 @@ ldbm_back_add( Slapi_PBlock *pb )
f92ce9
 			slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
f92ce9
 			/* must duplicate addingentry before returning it to cache,
f92ce9
 			 * which could free the entry. */
f92ce9
-			if ( (tmpentry = backentry_dup( addingentry )) == NULL ) {
f92ce9
+			if ((tmpentry = backentry_dup(originalentry?originalentry:addingentry)) == NULL) {
f92ce9
 				ldap_result_code= LDAP_OPERATIONS_ERROR;
f92ce9
 				goto error_return;
f92ce9
 			}
f92ce9
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
f92ce9
index d15b050..b9f754d 100644
f92ce9
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
f92ce9
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
f92ce9
@@ -521,7 +521,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
f92ce9
 			if (ec) {
f92ce9
 				/* must duplicate ec before returning it to cache,
f92ce9
 				 * which could free the entry. */
f92ce9
-				if ( (tmpentry = backentry_dup( ec )) == NULL ) {
f92ce9
+				if ((tmpentry = backentry_dup(original_entry?original_entry:ec)) == NULL) {
f92ce9
 					ldap_result_code= LDAP_OPERATIONS_ERROR;
f92ce9
 					goto error_return;
f92ce9
 				}
f92ce9
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
f92ce9
index 7bcbcee..6a4982c 100644
f92ce9
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
f92ce9
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
f92ce9
@@ -275,7 +275,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
f92ce9
             orig_dn_newsuperiordn = slapi_sdn_dup(orig_dn_newsuperiordn);
f92ce9
             /* must duplicate ec before returning it to cache,
f92ce9
              * which could free the entry. */
f92ce9
-            if ( (tmpentry = backentry_dup( ec )) == NULL ) {
f92ce9
+            if ((tmpentry = backentry_dup(original_entry?original_entry:ec)) == NULL) {
f92ce9
                 ldap_result_code= LDAP_OPERATIONS_ERROR;
f92ce9
                 goto error_return;
f92ce9
             }
f92ce9
@@ -295,10 +295,10 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
f92ce9
                 slapi_entry_free(ent);
f92ce9
                 slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, NULL );
f92ce9
             }
f92ce9
+            slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
f92ce9
             ec = original_entry;
f92ce9
             original_entry = tmpentry;
f92ce9
             tmpentry = NULL;
f92ce9
-            slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
f92ce9
             free_modrdn_existing_entry = 0; /* owned by original_entry now */
f92ce9
             if (!cache_is_in_cache(&inst->inst_cache, ec)) {
f92ce9
                 /* Put the resetted entry 'ec' into the cache again. */
f92ce9
-- 
f92ce9
1.9.3
f92ce9