mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 08:09:34 -05:00
Disable removal of subtree indices upon delete. This allows
modrdn to run, but masks the underlying subtree index bug (which I haven't found yet). Apply modrdn/dn2id changes to BDB2.
This commit is contained in:
parent
4c19272651
commit
03ea068193
7 changed files with 80 additions and 32 deletions
|
|
@ -243,7 +243,7 @@ bdb2i_back_add_internal(
|
|||
if ( bdb2i_id2entry_add( be, e ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0,
|
||||
0, 0 );
|
||||
(void) bdb2i_dn2id_delete( be, e->e_ndn );
|
||||
(void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, NULL, NULL, NULL );
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ bdb2i_back_delete_internal(
|
|||
}
|
||||
|
||||
/* delete from dn2id mapping */
|
||||
if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) {
|
||||
if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
|
||||
Debug(LDAP_DEBUG_ARGS,
|
||||
"<=- bdb2i_back_delete: operations error %s\n",
|
||||
dn, 0, 0);
|
||||
|
|
|
|||
|
|
@ -178,14 +178,16 @@ bdb2i_dn2idl(
|
|||
int
|
||||
bdb2i_dn2id_delete(
|
||||
BackendDB *be,
|
||||
const char *dn
|
||||
const char *dn,
|
||||
ID id
|
||||
)
|
||||
{
|
||||
struct dbcache *db;
|
||||
Datum key;
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\" )\n", dn, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb2i_dn2id_delete( \"%s\", %ld )\n",
|
||||
dn, id, 0 );
|
||||
|
||||
if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_WRCREAT ))
|
||||
== NULL ) {
|
||||
|
|
@ -195,6 +197,42 @@ bdb2i_dn2id_delete(
|
|||
return( -1 );
|
||||
}
|
||||
|
||||
{
|
||||
char *pdn = dn_parent( NULL, dn );
|
||||
|
||||
if( pdn != NULL ) {
|
||||
ldbm_datum_init( key );
|
||||
key.dsize = strlen( pdn ) + 2;
|
||||
key.dptr = ch_malloc( key.dsize );
|
||||
sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
|
||||
(void) bdb2i_idl_delete_key( be, db, key, id );
|
||||
free( key.dptr );
|
||||
free( pdn );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
char **subtree = dn_subtree( NULL, dn );
|
||||
|
||||
if( subtree != NULL ) {
|
||||
int i;
|
||||
for( i=0; subtree[i] != NULL; i++ ) {
|
||||
ldbm_datum_init( key );
|
||||
key.dsize = strlen( subtree[i] ) + 2;
|
||||
key.dptr = ch_malloc( key.dsize );
|
||||
sprintf( key.dptr, "%c%s", DN_SUBTREE_PREFIX, subtree[i] );
|
||||
|
||||
(void) bdb2i_idl_delete_key( be, db, key, id );
|
||||
|
||||
free( key.dptr );
|
||||
}
|
||||
|
||||
charray_free( subtree );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ldbm_datum_init( key );
|
||||
|
||||
key.dsize = strlen( dn ) + 2;
|
||||
|
|
|
|||
|
|
@ -225,12 +225,6 @@ bdb2i_back_modrdn_internal(
|
|||
Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new ndn=%s\n",
|
||||
new_ndn, 0, 0 );
|
||||
|
||||
if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
|
||||
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* check for abandon */
|
||||
ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
|
||||
if ( op->o_abandon ) {
|
||||
|
|
@ -239,23 +233,8 @@ bdb2i_back_modrdn_internal(
|
|||
}
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
/* delete old one */
|
||||
if ( bdb2i_dn2id_delete( be, e->e_ndn ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
(void) bdb2i_cache_delete_entry( &li->li_cache, e );
|
||||
free( e->e_dn );
|
||||
free( e->e_ndn );
|
||||
e->e_dn = new_dn;
|
||||
e->e_ndn = new_ndn;
|
||||
|
||||
|
||||
/* add new one */
|
||||
if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
if ( (bdb2i_dn2id ( be, new_ndn ) ) != NOID ) {
|
||||
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
|
@ -401,6 +380,37 @@ bdb2i_back_modrdn_internal(
|
|||
}
|
||||
#endif
|
||||
|
||||
/* check for abandon */
|
||||
ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
|
||||
if ( op->o_abandon ) {
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
|
||||
goto return_results;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
|
||||
|
||||
/* delete old one */
|
||||
if ( bdb2i_dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
(void) bdb2i_cache_delete_entry( &li->li_cache, e );
|
||||
|
||||
free( e->e_dn );
|
||||
free( e->e_ndn );
|
||||
e->e_dn = new_dn;
|
||||
e->e_ndn = new_ndn;
|
||||
new_dn = NULL;
|
||||
new_ndn = NULL;
|
||||
|
||||
/* add new one */
|
||||
if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
/* modify memory copy of entry */
|
||||
if ( bdb2i_back_modify_internal( be, conn, op, dn, &mod[0], e )
|
||||
!= 0 ) {
|
||||
|
|
@ -420,19 +430,17 @@ bdb2i_back_modrdn_internal(
|
|||
entry_free( e );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, NULL, NULL, NULL );
|
||||
goto return_results_after;
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
send_ldap_result( conn, op, LDAP_SUCCESS,
|
||||
NULL, NULL, NULL, NULL );
|
||||
rc = 0;
|
||||
goto return_results_after;
|
||||
|
||||
return_results:
|
||||
if( new_dn != NULL ) free( new_dn );
|
||||
if( new_ndn != NULL ) free( new_ndn );
|
||||
|
||||
return_results_after:
|
||||
/* NOTE:
|
||||
* new_dn and new_ndn are not deallocated because they are used by
|
||||
* the cache entry.
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ int bdb2i_cache_delete LDAP_P(( struct dbcache *db, Datum key ));
|
|||
|
||||
int bdb2i_dn2id_add LDAP_P(( BackendDB *be, const char *dn, ID id ));
|
||||
ID bdb2i_dn2id LDAP_P(( BackendDB *be, const char *dn ));
|
||||
int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn ));
|
||||
int bdb2i_dn2id_delete LDAP_P(( BackendDB *be, const char *dn, ID id ));
|
||||
|
||||
ID_BLOCK *
|
||||
bdb2i_dn2idl LDAP_P((
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ ID bdb2_tool_entry_put(
|
|||
rc = bdb2i_cache_store( id2entry, key, data, LDBM_REPLACE );
|
||||
|
||||
if( rc != 0 ) {
|
||||
(void) bdb2i_dn2id_delete( be, e->e_ndn );
|
||||
(void) bdb2i_dn2id_delete( be, e->e_ndn, e->e_id );
|
||||
return NOID;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ dn2id_delete(
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
char **subtree = dn_subtree( NULL, dn );
|
||||
|
||||
|
|
@ -246,6 +247,7 @@ dn2id_delete(
|
|||
charray_free( subtree );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ldbm_datum_init( key );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue