From 7fae7fe15599213581d3e667a8e97a91f95faabb Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 1 May 2002 18:50:14 +0000 Subject: [PATCH] Changed be_[n]suffix, be_[n]suffixAlias to BerVarray. No more bvec's anywhere. --- servers/slapd/back-bdb/dn2id.c | 10 ++--- servers/slapd/back-bdb/init.c | 6 +-- servers/slapd/back-monitor/database.c | 11 +---- servers/slapd/back-monitor/init.c | 10 ++--- servers/slapd/back-passwd/search.c | 10 ++--- servers/slapd/back-shell/result.c | 4 +- servers/slapd/back-tcl/tcl_back.h | 2 +- servers/slapd/back-tcl/tcl_util.c | 8 ++-- servers/slapd/backend.c | 18 ++++----- servers/slapd/backglue.c | 16 ++++---- servers/slapd/config.c | 58 ++++++++++++--------------- servers/slapd/mods.c | 19 --------- servers/slapd/repl.c | 22 +++++----- servers/slapd/root_dse.c | 4 +- servers/slapd/slap.h | 8 ++-- servers/slapd/suffixalias.c | 10 ++--- servers/slapd/tools/slapadd.c | 4 +- 17 files changed, 94 insertions(+), 126 deletions(-) diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 91a989095c..d9792904fb 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -744,7 +744,7 @@ int bdb_build_tree( * Note that this code always uses be_suffix[0], so defining * multiple suffixes for a single backend won't work! */ - rdns = ldap_explode_dn(be->be_nsuffix[0]->bv_val, 0); + rdns = ldap_explode_dn(be->be_nsuffix[0].bv_val, 0); for (i=0; rdns[i]; i++); bdb->bi_nrdns = i; charray_free(rdns); @@ -783,8 +783,8 @@ int bdb_fix_dn( ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr); o = bdb_find_id_node(id, bdb->bi_tree); - rlen = be->be_suffix[0]->bv_len + 1; - nrlen = be->be_nsuffix[0]->bv_len + 1; + rlen = be->be_suffix[0].bv_len + 1; + nrlen = be->be_nsuffix[0].bv_len + 1; for (n = o; n && n->i_parent; n=n->i_parent) { rlen += n->i_rdn->rdn.bv_len + 1; nrlen += n->i_rdn->nrdn.bv_len + 1; @@ -803,8 +803,8 @@ int bdb_fix_dn( } ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr); - strcpy(ptr, be->be_suffix[0]->bv_val); - strcpy(nptr, be->be_nsuffix[0]->bv_val); + strcpy(ptr, be->be_suffix[0].bv_val); + strcpy(nptr, be->be_nsuffix[0].bv_val); return 0; } diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 0283e3170b..a1bb111a7b 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -171,11 +171,11 @@ bdb_db_open( BackendDB *be ) u_int32_t flags; #ifdef NEW_LOGGING - LDAP_LOG(( "init", LDAP_LEVEL_ARGS, "bdb_db_open: %s\n", be->be_suffix[0]->bv_val )); + LDAP_LOG(( "init", LDAP_LEVEL_ARGS, "bdb_db_open: %s\n", be->be_suffix[0].bv_val )); #else Debug( LDAP_DEBUG_ARGS, "bdb_db_open: %s\n", - be->be_suffix[0]->bv_val, 0, 0 ); + be->be_suffix[0].bv_val, 0, 0 ); #endif /* we should check existance of dbenv_home and db_directory */ @@ -195,7 +195,7 @@ bdb_db_open( BackendDB *be ) flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER; - bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0]->bv_val ); + bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val ); bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall ); #ifndef NO_THREADS bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect ); diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 13ce9d5838..bfc1eded08 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -114,15 +114,8 @@ monitor_subsys_database_init( return( -1 ); } - for ( j = 0; be->be_suffix[j]; j++ ) { - struct berval bv[ 2 ]; - - bv[ 0 ] = *be->be_suffix[ j ]; - bv[ 1 ].bv_val = NULL; - - attr_merge( e, ad_nc, bv ); - attr_merge( e_database, ad_nc, bv ); - } + attr_merge( e, ad_nc, be->be_suffix ); + attr_merge( e_database, ad_nc, be->be_suffix ); for ( j = nBackendInfo; j--; ) { if ( &backendInfo[ j ] == be->bd_info ) { diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 692efd2d71..44d81d0529 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -226,7 +226,7 @@ monitor_back_db_init( struct monitorentrypriv *mp; int i, rc; char buf[1024], *end_of_line; - struct berval dn, *ndn; + struct berval dn, ndn; const char *text; struct berval bv[2]; @@ -249,11 +249,10 @@ monitor_back_db_init( /* indicate system schema supported */ be->be_flags |= SLAP_BFLAG_MONITOR; - ndn = NULL; dn.bv_val = SLAPD_MONITOR_DN; dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1; - rc = dnNormalize( NULL, &dn, &ndn ); + rc = dnNormalize2( NULL, &dn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, @@ -266,8 +265,9 @@ monitor_back_db_init( return -1; } - ber_bvecadd( &be->be_suffix, ber_dupbv( NULL, &dn ) ); - ber_bvecadd( &be->be_nsuffix, ndn ); + ber_dupbv( &bv[0], &dn ); + ber_bvarray_add( &be->be_suffix, &bv[0] ); + ber_bvarray_add( &be->be_nsuffix, &ndn ); mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 ); ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex ); diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 83db8ae5fe..4847bfff61 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -180,9 +180,9 @@ passwd_back_search( */ if( !be_issuffix( be, &parent ) ) { int i; - for( i=0; be->be_nsuffix[i] != NULL; i++ ) { - if( dnIsSuffix( nbase, be->be_nsuffix[i] ) ) { - matched = be->be_suffix[i]->bv_val; + for( i=0; be->be_nsuffix[i].bv_val != NULL; i++ ) { + if( dnIsSuffix( nbase, &be->be_nsuffix[i] ) ) { + matched = be->be_suffix[i].bv_val; break; } } @@ -262,12 +262,12 @@ pw2entry( Backend *be, struct passwd *pw, const char **text ) */ pwlen = strlen( pw->pw_name ); - vals[0].bv_len = (sizeof("uid=,")-1) + ( pwlen + be->be_suffix[0]->bv_len ); + vals[0].bv_len = (sizeof("uid=,")-1) + ( pwlen + be->be_suffix[0].bv_len ); vals[0].bv_val = ch_malloc( vals[0].bv_len + 1 ); /* rdn attribute type should be a configuratable item */ sprintf( vals[0].bv_val, "uid=%s,%s", - pw->pw_name, be->be_suffix[0]->bv_val ); + pw->pw_name, be->be_suffix[0].bv_val ); rc = dnNormalize2( NULL, vals, &bv ); if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index aaadf6bec7..ded78f03c4 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -110,7 +110,7 @@ print_suffixes( { int i; - for ( i = 0; be->be_suffix[i] != NULL; i++ ) { - fprintf( fp, "suffix: %s\n", be->be_suffix[i]->bv_val ); + for ( i = 0; be->be_suffix[i].bv_val != NULL; i++ ) { + fprintf( fp, "suffix: %s\n", be->be_suffix[i].bv_val ); } } diff --git a/servers/slapd/back-tcl/tcl_back.h b/servers/slapd/back-tcl/tcl_back.h index 63da57236e..aa56a2611f 100644 --- a/servers/slapd/back-tcl/tcl_back.h +++ b/servers/slapd/back-tcl/tcl_back.h @@ -44,7 +44,7 @@ struct tclinfo { void readtclscript (char *script, Tcl_Interp * my_tcl); char *tcl_clean_entry (Entry * e); -struct berval *tcl_merge_bvlist (struct berval **bvlist, struct berval *out); +struct berval *tcl_merge_bvlist (BerVarray bvlist, struct berval *out); int tcl_ldap_debug ( ClientData clientData, diff --git a/servers/slapd/back-tcl/tcl_util.c b/servers/slapd/back-tcl/tcl_util.c index 5d197f36bc..e23b86d115 100644 --- a/servers/slapd/back-tcl/tcl_util.c +++ b/servers/slapd/back-tcl/tcl_util.c @@ -192,7 +192,7 @@ readtclscript ( struct berval * tcl_merge_bvlist( - struct berval **bvlist, struct berval *out) + BerVarray bvlist, struct berval *out) { struct berval *ret = NULL; int i; @@ -212,7 +212,7 @@ tcl_merge_bvlist( ret->bv_len = 0; ret->bv_val = NULL; - for (i = 0; bvlist[i] != NULL; i++); + for (i = 0; bvlist[i].bv_val != NULL; i++); if (i) { char **strlist = ch_malloc ((i + 1) * sizeof(char *)); @@ -221,8 +221,8 @@ tcl_merge_bvlist( ch_free (ret); return NULL; } - for (i = 0; bvlist[i] != NULL; i++) { - strlist[i] = bvlist[i]->bv_val; + for (i = 0; bvlist[i].bv_val != NULL; i++) { + strlist[i] = bvlist[i].bv_val; } strlist[i] = NULL; ret->bv_val = Tcl_Merge(i, strlist); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 655c2fdc46..7d7414aaa8 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -248,11 +248,11 @@ int backend_startup(Backend *be) #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, "backend_startup: starting \"%s\"\n", - be->be_suffix[0]->bv_val )); + be->be_suffix[0].bv_val )); #else Debug( LDAP_DEBUG_TRACE, "backend_startup: starting \"%s\"\n", - be->be_suffix[0]->bv_val, 0, 0 ); + be->be_suffix[0].bv_val, 0, 0 ); #endif if ( be->bd_info->bi_open ) { @@ -425,8 +425,8 @@ int backend_destroy(void) if ( bd->bd_info->bi_db_destroy ) { bd->bd_info->bi_db_destroy( bd ); } - ber_bvecfree( bd->be_suffix ); - ber_bvecfree( bd->be_nsuffix ); + ber_bvarray_free( bd->be_suffix ); + ber_bvarray_free( bd->be_nsuffix ); if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val ); if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val ); if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val ); @@ -540,7 +540,7 @@ select_backend( for ( i = 0; i < nbackends; i++ ) { for ( j = 0; backends[i].be_nsuffix != NULL && - backends[i].be_nsuffix[j] != NULL; j++ ) + backends[i].be_nsuffix[j].bv_val != NULL; j++ ) { if (( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) && noSubs ) @@ -548,7 +548,7 @@ select_backend( continue; } - len = backends[i].be_nsuffix[j]->bv_len; + len = backends[i].be_nsuffix[j].bv_len; if ( len > dnlen ) { /* suffix is longer than DN */ @@ -565,7 +565,7 @@ select_backend( continue; } - if ( strcmp( backends[i].be_nsuffix[j]->bv_val, + if ( strcmp( backends[i].be_nsuffix[j].bv_val, &dn->bv_val[dnlen-len] ) == 0 ) { if( be == NULL ) { @@ -593,8 +593,8 @@ be_issuffix( { int i; - for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) { - if ( ber_bvcmp( be->be_nsuffix[i], bvsuffix ) == 0 ) { + for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i].bv_val != NULL; i++ ) { + if ( ber_bvcmp( &be->be_nsuffix[i], bvsuffix ) == 0 ) { return( 1 ); } } diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 0eccc8b8ac..e2afd09156 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -63,7 +63,7 @@ glue_back_select ( bv.bv_val = (char *) dn; for (i = 0; inodes; i++) { - if (dnIsSuffix(&bv, gi->n[i].be->be_nsuffix[0])) { + if (dnIsSuffix(&bv, &gi->n[i].be->be_nsuffix[0])) { return gi->n[i].be; } } @@ -360,20 +360,20 @@ glue_back_search ( if (scope == LDAP_SCOPE_ONELEVEL && dn_match(&gi->n[i].pdn, ndn)) { rc = be->be_search (be, conn, op, - be->be_suffix[0], be->be_nsuffix[0], + &be->be_suffix[0], &be->be_nsuffix[0], LDAP_SCOPE_BASE, deref, s2limit, t2limit, filter, filterstr, attrs, attrsonly); } else if (scope == LDAP_SCOPE_SUBTREE && - dnIsSuffix(be->be_nsuffix[0], ndn)) { + dnIsSuffix(&be->be_nsuffix[0], ndn)) { rc = be->be_search (be, conn, op, - be->be_suffix[0], be->be_nsuffix[0], + &be->be_suffix[0], &be->be_nsuffix[0], scope, deref, s2limit, t2limit, filter, filterstr, attrs, attrsonly); - } else if (dnIsSuffix(&bv, be->be_nsuffix[0])) { + } else if (dnIsSuffix(&bv, &be->be_nsuffix[0])) { rc = be->be_search (be, conn, op, dn, ndn, scope, deref, s2limit, t2limit, filter, filterstr, @@ -833,7 +833,7 @@ glue_sub_init( ) if (be->be_flags & SLAP_BFLAG_GLUE_LINKED) { continue; } - if (!dnIsSuffix(be->be_nsuffix[0], b1->be_nsuffix[0])) { + if (!dnIsSuffix(&be->be_nsuffix[0], &b1->be_nsuffix[0])) { continue; } cont--; @@ -890,7 +890,7 @@ glue_sub_init( ) gi->nodes * sizeof(gluenode)); } gi->n[gi->nodes].be = be; - dnParent( be->be_nsuffix[0], &gi->n[gi->nodes].pdn ); + dnParent( &be->be_nsuffix[0], &gi->n[gi->nodes].pdn ); gi->nodes++; } if (gi) { @@ -898,7 +898,7 @@ glue_sub_init( ) gi = (glueinfo *)ch_realloc(gi, sizeof(glueinfo) + gi->nodes * sizeof(gluenode)); gi->n[gi->nodes].be = gi->be; - dnParent( b1->be_nsuffix[0], &gi->n[gi->nodes].pdn ); + dnParent( &b1->be_nsuffix[0], &gi->n[gi->nodes].pdn ); gi->nodes++; b1->be_private = gi; b1->bd_info = bi; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index e79dcc6252..b4197a0807 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -858,9 +858,7 @@ read_config( const char *fname ) /* set database suffix */ } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) { Backend *tmp_be; - struct berval dn; - struct berval *pdn = NULL; - struct berval *ndn = NULL; + struct berval dn, pdn, ndn; if ( cargc < 2 ) { #ifdef NEW_LOGGING @@ -919,10 +917,8 @@ read_config( const char *fname ) dn.bv_val = cargv[1]; dn.bv_len = strlen( cargv[1] ); - pdn = ch_malloc( sizeof( struct berval )); - ndn = ch_malloc( sizeof( struct berval )); - rc = dnPrettyNormal( NULL, &dn, pdn, ndn ); + rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, @@ -936,7 +932,7 @@ read_config( const char *fname ) return( 1 ); } - tmp_be = select_backend( ndn, 0, 0 ); + tmp_be = select_backend( &ndn, 0, 0 ); if ( tmp_be == be ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_INFO, @@ -947,25 +943,25 @@ read_config( const char *fname ) "already served by this backend (ignored)\n", fname, lineno, 0 ); #endif - ber_bvfree( pdn ); - ber_bvfree( ndn ); + free( pdn.bv_val ); + free( ndn.bv_val ); } else if ( tmp_be != NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: suffix already served by a preceding " "backend \"%s\"\n", fname, lineno, - tmp_be->be_suffix[0]->bv_val )); + tmp_be->be_suffix[0].bv_val )); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix " "already served by a preceeding backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0]->bv_val ); + fname, lineno, tmp_be->be_suffix[0].bv_val ); #endif - ber_bvfree( pdn ); - ber_bvfree( ndn ); + free( pdn.bv_val ); + free( ndn.bv_val ); return( 1 ); - } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) { + } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: suffix DN empty and default search " @@ -979,14 +975,14 @@ read_config( const char *fname ) #endif } - ber_bvecadd( &be->be_suffix, pdn ); - ber_bvecadd( &be->be_nsuffix, ndn ); + ber_bvarray_add( &be->be_suffix, &pdn ); + ber_bvarray_add( &be->be_nsuffix, &ndn ); /* set database suffixAlias */ } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) { Backend *tmp_be; - struct berval alias, *palias, nalias; - struct berval aliased, *paliased, naliased; + struct berval alias, palias, nalias; + struct berval aliased, paliased, naliased; if ( cargc < 2 ) { #ifdef NEW_LOGGING @@ -1046,9 +1042,8 @@ read_config( const char *fname ) alias.bv_val = cargv[1]; alias.bv_len = strlen( cargv[1] ); - palias = ch_malloc(sizeof(struct berval)); - rc = dnPrettyNormal( NULL, &alias, palias, &nalias ); + rc = dnPrettyNormal( NULL, &alias, &palias, &nalias ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, @@ -1069,22 +1064,21 @@ read_config( const char *fname ) LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: suffixAlias served by a preceeding " "backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0]->bv_val )); + fname, lineno, tmp_be->be_suffix[0].bv_val )); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffixAlias served by" " a preceeding backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0]->bv_val ); + fname, lineno, tmp_be->be_suffix[0].bv_val ); #endif - ber_bvfree( palias ); + free( palias.bv_val ); return -1; } aliased.bv_val = cargv[2]; aliased.bv_len = strlen( cargv[2] ); - paliased = ch_malloc(sizeof(struct berval)); - rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased ); + rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, @@ -1095,7 +1089,7 @@ read_config( const char *fname ) "%s: line %d: aliased DN is invalid\n", fname, lineno, 0 ); #endif - ber_bvfree( palias ); + free( palias.bv_val ); return( 1 ); } @@ -1106,20 +1100,20 @@ read_config( const char *fname ) LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: suffixAlias derefs to a different backend " "a preceeding backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0]->bv_val )); + fname, lineno, tmp_be->be_suffix[0].bv_val )); #else Debug( LDAP_DEBUG_ANY, "%s: line %d: suffixAlias derefs to differnet backend" " a preceeding backend \"%s\"\n", - fname, lineno, tmp_be->be_suffix[0]->bv_val ); + fname, lineno, tmp_be->be_suffix[0].bv_val ); #endif - ber_bvfree( palias ); - ber_bvfree( paliased ); + free( palias.bv_val ); + free( paliased.bv_val ); return -1; } - ber_bvecadd( &be->be_suffixAlias, palias ); - ber_bvecadd( &be->be_suffixAlias, paliased ); + ber_bvarray_add( &be->be_suffixAlias, &palias ); + ber_bvarray_add( &be->be_suffixAlias, &paliased ); /* set max deref depth */ } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) { diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 529b4e74b2..f57cf41dab 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -303,22 +303,3 @@ slap_mods_free( } } -void -slap_modlist_free( - LDAPModList *ml -) -{ - LDAPModList *next; - - for ( ; ml != NULL; ml = next ) { - next = ml->ml_next; - - if (ml->ml_type) - free( ml->ml_type ); - - if ( ml->ml_bvalues != NULL ) - ber_bvecfree( ml->ml_bvalues ); - - free( ml ); - } -} diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 6f2b3ac262..4f0105b3e9 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -55,23 +55,23 @@ add_replica_suffix( const char *suffix ) { - struct berval dn, *ndn = NULL; + struct berval dn, ndn; int rc; dn.bv_val = (char *) suffix; dn.bv_len = strlen( dn.bv_val ); - rc = dnNormalize( NULL, &dn, &ndn ); + rc = dnNormalize2( NULL, &dn, &ndn ); if( rc != LDAP_SUCCESS ) { return 2; } - if ( select_backend( ndn, 0, 0 ) != be ) { - ber_bvfree( ndn ); + if ( select_backend( &ndn, 0, 0 ) != be ) { + free( ndn.bv_val ); return 1; } - ber_bvecadd( &be->be_replica[nr]->ri_nsuffix, ndn ); + ber_bvarray_add( &be->be_replica[nr]->ri_nsuffix, &ndn ); return 0; } @@ -139,13 +139,13 @@ replog( if ( be->be_replica[i]->ri_nsuffix != NULL ) { int j; - for ( j = 0; be->be_replica[i]->ri_nsuffix[j]; j++ ) { - if ( dnIsSuffix( ndn, be->be_replica[i]->ri_nsuffix[j] ) ) { + for ( j = 0; be->be_replica[i]->ri_nsuffix[j].bv_val; j++ ) { + if ( dnIsSuffix( ndn, &be->be_replica[i]->ri_nsuffix[j] ) ) { break; } } - if ( !be->be_replica[i]->ri_nsuffix[j] ) { + if ( !be->be_replica[i]->ri_nsuffix[j].bv_val ) { /* do not add "replica:" line */ continue; } @@ -195,13 +195,13 @@ replog( if ( be->be_replica[i]->ri_nsuffix != NULL ) { int j; - for ( j = 0; be->be_replica[i]->ri_nsuffix[j]; j++ ) { - if ( dnIsSuffix( ndn, be->be_replica[i]->ri_nsuffix[j] ) ) { + for ( j = 0; be->be_replica[i]->ri_nsuffix[j].bv_val; j++ ) { + if ( dnIsSuffix( ndn, &be->be_replica[i]->ri_nsuffix[j] ) ) { break; } } - if ( !be->be_replica[i]->ri_nsuffix[j] ) { + if ( !be->be_replica[i]->ri_nsuffix[j].bv_val ) { /* do not add "replica:" line */ continue; } diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index b52e3558b4..5db42c0f70 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -93,8 +93,8 @@ root_dse_info( if ( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) { continue; } - for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { - vals[0] = *backends[i].be_suffix[j]; + for ( j = 0; backends[i].be_suffix[j].bv_val != NULL; j++ ) { + vals[0] = backends[i].be_suffix[j]; attr_merge( e, ad_namingContexts, vals ); } } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 945c8407e6..ddd7c9b048 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1008,7 +1008,7 @@ LDAP_SLAPD_V (int) slapMode; struct slap_replica_info { char *ri_host; /* supersedes be_replica */ - struct berval **ri_nsuffix; /* array of suffixes this replica accepts */ + BerVarray ri_nsuffix; /* array of suffixes this replica accepts */ AttributeName *ri_attrs; /* attrs to replicate, NULL=all */ int ri_exclude; /* 1 => exclude ri_attrs */ }; @@ -1150,9 +1150,9 @@ struct slap_backend_db { slap_ssf_set_t be_ssf_set; /* these should be renamed from be_ to bd_ */ - struct berval **be_suffix; /* the DN suffixes of data in this backend */ - struct berval **be_nsuffix; /* the normalized DN suffixes in this backend */ - struct berval **be_suffixAlias; /* pairs of DN suffix aliases and deref values */ + BerVarray be_suffix; /* the DN suffixes of data in this backend */ + BerVarray be_nsuffix; /* the normalized DN suffixes in this backend */ + BerVarray be_suffixAlias; /* pairs of DN suffix aliases and deref values */ struct berval be_rootdn; /* the magic "root" name (DN) for this db */ struct berval be_rootndn; /* the magic "root" normalized name (DN) for this db */ struct berval be_rootpw; /* the magic "root" password for this db */ diff --git a/servers/slapd/suffixalias.c b/servers/slapd/suffixalias.c index bae4e4e078..faf68b95b4 100644 --- a/servers/slapd/suffixalias.c +++ b/servers/slapd/suffixalias.c @@ -40,10 +40,10 @@ void suffix_alias( dnLength = dn->bv_len; for ( i = 0; - be->be_suffixAlias != NULL && be->be_suffixAlias[i] != NULL; + be->be_suffixAlias != NULL && be->be_suffixAlias[i].bv_val != NULL; i += 2 ) { - int aliasLength = be->be_suffixAlias[i]->bv_len; + int aliasLength = be->be_suffixAlias[i].bv_len; int diff = dnLength - aliasLength; if ( diff < 0 ) { @@ -58,12 +58,12 @@ void suffix_alias( /* XXX or an escaped separator... oh well */ } - if (!strcmp(be->be_suffixAlias[i]->bv_val, &dn->bv_val[diff])) { + if (!strcmp(be->be_suffixAlias[i].bv_val, &dn->bv_val[diff])) { char *oldDN = dn->bv_val; - dn->bv_len = diff + be->be_suffixAlias[i+1]->bv_len; + dn->bv_len = diff + be->be_suffixAlias[i+1].bv_len; dn->bv_val = ch_malloc( dn->bv_len + 1 ); strncpy( dn->bv_val, oldDN, diff ); - strcpy( &dn->bv_val[diff], be->be_suffixAlias[i+1]->bv_val ); + strcpy( &dn->bv_val[diff], be->be_suffixAlias[i+1].bv_val ); #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "suffix_alias: converted \"%s\" to \"%s\"\n", diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index ad18fe9c6b..d14114c50c 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -83,12 +83,12 @@ main( int argc, char **argv ) fprintf( stderr, "%s: line %d: " "database (%s) not configured to hold \"%s\"\n", progname, lineno, - be ? be->be_suffix[0]->bv_val : "", + be ? be->be_suffix[0].bv_val : "", e->e_dn ); fprintf( stderr, "%s: line %d: " "database (%s) not configured to hold \"%s\"\n", progname, lineno, - be ? be->be_nsuffix[0]->bv_val : "", + be ? be->be_nsuffix[0].bv_val : "", e->e_ndn ); rc = EXIT_FAILURE; entry_free( e );