From b51abe54eee99cdc90e70741aabf1d31d027d8f9 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: May 05 2012 14:22:39 +0000 Subject: Ticket #358 - managed entry doesn't delete linked entry https://fedorahosted.org/389/ticket/358 Resolves: Ticket #358 Bug Description: managed entry doesn't delete linked entry Reviewed by: nhosoi (Thanks!) Branch: master Fix Description: SLAPI_DELETE_BEPREOP_ENTRY is the same as SLAPI_ENTRY_PRE_OP they are the same field in the pblock. We have to be very careful to only set SLAPI_DELETE_BEPREOP_ENTRY for those plugins which absolutely need to use it, and be careful to reset it after use. We must not overwrite the SLAPI_ENTRY_PRE_OP which is needed by postoperation plugins. Platforms tested: RHEL6 x86_64, Fedora 17 Flag Day: no Doc impact: no (cherry picked from commit 314ea64024def55b2d900f306ea7de30a00a70c5) --- diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index 569ad0b..57a4605 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -106,7 +106,6 @@ ldbm_back_delete( Slapi_PBlock *pb ) slapi_pblock_get( pb, SLAPI_TXN, (void**)&parent_txn ); slapi_pblock_get( pb, SLAPI_OPERATION, &operation ); slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation ); - slapi_pblock_get( pb, SLAPI_DELETE_BEPREOP_ENTRY, &orig_entry ); /* sdn needs to be initialized before "goto *_return */ slapi_sdn_init(&sdn); @@ -216,9 +215,6 @@ ldbm_back_delete( Slapi_PBlock *pb ) } slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ldap_result_code); - /* set entry in case be-preop plugins need to work on it (e.g., USN) */ - slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, e->ep_entry ); - rc = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN); if (rc == -1) { @@ -503,6 +499,7 @@ ldbm_back_delete( Slapi_PBlock *pb ) /* call the transaction pre delete plugins just after creating * the transaction */ + slapi_pblock_get( pb, SLAPI_DELETE_BEPREOP_ENTRY, &orig_entry ); slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, e->ep_entry ); retval = plugin_call_plugins(pb, SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN); if (retval) { @@ -522,10 +519,13 @@ ldbm_back_delete( Slapi_PBlock *pb ) } goto error_return; } + slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, orig_entry ); + orig_entry = NULL; if(create_tombstone_entry) { + slapi_pblock_get( pb, SLAPI_DELETE_BEPREOP_ENTRY, &orig_entry ); slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, tombstone->ep_entry ); rc = plugin_call_plugins(pb, @@ -549,6 +549,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) /* retval is -1 */ goto error_return; } + slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, orig_entry ); + orig_entry = NULL; /* * The entry is not removed from the disk when we tombstone an @@ -1097,7 +1099,12 @@ error_return: } common_return: - slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, orig_entry ); + if (orig_entry) { + /* NOTE: #define SLAPI_DELETE_BEPREOP_ENTRY SLAPI_ENTRY_PRE_OP */ + /* so if orig_entry is NULL, we will wipe out SLAPI_ENTRY_PRE_OP + for the post op plugins */ + slapi_pblock_set( pb, SLAPI_DELETE_BEPREOP_ENTRY, orig_entry ); + } if (tombstone_in_cache) { CACHE_RETURN( &inst->inst_cache, &tombstone );