From b57c11f4bd23e0fe9dec8bae3af2fcd7494a8f98 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 29 Jan 2002 04:53:47 +0000 Subject: [PATCH] BDB_ALIASES and BDB_SUBENTRIES cleanup --- servers/slapd/back-bdb/add.c | 13 ++++++++++++- servers/slapd/back-bdb/attribute.c | 2 ++ servers/slapd/back-bdb/back-bdb.h | 1 - servers/slapd/back-bdb/bind.c | 14 ++++++++++++++ servers/slapd/back-bdb/config.c | 2 -- servers/slapd/back-bdb/delete.c | 3 +-- servers/slapd/back-bdb/filterindex.c | 3 --- servers/slapd/back-bdb/group.c | 2 ++ servers/slapd/back-bdb/init.c | 11 ++++++++--- servers/slapd/back-bdb/modify.c | 3 +-- servers/slapd/back-bdb/modrdn.c | 2 ++ servers/slapd/back-bdb/passwd.c | 13 +++++++++++-- servers/slapd/back-bdb/search.c | 22 +++++++++++----------- 13 files changed, 64 insertions(+), 27 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 961aa0a8ed..7da553e59f 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -30,7 +30,9 @@ bdb_add( AttributeDescription *children = slap_schema.si_ad_children; DB_TXN *ltid = NULL; struct bdb_op_info opinfo; +#ifdef BDB_SUBENTRIES int subentry; +#endif #if 0 u_int32_t lockid; DB_LOCK lock; @@ -47,7 +49,9 @@ bdb_add( goto return_results; } +#ifdef BDB_SUBENTRIES subentry = is_entry_subentry( e ); +#endif /* * acquire an ID outside of the operation transaction @@ -186,6 +190,7 @@ retry: /* transaction retry */ goto return_results;; } +#ifdef BDB_SUBENTRIES if ( is_entry_subentry( p ) ) { /* parent is a subentry, don't allow add */ Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is subentry\n", @@ -194,7 +199,8 @@ retry: /* transaction retry */ text = "parent is a subentry"; goto return_results;; } - +#endif +#ifdef BDB_ALIASES if ( is_entry_alias( p ) ) { /* parent is an alias, don't allow add */ Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is alias\n", @@ -203,6 +209,7 @@ retry: /* transaction retry */ text = "parent is an alias"; goto return_results;; } +#endif if ( is_entry_referral( p ) ) { /* parent is a referral, don't allow add */ @@ -221,10 +228,12 @@ retry: /* transaction retry */ goto done; } +#ifdef BDB_SUBENTRIES if ( subentry ) { /* FIXME: */ /* parent must be an administrative point of the required kind */ } +#endif /* free parent and reader lock */ bdb_cache_return_entry_r( &bdb->bi_cache, p ); @@ -269,6 +278,7 @@ retry: /* transaction retry */ } } +#ifdef BDB_SUBENTRIES if( subentry ) { Debug( LDAP_DEBUG_TRACE, "bdb_add: no parent, cannot add subentry\n", @@ -277,6 +287,7 @@ retry: /* transaction retry */ text = "no parent, cannot add subentry"; goto return_results;; } +#endif #if 0 if ( ltid ) { DBT obj; diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c index 298c6f5fdc..71f1147cf9 100644 --- a/servers/slapd/back-bdb/attribute.c +++ b/servers/slapd/back-bdb/attribute.c @@ -114,6 +114,7 @@ bdb_attribute( #endif } +#ifdef BDB_ALIASES /* find attribute values */ if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING @@ -126,6 +127,7 @@ bdb_attribute( rc = LDAP_ALIAS_PROBLEM; goto return_results; } +#endif if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 08ad730aa2..e0d6cd7842 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -15,7 +15,6 @@ LDAP_BEGIN_DECL -#define BDB_FILTER_INDICES 1 #define BDB_IDL_MULTI 1 /* #define BDB_HIER 1 */ diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c index 1c682e4b4b..2dbb5ad8f5 100644 --- a/servers/slapd/back-bdb/bind.c +++ b/servers/slapd/back-bdb/bind.c @@ -109,7 +109,20 @@ bdb_bind( ber_dupbv( edn, &e->e_name ); /* check for deleted */ +#ifdef BDB_SUBENTRIES + if ( is_entry_subentry( e ) ) { + /* entry is an subentry, don't allow bind */ + Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, + 0, 0 ); + + send_ldap_result( conn, op, rc = LDAP_INVALID_CREDENTIALS, + NULL, NULL, NULL, NULL ); + + goto done; + } +#endif +#ifdef BDB_ALIASES if ( is_entry_alias( e ) ) { /* entry is an alias, don't allow bind */ Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, @@ -120,6 +133,7 @@ bdb_bind( goto done; } +#endif if ( is_entry_referral( e ) ) { /* entry is a referral, don't allow bind */ diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index b1a6d6d5dd..bd74e95e8c 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -121,7 +121,6 @@ bdb_db_config( } bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 ); -#if BDB_FILTER_INDICES /* attribute to index */ } else if ( strcasecmp( argv[0], "index" ) == 0 ) { int rc; @@ -139,7 +138,6 @@ bdb_db_config( rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] ); if( rc != LDAP_SUCCESS ) return 1; -#endif /* size of the cache in entries */ } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) { diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index f09b2963b1..24d4f2ecb4 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -233,8 +233,7 @@ retry: /* transaction retry */ } if ( !manageDSAit && is_entry_referral( e ) ) { - /* parent is a referral, don't allow add */ - /* parent is an alias, don't allow add */ + /* entry is a referral, don't allow delete */ BerVarray refs = get_entry_referrals( be, conn, op, e ); diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index 995b9e96cb..9e5caa29ab 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -13,8 +13,6 @@ #include "back-bdb.h" #include "idl.h" -#ifdef BDB_FILTER_INDICES - static int presence_candidates( Backend *be, AttributeDescription *desc, @@ -563,4 +561,3 @@ substring_candidates( return( 0 ); } -#endif diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c index b754c31f14..e5c3bc8a97 100644 --- a/servers/slapd/back-bdb/group.c +++ b/servers/slapd/back-bdb/group.c @@ -123,6 +123,7 @@ bdb_group( */ rc = 1; +#ifdef BDB_ALIASES if( is_entry_alias( e ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, @@ -133,6 +134,7 @@ bdb_group( #endif goto return_results; } +#endif if( is_entry_referral( e ) ) { #ifdef NEW_LOGGING diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index b51ca852b9..a7f3ad0f01 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -65,9 +65,14 @@ bdb_db_init( BackendDB *be ) 0, 0, 0 ); /* indicate system schema supported */ - be->be_flags |= SLAP_BFLAG_ALIASES - | SLAP_BFLAG_REFERRALS - | SLAP_BFLAG_SUBENTRIES; + be->be_flags |= +#ifdef BDB_SUBENTRIES + SLAP_BFLAG_SUBENTRIES | +#endif +#ifdef BDB_ALIASES + SLAP_BFLAG_ALIASES | +#endif + SLAP_BFLAG_REFERRALS; /* allocate backend-database-specific stuff */ bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 6194c20e2b..d9dc92be05 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -281,8 +281,7 @@ retry: /* transaction retry */ } if ( !manageDSAit && is_entry_referral( e ) ) { - /* parent is a referral, don't allow add */ - /* parent is an alias, don't allow add */ + /* entry is a referral, don't allow modify */ BerVarray refs = get_entry_referrals( be, conn, op, e ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 73c7d21252..29888ae7d0 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -324,6 +324,7 @@ retry: /* transaction retry */ goto return_results; } +#ifdef BDB_ALIASES if ( is_entry_alias( np ) ) { /* parent is an alias, don't allow add */ Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n", @@ -332,6 +333,7 @@ retry: /* transaction retry */ rc = LDAP_ALIAS_PROBLEM; goto return_results; } +#endif if ( is_entry_referral( np ) ) { /* parent is a referral, don't allow add */ diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 003f85691a..38cee4b7c6 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -142,18 +142,27 @@ retry: /* transaction retry */ goto done; } +#ifdef BDB_SUBENTRIES + if( is_entry_subentries( e ) ) { + /* entry is an alias, don't allow operation */ + *text = "authorization entry is subentry"; + rc = LDAP_OTHER; + goto done; + } +#endif +#ifdef BDB_ALIASES if( is_entry_alias( e ) ) { /* entry is an alias, don't allow operation */ *text = "authorization entry is alias"; rc = LDAP_ALIAS_PROBLEM; goto done; } - +#endif if( is_entry_referral( e ) ) { /* entry is an referral, don't allow operation */ *text = "authorization entry is referral"; - rc = LDAP_OPERATIONS_ERROR; + rc = LDAP_OTHER; goto done; } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 6b3447ef5c..34197d090b 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -315,22 +315,26 @@ bdb_search( goto loop_continue; } +#ifdef BDB_SUBENTRIES if ( is_entry_subentry( e ) ) { if( scope != LDAP_SCOPE_BASE ) { if(!get_subentries_visibility( op )) { /* only subentries are visible */ goto loop_continue; } + } else if ( get_subentries( op ) && !get_subentries_visibility( op )) { /* only subentries are visible */ goto loop_continue; } + } else if ( get_subentries_visibility( op )) { /* only subentries are visible */ goto loop_continue; } +#endif #ifdef BDB_ALIASES if ( deref & LDAP_DEREF_SEARCHING && is_entry_alias( e ) ) { @@ -545,15 +549,18 @@ static int search_candidates( ID *ids ) { int rc; - Filter f, scopef, sf, rf, xf; + Filter f, scopef, rf, xf; ID tmp[BDB_IDL_UM_SIZE]; AttributeAssertion aa_ref; +#ifdef BDB_SUBENTRIES + Filter sf; AttributeAssertion aa_subentry; - struct bdb_info *bdb = (struct bdb_info *) be->be_private; +#endif #ifdef BDB_ALIASES Filter af; AttributeAssertion aa_alias; #endif + struct bdb_info *bdb = (struct bdb_info *) be->be_private; /* * This routine takes as input a filter (user-filter) @@ -606,6 +613,7 @@ static int search_candidates( scopef.f_dn = &e->e_nname; scopef.f_next = xf.f_or == filter ? filter : &xf ; +#ifdef BDB_SUBENTRIES if( get_subentries_visibility( op ) ) { struct berval bv_subentry = { sizeof("SUBENTRY")-1, "SUBENTRY" }; sf.f_choice = LDAP_FILTER_EQUALITY; @@ -615,17 +623,9 @@ static int search_candidates( sf.f_next = scopef.f_next; scopef.f_next = &sf; } +#endif -#ifdef BDB_FILTER_INDICES rc = bdb_filter_candidates( be, &f, ids, tmp ); -#else - /* FIXME: Original code: - BDB_IDL_ID( bdb, ids, e->e_id ); - * this is a hack to make "" base work; when bdb_filter_candidates - * is used this should not be needed any more */ - BDB_IDL_ID( bdb, ids, (e->e_id == NOID ? 1 : e->e_id) ); - rc = 0; -#endif Debug(LDAP_DEBUG_TRACE, "bdb_search_candidates: id=%ld first=%ld last=%ld\n", -- 2.39.5