amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone

Blame SOURCES/0011-Ticket-49967-entry-cache-corruption-after-failed-MOD.patch

fb6657
From a7ee52bd4b0bce82402a581ee16659ebb2f8d96e Mon Sep 17 00:00:00 2001
fb6657
From: Thierry Bordaz <tbordaz@redhat.com>
fb6657
Date: Wed, 24 Oct 2018 15:31:25 +0200
fb6657
Subject: [PATCH 1/2] Ticket 49967 - entry cache corruption after failed MODRDN
fb6657
fb6657
Bug Description:
fb6657
	During a MODRDN the DN cache is updated to replace
fb6657
	source DN with the target DN (modrdn_rename_entry_update_indexes)
fb6657
	If later a failure occurs (for example if BETXN_POSTOP fails) and
fb6657
	the txn is aborted, the target DN (for the specific entryID) remains
fb6657
	in the DN cache.
fb6657
fb6657
	If the entry is returned in a search, to build the DN there is
fb6657
	a lookup of the DN cache with the entryID. It retrieves the target DN
fb6657
	rather than the source DN
fb6657
fb6657
Fix Description:
fb6657
	In case of failure of the operation, the entry (from the entryID)
fb6657
	need to be cleared from the DN cache
fb6657
fb6657
https://pagure.io/389-ds-base/issue/49967
fb6657
fb6657
Reviewed by: Mark Reynolds
fb6657
fb6657
Platforms tested: F27
fb6657
fb6657
Flag Day: no
fb6657
fb6657
Doc impact: no
fb6657
fb6657
(cherry picked from commit ab4af68ef49fcdc5f2f6d0c1f5c7b9a5333b1bee)
fb6657
---
fb6657
 ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 13 +++++++++++++
fb6657
 1 file changed, 13 insertions(+)
fb6657
fb6657
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
fb6657
index 71e2a8fe0..e2e9d1b46 100644
fb6657
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
fb6657
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
fb6657
@@ -1400,6 +1400,19 @@ common_return:
fb6657
                 }
fb6657
             }
fb6657
         }
fb6657
+
fb6657
+        if (ec && retval) {
fb6657
+            /* if the operation failed, the destination entry does not exist
fb6657
+             * but it has been added in dncache during cache_add_tentative
fb6657
+             * we need to remove it. Else a retrieval from ep_id can give the wrong DN
fb6657
+             */
fb6657
+            struct backdn *bdn = dncache_find_id(&inst->inst_dncache, ec->ep_id);
fb6657
+            slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_modrdn",
fb6657
+                                      "operation failed, the target entry is cleared from dncache (%s)\n", slapi_entry_get_dn(ec->ep_entry));
fb6657
+            CACHE_REMOVE(&inst->inst_dncache, bdn);
fb6657
+            CACHE_RETURN(&inst->inst_dncache, &bdn;;
fb6657
+        }
fb6657
+
fb6657
         /* remove the new entry from the cache if the op failed -
fb6657
            otherwise, leave it in */
fb6657
         if (ec && inst) {
fb6657
-- 
fb6657
2.17.2
fb6657