From 2d3c48ccd56f33538d0205083d26865bfbf0f64d Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 9 Feb 2007 17:23:00 +0000 Subject: [PATCH] ITS#4838 fix fake root handling broken by prev commit --- servers/slapd/back-bdb/dn2id.c | 6 ++++-- servers/slapd/back-bdb/init.c | 9 +++++++++ servers/slapd/back-bdb/search.c | 17 +++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index eff601e38e..07acfeb2d5 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -349,7 +349,8 @@ bdb_dn2idl( ndn->bv_val, 0, 0 ); #ifndef BDB_MULTIPLE_SUFFIXES - if ( prefix == DN_SUBTREE_PREFIX && ei->bei_parent->bei_id == 0 ) { + if ( prefix == DN_SUBTREE_PREFIX + && ( ei->bei_id == 0 || ei->bei_parent->bei_id == 0 )) { BDB_IDL_ALL(bdb, ids); return 0; } @@ -1077,7 +1078,8 @@ hdb_dn2idl( #ifndef BDB_MULTIPLE_SUFFIXES if ( op->ors_scope != LDAP_SCOPE_ONELEVEL && - ei->bei_parent->bei_id == 0 ) + ( ei->bei_id == 0 || + ei->bei_parent->bei_id == 0 )) { BDB_IDL_ALL( bdb, ids ); return 0; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index ce41a5cf6b..510197bcba 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -79,6 +79,15 @@ bdb_db_init( BackendDB *be ) ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock ); ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock ); + { + Entry *e = entry_alloc(); + e->e_id = 0; + e->e_private = &bdb->bi_cache.c_dntree; + BER_BVSTR( &e->e_name, "" ); + BER_BVSTR( &e->e_nname, "" ); + bdb->bi_cache.c_dntree.bei_e = e; + } + be->be_private = bdb; be->be_cf_ocs = be->bd_info->bi_cf_ocs; diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 0a42b63dca..94dd7c87ae 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -311,7 +311,7 @@ bdb_search( Operation *op, SlapReply *rs ) ID id, cursor; ID candidates[BDB_IDL_UM_SIZE]; ID scopes[BDB_IDL_DB_SIZE]; - Entry *e = NULL, base, e_root = {0}; + Entry *e = NULL, base, *e_root; Entry *matched = NULL; EntryInfo *ei; struct berval realbase = BER_BVNULL; @@ -348,13 +348,10 @@ bdb_search( Operation *op, SlapReply *rs ) } } + e_root = bdb->bi_cache.c_dntree.bei_e; if ( op->o_req_ndn.bv_len == 0 ) { /* DIT root special case */ - ei = &bdb->bi_cache.c_dntree; - e_root.e_private = ei; - e_root.e_id = 0; - BER_BVSTR( &e_root.e_nname, "" ); - BER_BVSTR( &e_root.e_name, "" ); + ei = e_root->e_private; rs->sr_err = LDAP_SUCCESS; } else { if ( op->ors_deref & LDAP_DEREF_FINDING ) { @@ -484,14 +481,14 @@ dn2entry_retry: #ifdef SLAP_ZONE_ALLOC slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif - if ( e != &e_root ) { + if ( e != e_root ) { bdb_cache_return_entry_r(bdb, e, &lock); } send_ldap_result( op, rs ); return rs->sr_err; } - if ( !manageDSAit && e != &e_root && is_entry_referral( e ) ) { + if ( !manageDSAit && e != e_root && is_entry_referral( e ) ) { /* entry is a referral, don't allow add */ struct berval matched_dn = BER_BVNULL; BerVarray erefs = NULL; @@ -541,7 +538,7 @@ dn2entry_retry: #ifdef SLAP_ZONE_ALLOC slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif - if ( e != &e_root ) { + if ( e != e_root ) { bdb_cache_return_entry_r(bdb, e, &lock); } send_ldap_result( op, rs ); @@ -564,7 +561,7 @@ dn2entry_retry: #ifdef SLAP_ZONE_ALLOC slap_zn_runlock(bdb->bi_cache.c_zctx, e); #endif - if ( e != &e_root ) { + if ( e != e_root ) { bdb_cache_return_entry_r(bdb, e, &lock); } e = NULL; -- 2.39.5