andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 702f9f9f036bdef2535fcce4ea108b2d9ce09a19 Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Fri, 13 Mar 2015 17:56:43 -0700
dc8c34
Subject: [PATCH 307/308] Ticket #48133 - Non tombstone entry which dn starting
dc8c34
 with "nsuniqueid=...," cannot be deleted
dc8c34
dc8c34
Bug Description: Trying to delete an entry which DN starts with
dc8c34
"nsuniqueid=...," but no objectclass=nsTombstone fails with
dc8c34
"Turning a tombstone into a tombstone!", which is indeed not.
dc8c34
dc8c34
Fix Description: This patch checks the entry and if it does not
dc8c34
have "objectclass=nsTombstone", the entry is not treated as a
dc8c34
tombstone.  Also, if the DN already has the entry's nsuniqueid
dc8c34
at the beginning, it does not get appended to avoid the duplicate.
dc8c34
dc8c34
Note: Adding an entry which DN starts with "nsuniqueid" and no
dc8c34
nsTombstone objectclass fails since such an entry is rejected in
dc8c34
check_rdn_for_created_attrs called from do_add.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/48133
dc8c34
(cherry picked from commit 3579393628d9f256613e20d4b1ec248ea3feee2e)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/ldbm_delete.c | 19 +++++++++++++++++--
dc8c34
 1 file changed, 17 insertions(+), 2 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
index 48058d6..a03915c 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
@@ -454,13 +454,28 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 		char *tombstone_dn;
dc8c34
 		Slapi_Value *tomb_value;
dc8c34
 
dc8c34
-		if (slapi_is_special_rdn(edn, RDN_IS_TOMBSTONE)) {
dc8c34
+		if (slapi_entry_attr_hasvalue(e->ep_entry, SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE) &&
dc8c34
+		    slapi_is_special_rdn(edn, RDN_IS_TOMBSTONE)) {
dc8c34
 			LDAPDebug1Arg(LDAP_DEBUG_ANY, "Turning a tombstone into a tombstone! \"%s\"\n", edn);
dc8c34
 			ldap_result_code= LDAP_OPERATIONS_ERROR;
dc8c34
 			retval = -1;
dc8c34
 			goto error_return;
dc8c34
 		}
dc8c34
-		tombstone_dn = compute_entry_tombstone_dn(edn, childuniqueid);
dc8c34
+		if (!childuniqueid) {
dc8c34
+			slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete",
dc8c34
+			                "No nsUniqueId in the entry \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n", 
dc8c34
+			                edn, e, e->ep_state, e->ep_refcnt);
dc8c34
+			ldap_result_code = LDAP_OPERATIONS_ERROR;
dc8c34
+			retval = -1;
dc8c34
+			goto error_return;
dc8c34
+		}
dc8c34
+		if ((0 == PL_strncmp(edn + sizeof(SLAPI_ATTR_UNIQUEID), childuniqueid, strlen(childuniqueid))) &&
dc8c34
+			(*(edn + SLAPI_ATTR_UNIQUEID_LENGTH + slapi_uniqueIDSize() + 1/*=*/) == ',')) {
dc8c34
+			/* The DN already starts with "nsuniqueid=...," */
dc8c34
+			tombstone_dn = slapi_ch_strdup(edn);
dc8c34
+		} else {
dc8c34
+			tombstone_dn = compute_entry_tombstone_dn(edn, childuniqueid);
dc8c34
+		}
dc8c34
 
dc8c34
 		slapi_sdn_set_ndn_byval(&nscpEntrySDN, slapi_sdn_get_ndn(slapi_entry_get_sdn(e->ep_entry)));
dc8c34
 
dc8c34
-- 
dc8c34
1.9.3
dc8c34