* 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);
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;
}
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;
}
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 */
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 );
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 ) {
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];
/* 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,
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 );
*/
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;
}
}
*/
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 ) {
{
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 );
}
}
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,
struct berval *
tcl_merge_bvlist(
- struct berval **bvlist, struct berval *out)
+ BerVarray bvlist, struct berval *out)
{
struct berval *ret = NULL;
int i;
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 *));
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);
#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 ) {
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 );
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 )
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 */
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 ) {
{
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 );
}
}
bv.bv_val = (char *) dn;
for (i = 0; i<gi->nodes; 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;
}
}
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,
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--;
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) {
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;
/* 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
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,
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,
"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 "
#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
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,
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,
"%s: line %d: aliased DN is invalid\n",
fname, lineno, 0 );
#endif
- ber_bvfree( palias );
+ free( palias.bv_val );
return( 1 );
}
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 ) {
}
}
-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 );
- }
-}
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;
}
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;
}
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;
}
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 );
}
}
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 */
};
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 */
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 ) {
/* 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",
fprintf( stderr, "%s: line %d: "
"database (%s) not configured to hold \"%s\"\n",
progname, lineno,
- be ? be->be_suffix[0]->bv_val : "<none>",
+ be ? be->be_suffix[0].bv_val : "<none>",
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 : "<none>",
+ be ? be->be_nsuffix[0].bv_val : "<none>",
e->e_ndn );
rc = EXIT_FAILURE;
entry_free( e );