From 2dd27b0786c511623c37a48f5935fb639cdc80dc Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 25 Dec 2001 19:48:26 +0000 Subject: [PATCH] More struct berval DNs --- servers/slapd/acl.c | 15 +++--- servers/slapd/add.c | 2 +- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/dn2id.c | 4 +- servers/slapd/back-bdb/init.c | 4 +- servers/slapd/back-bdb/modrdn.c | 4 +- servers/slapd/back-bdb/search.c | 2 +- servers/slapd/back-ldap/search.c | 2 +- servers/slapd/back-ldbm/add.c | 2 +- servers/slapd/back-ldbm/delete.c | 2 +- servers/slapd/back-ldbm/modrdn.c | 8 +-- servers/slapd/back-ldbm/search.c | 2 +- servers/slapd/back-meta/search.c | 2 +- servers/slapd/back-monitor/database.c | 3 +- servers/slapd/back-monitor/init.c | 27 +++++++--- servers/slapd/back-passwd/search.c | 13 +++-- servers/slapd/back-shell/result.c | 2 +- servers/slapd/back-sql/search.c | 4 +- servers/slapd/backend.c | 37 +++++++------- servers/slapd/backglue.c | 4 +- servers/slapd/compare.c | 2 +- servers/slapd/config.c | 18 +++---- servers/slapd/configinfo.c | 2 +- servers/slapd/delete.c | 2 +- servers/slapd/modify.c | 2 +- servers/slapd/modrdn.c | 2 +- servers/slapd/proto-slap.h | 73 +++++++++++++++++---------- servers/slapd/root_dse.c | 3 +- servers/slapd/search.c | 2 +- servers/slapd/slap.h | 18 ++++--- servers/slapd/tools/slapadd.c | 2 +- 32 files changed, 152 insertions(+), 117 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index a81c8dd2bd..321522d3ea 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -117,7 +117,7 @@ access_allowed( assert( be != NULL ); /* grant database root access */ - if ( be != NULL && be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be != NULL && be_isroot( be, &op->o_ndn ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_INFO, "access_allowed: conn %d root access granted\n", @@ -764,7 +764,7 @@ acl_mask( buf[sizeof(buf) - 1] = 0; } - if (backend_group(be, conn, op, e, buf, op->o_ndn.bv_val, + if (backend_group(be, conn, op, e, buf, &op->o_ndn, b->a_group_oc, b->a_group_at) != 0) { continue; @@ -1013,7 +1013,7 @@ acl_check_modlist( assert( be != NULL ); /* short circuit root database access */ - if ( be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be_isroot( be, &op->o_ndn ) ) { #ifdef NEW_LOGGING LDAP_LOG(( "acl", LDAP_LEVEL_DETAIL1, "acl_check_modlist: conn %d access granted to root user\n", @@ -1213,9 +1213,8 @@ aci_set_gather (void *cookie, char *name, char *attr) const char *text; AttributeDescription *desc = NULL; if (slap_str2ad(attr, &desc, &text) == LDAP_SUCCESS) { - backend_attribute(cp->be, NULL /*cp->conn*/, - NULL /*cp->op*/, cp->e, - ndn, desc, &bvals); + backend_attribute(cp->be, NULL, NULL, + cp->e, ndn, desc, &bvals); if (bvals != NULL) { for (i = 0; bvals[i] != NULL; i++) { } vals = ch_calloc(i + 1, sizeof(char *)); @@ -1283,7 +1282,7 @@ aci_match_set ( && slap_str2ad(setat, &desc, &text) == LDAP_SUCCESS ) { backend_attribute(be, NULL, NULL, e, - subjdn, desc, &bvals); + subjdn, desc, &bvals); if ( bvals != NULL ) { if ( bvals[0] != NULL ) set = ch_strdup(bvals[0]->bv_val); @@ -1517,7 +1516,7 @@ aci_group_member ( if (grp_oc != NULL && grp_ad != NULL && grpdn != NULL) { string_expand(grpdn, 1024, subjdn, e->e_ndn, matches); if ( dn_normalize(grpdn) != NULL ) { - rc = (backend_group(be, conn, op, e, grpdn, op->o_ndn.bv_val, grp_oc, grp_ad) == 0); + rc = (backend_group(be, conn, op, e, grpdn, &op->o_ndn, grp_oc, grp_ad) == 0); } } diff --git a/servers/slapd/add.c b/servers/slapd/add.c index c8d5b04d4e..5bd01be842 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -255,7 +255,7 @@ do_add( Connection *conn, Operation *op ) } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, e->e_dn, e->e_ndn ); + rc = backend_check_referrals( be, conn, op, &e->e_name, &e->e_nname ); if ( rc != LDAP_SUCCESS ) { goto done; } diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 1812992318..905a856a28 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -192,7 +192,7 @@ retry: rc = txn_abort( ltid ); * must be adding entry to at suffix * or with parent "" */ - if ( !be_isroot( be, op->o_ndn.bv_val )) { + if ( !be_isroot( be, &op->o_ndn )) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 45e5cb5540..9822076ef3 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -161,7 +161,7 @@ retry: /* transaction retry */ } else { /* no parent, must be root to delete */ - if( ! be_isroot( be, op->o_ndn.bv_val ) ) { + if( ! be_isroot( be, &op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index ca360779d5..b35c7c5fe3 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -578,7 +578,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! */ - bdb->bi_sufflen = strlen(be->be_suffix[0]); + bdb->bi_sufflen = be->be_suffix[0]->bv_len; rdns = ldap_explode_dn(be->be_nsuffix[0]->bv_val, 0); for (i=0; rdns[i]; i++); @@ -639,7 +639,7 @@ int bdb_fix_dn( ptr--; nptr--; - strcpy(ptr, be->be_suffix[0]); + 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 0574375c08..8150c35b76 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -142,7 +142,7 @@ bdb_db_open( BackendDB *be ) Debug( LDAP_DEBUG_ARGS, "bdb_db_open: %s\n", - be->be_suffix[0], 0, 0 ); + be->be_suffix[0]->bv_val, 0, 0 ); /* we should check existance of dbenv_home and db_directory */ @@ -164,7 +164,7 @@ bdb_db_open( BackendDB *be ) bdb->bi_txn_cp = 0; } - bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0] ); + bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0]->bv_val ); bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall ); #ifdef BDB_SUBDIRS diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 4ecca38f51..b92c60c7ed 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -212,7 +212,7 @@ retry: /* transaction retry */ } else { /* no parent, modrdn entry directly under root */ - isroot = be_isroot( be, op->o_ndn.bv_val ); + isroot = be_isroot( be, &op->o_ndn ); if ( ! isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { @@ -328,7 +328,7 @@ retry: /* transaction retry */ } else { if ( isroot == -1 ) { - isroot = be_isroot( be, op->o_ndn.bv_val ); + isroot = be_isroot( be, &op->o_ndn ); } np_dn = ch_strdup( "" ); diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 23af1f789e..849077ba0e 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -157,7 +157,7 @@ bdb_search( } /* if not root, get appropriate limits */ - if ( be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be_isroot( be, &op->o_ndn ) ) { isroot = 1; } else { ( void ) get_limits( be, op->o_ndn.bv_val, &limit ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index d76ff98a30..2801d7c1a2 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -85,7 +85,7 @@ ldap_back_search( } /* if not root, get appropriate limits */ - if ( be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be_isroot( be, &op->o_ndn ) ) { isroot = 1; } else { ( void ) get_limits( be, op->o_ndn.bv_val, &limit ); diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 797896ff2a..1b86663a23 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -205,7 +205,7 @@ ldbm_back_add( } /* no parent, must be adding entry to root */ - if ( !be_isroot( be, op->o_ndn.bv_val ) ) { + if ( !be_isroot( be, &op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 318fd673e8..f92bd24a4d 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -153,7 +153,7 @@ ldbm_back_delete( } else { /* no parent, must be root to delete */ - if( ! be_isroot( be, op->o_ndn.bv_val ) ) { + if( ! be_isroot( be, &op->o_ndn ) ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 1aa8cd4011..151a032b4e 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -206,8 +206,8 @@ ldbm_back_modrdn( } else { /* no parent, must be root to modify rdn */ - isroot = be_isroot( be, op->o_ndn.bv_val ); - if ( ! be_isroot ) { + isroot = be_isroot( be, &op->o_ndn ); + if ( ! isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { p = (Entry *)&slap_entry_root; @@ -382,10 +382,10 @@ ldbm_back_modrdn( /* no parent, must be root to modify newSuperior */ if ( isroot == -1 ) { - isroot = be_isroot( be, op->o_ndn.bv_val ); + isroot = be_isroot( be, &op->o_ndn ); } - if ( ! be_isroot ) { + if ( ! isroot ) { if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) { np = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 991c8ac395..031012433c 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -206,7 +206,7 @@ searchit: } /* if not root, get appropriate limits */ - if ( be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be_isroot( be, &op->o_ndn ) ) { isroot = 1; } else { ( void ) get_limits( be, op->o_ndn.bv_val, &limit ); diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 2926af6c65..4fa5390097 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -149,7 +149,7 @@ meta_back_search( nbaselen = strlen( nbase ); /* if not root, get appropriate limits */ - if ( be_isroot( be, op->o_ndn.bv_val ) ) { + if ( be_isroot( be, &op->o_ndn ) ) { isroot = 1; } else { ( void ) get_limits( be, op->o_ndn.bv_val, &limit ); diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 54ec297ac8..030db2c5dd 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -121,8 +121,7 @@ monitor_subsys_database_init( attr_merge( e, monitor_ad_desc, bv ); for ( j = 0; be->be_suffix[j]; j++ ) { - val.bv_val = be->be_suffix[j]; - val.bv_len = strlen( val.bv_val ); + val = *be->be_suffix[j]; attr_merge( e, ad_nc, bv ); attr_merge( e_database, ad_nc, bv ); diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 1092e61c68..6f214178ae 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -218,8 +218,9 @@ monitor_back_db_init( struct monitorinfo *mi; Entry *e, *e_tmp; struct monitorentrypriv *mp; - int i; - char buf[1024], *ndn, *end_of_line; + int i, rc; + char buf[1024], *end_of_line; + struct berval dn, *ndn; const char *text; struct berval val, *bv[2] = { &val, NULL }; @@ -241,10 +242,24 @@ monitor_back_db_init( } monitor_defined++; - ndn = ch_strdup( SLAPD_MONITOR_DN ); - charray_add( &be->be_suffix, ndn ); - dn_normalize( ndn ); - ber_bvecadd( &be->be_nsuffix, ber_bvstr( ndn ) ); + ndn = NULL; + dn.bv_val = SLAPD_MONITOR_DN; + dn.bv_len = sizeof( SLAPD_MONITOR_DN ) - 1; + + rc = dnNormalize( NULL, &dn, &ndn ); + if( rc != LDAP_SUCCESS ) { +#ifdef NEW_LOGGING + LDAP_LOG(( "operation", LDAP_LEVEL_CRIT, + "monitor DN \"" SLAPD_MONITOR_DN "\" backend is allowed\n" )); +#else + Debug( LDAP_DEBUG_ANY, + "monitor DN \"" SLAPD_MONITOR_DN "\" backend is allowed\n", + 0, 0, 0 ); +#endif + return -1; + } + + ber_bvecadd( &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 8a05ce281a..1595547817 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -191,7 +191,7 @@ passwd_back_search( int i; for( i=0; be->be_nsuffix[i] != NULL; i++ ) { if( dn_issuffix( nbase, be->be_nsuffix[i]->bv_val ) ) { - matched = be->be_suffix[i]; + matched = be->be_suffix[i]->bv_val; break; } } @@ -293,10 +293,13 @@ pw2entry( Backend *be, struct passwd *pw, char *rdn ) attr_merge( e, ad_objectClass, vals ); /* rdn attribute type should be a configuratable item */ - sprintf( buf, "uid=%s,%s", pw->pw_name, be->be_suffix[0] ); - e->e_dn = ch_strdup( buf ); - e->e_ndn = ch_strdup( buf ); - (void) dn_normalize( e->e_ndn ); + sprintf( buf, "uid=%s,%s", pw->pw_name, be->be_suffix[0]->bv_val ); + e->e_name.bv_val = ch_strdup( buf ); + e->e_name.bv_len = strlen( e->e_name.bv_val ); + + e->e_nname.bv_val = ch_strdup( buf ); + (void) dn_normalize( e->e_nname ); + e->e_nname.bv_len = strlen( e->e_name.bv_val ); val.bv_val = pw->pw_name; val.bv_len = strlen( pw->pw_name ); diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index f2dd0e4593..5516118adf 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -111,6 +111,6 @@ print_suffixes( int i; for ( i = 0; be->be_suffix[i] != NULL; i++ ) { - fprintf( fp, "suffix: %s\n", be->be_suffix[i] ); + fprintf( fp, "suffix: %s\n", be->be_suffix[i].bv_val ); } } diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 367f933fac..23af5819d5 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -547,7 +547,7 @@ int backsql_search(BackendDB *be,Connection *conn,Operation *op, /* TimesTen : Pass it along to the lower level routines */ srch_info.isTimesTen = bi->isTimesTen; - if (tlimit == 0 && be_isroot(be,op->o_ndn.bv_val)) + if (tlimit == 0 && be_isroot(be,&op->o_ndn)) { tlimit = -1; /* allow root to set no limit */ } @@ -558,7 +558,7 @@ int backsql_search(BackendDB *be,Connection *conn,Operation *op, stoptime = op->o_time + tlimit; } - if (slimit == 0 && be_isroot(be,op->o_ndn.bv_val)) + if (slimit == 0 && be_isroot(be,&op->o_ndn)) { slimit = -1; /* allow root to set no limit */ } diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 88fd1f8118..12951245cd 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -241,11 +241,11 @@ int backend_startup(Backend *be) #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, "backend_startup: starting \"%s\"\n", - be->be_suffix[0] )); + be->be_suffix[0]->bv_val )); #else Debug( LDAP_DEBUG_TRACE, "backend_startup: starting \"%s\"\n", - be->be_suffix[0], 0, 0 ); + be->be_suffix[0]->bv_val, 0, 0 ); #endif if ( be->bd_info->bi_open ) { @@ -417,7 +417,7 @@ int backend_destroy(void) backendDB[i].bd_info->bi_db_destroy( &backendDB[i] ); } - charray_free( backendDB[i].be_suffix ); + ber_bvecfree( backendDB[i].be_suffix ); ber_bvecfree( backendDB[i].be_nsuffix ); free( backendDB[i].be_rootdn.bv_val ); free( backendDB[i].be_rootndn.bv_val ); @@ -594,11 +594,9 @@ be_issuffix( } int -be_isroot( Backend *be, const char *ndn ) +be_isroot( Backend *be, struct berval *ndn ) { - int rc; - - if ( ndn == NULL || *ndn == '\0' ) { + if ( !ndn->bv_len ) { return( 0 ); } @@ -606,9 +604,7 @@ be_isroot( Backend *be, const char *ndn ) return( 0 ); } - rc = strcmp( be->be_rootndn.bv_val, ndn ) ? 0 : 1; - - return(rc); + return strcmp( be->be_rootndn.bv_val, ndn->bv_val ) ? 0 : 1; } int @@ -638,12 +634,16 @@ be_root_dn( Backend *be ) int be_isroot_pw( Backend *be, Connection *conn, - const char *ndn, + const char *dn, struct berval *cred ) { int result; - if ( ! be_isroot( be, ndn ) ) { + struct berval ndn; + ndn.bv_val = (char *) dn; + ndn.bv_len = dn ? strlen( dn ) : 0; + + if ( ! be_isroot( be, &ndn ) ) { return 0; } @@ -960,8 +960,8 @@ int backend_check_referrals( Backend *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn ) + struct berval *dn, + struct berval *ndn ) { int rc = LDAP_SUCCESS; @@ -969,7 +969,7 @@ int backend_check_referrals( const char *text; rc = be->be_chk_referrals( be, - conn, op, dn, ndn, &text ); + conn, op, dn->bv_val, ndn->bv_val, &text ); if( rc != LDAP_SUCCESS && rc != LDAP_REFERRAL ) { send_ldap_result( conn, op, rc, @@ -987,7 +987,7 @@ backend_group( Operation *op, Entry *target, const char *gr_ndn, - const char *op_ndn, + struct berval *op_ndn, ObjectClass *group_oc, AttributeDescription *group_at ) @@ -1029,7 +1029,7 @@ backend_group( if( be->be_group ) { int res = be->be_group( be, conn, op, - target, gr_ndn, op_ndn, + target, gr_ndn, op_ndn->bv_val, group_oc, group_at ); if (op->o_tag != LDAP_REQ_BIND) { @@ -1109,8 +1109,7 @@ Attribute *backend_operational( * add them to the attribute list */ if ( ( opattrs || attrs ) && be && be->be_operational != NULL ) { - ( void )be->be_operational( be, conn, op, e, - attrs, opattrs, ap ); + ( void )be->be_operational( be, conn, op, e, attrs, opattrs, ap ); } return a; diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 696ed48bb4..8062fd42c7 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -328,7 +328,7 @@ glue_back_search ( if (scope == LDAP_SCOPE_ONELEVEL && !strcmp (gi->n[i].pdn, ndn)) { rc = be->be_search (be, conn, op, - be->be_suffix[0], + be->be_suffix[0]->bv_val, be->be_nsuffix[0]->bv_val, LDAP_SCOPE_BASE, deref, s2limit, t2limit, filter, filterstr, @@ -336,7 +336,7 @@ glue_back_search ( } else if (scope == LDAP_SCOPE_SUBTREE && dnIsSuffix(be->be_nsuffix[0], &bv)) { rc = be->be_search (be, conn, op, - be->be_suffix[0], + be->be_suffix[0]->bv_val, be->be_nsuffix[0]->bv_val, scope, deref, s2limit, t2limit, filter, filterstr, diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 163a4f538c..58cbe2a32d 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -260,7 +260,7 @@ do_compare( } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, pdn->bv_val, ndn->bv_val ); + rc = backend_check_referrals( be, conn, op, pdn, ndn ); if ( rc != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 81b9223c94..ad0449ece3 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -979,11 +979,11 @@ read_config( const char *fname ) 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] )); + 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] ); + fname, lineno, tmp_be->be_suffix[0]->bv_val ); #endif ber_bvfree( pdn ); ber_bvfree( ndn ); @@ -1003,7 +1003,7 @@ read_config( const char *fname ) #endif } - charray_add( &be->be_suffix, pdn->bv_val ); + ber_bvecadd( &be->be_suffix, pdn ); ber_bvecadd( &be->be_nsuffix, ndn ); /* set database suffixAlias */ @@ -1107,12 +1107,12 @@ 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] )); + 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] ); + fname, lineno, tmp_be->be_suffix[0]->bv_val ); #endif ber_bvfree( palias ); return -1; @@ -1158,13 +1158,13 @@ read_config( const char *fname ) #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: suffixAlias derefs to a different backend " - "a preceeding backend \"%s\" (ignored)\n", - fname, lineno, tmp_be->be_suffix[0] )); + "a preceeding backend \"%s\"\n", + 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\" (ignored)\n", - fname, lineno, tmp_be->be_suffix[0] ); + " a preceeding backend \"%s\"\n", + fname, lineno, tmp_be->be_suffix[0]->bv_val ); #endif ber_bvfree( palias ); ber_bvfree( paliased ); diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 51874a539f..51c2b472fc 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -81,7 +81,7 @@ config_info( strcpy( buf, backends[i].be_type ); for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { strcat( buf, " : " ); - strcat( buf, backends[i].be_suffix[j] ); + strcat( buf, backends[i].be_suffix[j]->bv_val ); } val.bv_val = buf; val.bv_len = strlen( buf ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 08c3d24686..e579d98371 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -163,7 +163,7 @@ do_delete( } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, pdn->bv_val, ndn->bv_val ); + rc = backend_check_referrals( be, conn, op, pdn, ndn ); if ( rc != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 9b1ece0d29..a1316fc983 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -317,7 +317,7 @@ do_modify( } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, pdn->bv_val, ndn->bv_val ); + rc = backend_check_referrals( be, conn, op, pdn, ndn ); if ( rc != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index cb3d6238db..b28bae6c10 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -343,7 +343,7 @@ do_modrdn( } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, pdn->bv_val, ndn->bv_val ); + rc = backend_check_referrals( be, conn, op, pdn, ndn ); if ( rc != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 1f2ffdefc0..e6822de750 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -88,13 +88,20 @@ LDAP_SLAPD_F (void) acl_free LDAP_P(( AccessControl *a )); * at.c */ -LDAP_SLAPD_F (void) at_config LDAP_P(( const char *fname, int lineno, int argc, char **argv )); -LDAP_SLAPD_F (AttributeType *) at_find LDAP_P(( const char *name )); -LDAP_SLAPD_F (int) at_find_in_list LDAP_P(( AttributeType *sat, AttributeType **list )); -LDAP_SLAPD_F (int) at_append_to_list LDAP_P(( AttributeType *sat, AttributeType ***listp )); -LDAP_SLAPD_F (int) at_delete_from_list LDAP_P(( int pos, AttributeType ***listp )); +LDAP_SLAPD_F (void) at_config LDAP_P(( + const char *fname, int lineno, + int argc, char **argv )); +LDAP_SLAPD_F (AttributeType *) at_find LDAP_P(( + const char *name )); +LDAP_SLAPD_F (int) at_find_in_list LDAP_P(( + AttributeType *sat, AttributeType **list )); +LDAP_SLAPD_F (int) at_append_to_list LDAP_P(( + AttributeType *sat, AttributeType ***listp )); +LDAP_SLAPD_F (int) at_delete_from_list LDAP_P(( + int pos, AttributeType ***listp )); LDAP_SLAPD_F (int) at_schema_info LDAP_P(( Entry *e )); -LDAP_SLAPD_F (int) at_add LDAP_P(( LDAPAttributeType *at, const char **err )); +LDAP_SLAPD_F (int) at_add LDAP_P(( + LDAPAttributeType *at, const char **err )); LDAP_SLAPD_F (int) is_at_subtype LDAP_P(( AttributeType *sub, @@ -117,9 +124,12 @@ LDAP_SLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a )); LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e, AttributeDescription *desc, struct berval **vals )); -LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription *desc )); -LDAP_SLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, AttributeDescription *desc )); -LDAP_SLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc )); +LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P(( + Attribute *a, AttributeDescription *desc )); +LDAP_SLAPD_F (Attribute *) attr_find LDAP_P(( + Attribute *a, AttributeDescription *desc )); +LDAP_SLAPD_F (int) attr_delete LDAP_P(( + Attribute **attrs, AttributeDescription *desc )); LDAP_SLAPD_F (void) attrs_free LDAP_P(( Attribute *a )); LDAP_SLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a )); @@ -157,8 +167,10 @@ LDAP_SLAPD_F (BackendDB *) select_backend LDAP_P(( int manageDSAit, int noSubordinates )); -LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be, const char *suffix )); -LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be, const char *ndn )); +LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be, + const char *suffix )); +LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be, + struct berval *ndn )); LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Backend *be, Connection *conn, const char *ndn, struct berval *cred )); LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Backend *be, struct berval *ndn )); @@ -181,8 +193,8 @@ LDAP_SLAPD_F( int ) backend_check_referrals LDAP_P(( BackendDB *be, Connection *conn, Operation *op, - const char *dn, - const char *ndn )); + struct berval *dn, + struct berval *ndn )); LDAP_SLAPD_F (int) backend_connection_init LDAP_P((Connection *conn)); LDAP_SLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn)); @@ -192,7 +204,7 @@ LDAP_SLAPD_F (int) backend_group LDAP_P((BackendDB *be, Operation *op, Entry *target, const char *gr_ndn, - const char *op_ndn, + struct berval *op_ndn, ObjectClass *group_oc, AttributeDescription *group_at )); @@ -304,15 +316,17 @@ LDAP_SLAPD_F (long) connection_init LDAP_P(( LDAP_SLAPD_F (void) connection_closing LDAP_P(( Connection *c )); LDAP_SLAPD_F (int) connection_state_closing LDAP_P(( Connection *c )); -LDAP_SLAPD_F (const char *) connection_state2str LDAP_P(( int state )) LDAP_GCCATTR((const)); +LDAP_SLAPD_F (const char *) connection_state2str LDAP_P(( int state )) + LDAP_GCCATTR((const)); LDAP_SLAPD_F (int) connection_write LDAP_P((ber_socket_t s)); LDAP_SLAPD_F (int) connection_read LDAP_P((ber_socket_t s)); LDAP_SLAPD_F (unsigned long) connections_nextid(void); -LDAP_SLAPD_F (Connection *) connection_first LDAP_P((ber_socket_t *)); -LDAP_SLAPD_F (Connection *) connection_next LDAP_P((Connection *, ber_socket_t *)); +LDAP_SLAPD_F (Connection *) connection_first LDAP_P(( ber_socket_t * )); +LDAP_SLAPD_F (Connection *) connection_next LDAP_P(( + Connection *, ber_socket_t *)); LDAP_SLAPD_F (void) connection_done LDAP_P((Connection *)); LDAP_SLAPD_F (void) connection2anonymous LDAP_P((Connection *)); @@ -406,7 +420,8 @@ typedef int (*SLAP_EXTOP_MAIN_FN) LDAP_P(( typedef int (*SLAP_EXTOP_GETOID_FN) LDAP_P(( int index, char *oid, int blen )); -LDAP_SLAPD_F (int) load_extension LDAP_P((const void *module, const char *file_name)); +LDAP_SLAPD_F (int) load_extension LDAP_P(( + const void *module, const char *file_name)); LDAP_SLAPD_F (char *) get_supported_extension LDAP_P((int index)); LDAP_SLAPD_F (int) load_extop LDAP_P(( @@ -449,7 +464,7 @@ LDAP_SLAPD_F (int) add_limits LDAP_P(( Backend *be, int type, const char *pattern, struct slap_limits_set *limit )); LDAP_SLAPD_F (int) parse_limits LDAP_P(( - Backend *be, const char *fname, int lineno, int argc, char **argv )); + Backend *be, const char *fname, int lineno, int argc, char **argv )); LDAP_SLAPD_F (int) parse_limit LDAP_P(( const char *arg, struct slap_limits_set *limit )); @@ -690,8 +705,10 @@ LDAP_SLAPD_F (int) is_object_subclass LDAP_P(( ObjectClass *sup )); -LDAP_SLAPD_F (Syntax *) syn_find LDAP_P((const char *synname)); -LDAP_SLAPD_F (Syntax *) syn_find_desc LDAP_P((const char *syndesc, int *slen)); +LDAP_SLAPD_F (Syntax *) syn_find LDAP_P(( + const char *synname )); +LDAP_SLAPD_F (Syntax *) syn_find_desc LDAP_P(( + const char *syndesc, int *slen )); #ifdef SLAPD_BINARY_CONVERSION LDAP_SLAPD_F (int) syn_add LDAP_P(( LDAPSyntax *syn, @@ -701,7 +718,7 @@ LDAP_SLAPD_F (int) syn_add LDAP_P(( slap_syntax_transform_func *pretty, slap_syntax_transform_func *ber2str, slap_syntax_transform_func *str2ber, - const char **err)); + const char **err )); #else LDAP_SLAPD_F (int) syn_add LDAP_P(( LDAPSyntax *syn, @@ -709,11 +726,11 @@ LDAP_SLAPD_F (int) syn_add LDAP_P(( slap_syntax_validate_func *validate, slap_syntax_transform_func *normalize, slap_syntax_transform_func *pretty, - const char **err)); + const char **err )); #endif LDAP_SLAPD_F (MatchingRule *) mr_find LDAP_P((const char *mrname)); -LDAP_SLAPD_F (int) mr_add LDAP_P((LDAPMatchingRule *mr, +LDAP_SLAPD_F (int) mr_add LDAP_P(( LDAPMatchingRule *mr, unsigned usage, slap_mr_convert_func *convert, slap_mr_normalize_func *normalize, @@ -721,7 +738,7 @@ LDAP_SLAPD_F (int) mr_add LDAP_P((LDAPMatchingRule *mr, slap_mr_indexer_func *indexer, slap_mr_filter_func *filter, MatchingRule * associated, - const char **err)); + const char **err )); LDAP_SLAPD_F (int) register_syntax LDAP_P(( const char *desc, @@ -744,8 +761,10 @@ LDAP_SLAPD_F (int) schema_info LDAP_P(( Entry **entry, const char **text )); LDAP_SLAPD_F (int) is_entry_objectclass LDAP_P(( Entry *, ObjectClass *oc )); -#define is_entry_alias(e) is_entry_objectclass((e), slap_schema.si_oc_alias) -#define is_entry_referral(e) is_entry_objectclass((e), slap_schema.si_oc_referral) +#define is_entry_alias(e) \ + is_entry_objectclass((e), slap_schema.si_oc_alias) +#define is_entry_referral(e) \ + is_entry_objectclass((e), slap_schema.si_oc_referral) /* diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index cd0c20c9e5..f2ba8e0273 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -87,8 +87,7 @@ root_dse_info( if ( backends[i].be_glueflags & SLAP_GLUE_SUBORDINATE ) continue; for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { - val.bv_val = backends[i].be_suffix[j]; - val.bv_len = strlen( val.bv_val ); + val = *backends[i].be_suffix[j]; attr_merge( e, ad_namingContexts, vals ); } } diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 5f8d78c0a6..a6d6e36c15 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -317,7 +317,7 @@ do_search( } /* check for referrals */ - rc = backend_check_referrals( be, conn, op, pbase->bv_val, nbase->bv_val ); + rc = backend_check_referrals( be, conn, op, pbase, nbase ); if ( rc != LDAP_SUCCESS ) { goto return_results; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index c72f119ace..02b7d6f5a0 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -850,7 +850,7 @@ typedef struct slap_backend_db BackendDB; /* per backend database */ LDAP_SLAPD_V (int) nBackendInfo; LDAP_SLAPD_V (int) nBackendDB; -LDAP_SLAPD_V (BackendInfo *) backendInfo; +LDAP_SLAPD_V (BackendInfo *) backendInfo; LDAP_SLAPD_V (BackendDB *) backendDB; LDAP_SLAPD_V (int) slapMode; @@ -889,9 +889,13 @@ struct slap_limits { #define SLAP_LIMITS_ANONYMOUS 0x0006 #define SLAP_LIMITS_USERS 0x0007 regex_t lm_dn_regex; /* regex data for REGEX */ - struct berval *lm_dn_pat; /* ndn for EXACT, BASE, ONE, SUBTREE, - * CHILDREN; pattern for REGEX; NULL - * for ANONYMOUS, USERS */ + + /* + * normalized DN for EXACT, BASE, ONE, SUBTREE, CHILDREN; + * pattern for REGEX; NULL for ANONYMOUS, USERS + */ + struct berval *lm_dn_pat; + struct slap_limits_set lm_limits; }; @@ -981,7 +985,7 @@ struct slap_backend_db { slap_ssf_set_t be_ssf_set; /* these should be renamed from be_ to bd_ */ - char **be_suffix; /* the DN suffixes of data in this backend */ + 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 */ struct berval be_rootdn; /* the magic "root" name (DN) for this db */ @@ -998,6 +1002,7 @@ struct slap_backend_db { char *be_replogfile; /* replication log file (in master) */ struct berval be_update_ndn; /* allowed to make changes (in replicas) */ struct berval **be_update_refs; /* where to refer modifying clients to */ + char *be_realm; int be_lastmod; /* keep track of lastmodified{by,time} */ #define SLAP_GLUE_INSTANCE 0x01 /* a glue backend */ @@ -1005,9 +1010,6 @@ struct slap_backend_db { #define SLAP_GLUE_LINKED 0x04 /* child is connected to parent */ int be_glueflags; /* */ - - char *be_realm; - void *be_private; /* anything the backend database needs */ }; diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 2e9fdeca59..dd25c6cd2c 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -79,7 +79,7 @@ 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] : "", + be ? be->be_suffix[0]->bv_val : "", e->e_dn ); fprintf( stderr, "%s: line %d: " "database (%s) not configured to hold \"%s\"\n", -- 2.39.5