From: Howard Chu Date: Wed, 6 Oct 2004 05:51:38 +0000 (+0000) Subject: Revert ITS#3353 patch, it needs to be reworked. X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~457 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7e87f547160f78690b4fe2a6bdf7f67505de8ee4;p=openldap Revert ITS#3353 patch, it needs to be reworked. --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 51666859a4..a1e9992870 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -203,14 +203,14 @@ fe_op_add( Operation *op, SlapReply *rs ) */ op->o_bd = select_backend( &e->e_nname, manageDSAit, 0 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); - if ( !rs->sr_ref ) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if ( !rs->sr_ref ) rs->sr_ref = default_referral; if ( rs->sr_ref ) { rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } } else { @@ -329,17 +329,17 @@ fe_op_add( Operation *op, SlapReply *rs ) #endif /* LDAP_SLAPI */ defref = op->o_bd->be_update_refs - ? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral); + ? op->o_bd->be_update_refs : default_referral; if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); if ( rs->sr_ref == NULL ) rs->sr_ref = defref; rs->sr_err = LDAP_REFERRAL; - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } } else { diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 141fe32829..95efcc21bb 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -1166,7 +1166,7 @@ bdb_txn_get( Operation *op, DB_ENV *env, DB_TXN **txn ) if ( ldap_pvt_thread_pool_getkey( ctx, ((char *)env)+1, &data, NULL ) ) { for ( i=0, rc=1; rc != 0 && i<4; i++ ) { - rc = TXN_BEGIN( env, NULL, txn, 0 ); + rc = TXN_BEGIN( env, NULL, txn, DB_TXN_NOT_DURABLE ); if (rc) ldap_pvt_thread_yield(); } if ( rc != 0) { diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index f595658e1b..7a3b279bf0 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -74,7 +74,7 @@ dn2entry_retry: e = NULL; } else { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); } diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 6a38c76fb5..80dfedaa74 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -165,7 +165,7 @@ retry: /* transaction retry */ ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -174,10 +174,10 @@ retry: /* transaction retry */ rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 5f7b81433a..7c634390b7 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -177,7 +177,7 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect ); /* One long-lived TXN per thread, two TXNs per write op */ - bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, SLAPD_GLOBAL(connection_pool_max) * 3 ); + bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 ); if ( bdb->bi_idl_cache_max_size ) { bdb->bi_idl_tree = NULL; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 047f21f3f3..f5c77763c3 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -399,7 +399,7 @@ retry: /* transaction retry */ ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -408,10 +408,10 @@ retry: /* transaction retry */ rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 1856ed401c..d234353ae3 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -188,7 +188,7 @@ retry: /* transaction retry */ ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -198,7 +198,7 @@ retry: /* transaction retry */ send_ldap_result( op, rs ); ber_bvarray_free( rs->sr_ref ); - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c index 9cc054063d..9b8d434deb 100644 --- a/servers/slapd/back-bdb/referral.c +++ b/servers/slapd/back-bdb/referral.c @@ -94,9 +94,9 @@ dn2entry_retry: bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &lock); e = NULL; - } else if ( SLAPD_GLOBAL(default_referral) != NULL ) { + } else if ( default_referral != NULL ) { rc = LDAP_OTHER; - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 7c109ce390..39f84b4e0c 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -612,7 +612,7 @@ dn2entry_retry: } } else { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &sop->o_req_dn, sop->oq_search.rs_scope ); } diff --git a/servers/slapd/back-dnssrv/referral.c b/servers/slapd/back-dnssrv/referral.c index a4823cbc74..1d5ba88edb 100644 --- a/servers/slapd/back-dnssrv/referral.c +++ b/servers/slapd/back-dnssrv/referral.c @@ -57,7 +57,7 @@ dnssrv_back_referrals( if( ldap_dn2domain( op->o_req_dn.bv_val, &domain ) || domain == NULL ) { rs->sr_err = LDAP_REFERRAL; - rs->sr_ref = SLAPD_GLOBAL(default_referral); + rs->sr_ref = default_referral; send_ldap_result( op, rs ); return LDAP_REFERRAL; } diff --git a/servers/slapd/back-dnssrv/search.c b/servers/slapd/back-dnssrv/search.c index 267e00da35..40c03230f0 100644 --- a/servers/slapd/back-dnssrv/search.c +++ b/servers/slapd/back-dnssrv/search.c @@ -59,7 +59,7 @@ dnssrv_back_search( if( ldap_dn2domain( op->o_req_dn.bv_val, &domain ) || domain == NULL ) { rs->sr_err = LDAP_REFERRAL; - rs->sr_ref = SLAPD_GLOBAL(default_referral); + rs->sr_ref = default_referral; send_ldap_result( op, rs ); rs->sr_ref = NULL; goto done; diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index d2ff930d72..13a4fc57fc 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -46,12 +46,12 @@ int init_module(int argc, char *argv[]) { #endif /* SLAPD_LDAP */ -int +static int ldap_back_open( BackendInfo *bi ) { - bi->bi_controls = SLAPD_GLOBAL(known_controls); + bi->bi_controls = slap_known_controls; return 0; } diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 1f99585dff..9bb32cd762 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -109,7 +109,7 @@ ldbm_back_add( cache_return_entry_r( &li->li_cache, matched ); } else { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); } diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 8afc624a6a..936d26c244 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -48,7 +48,7 @@ ldbm_back_compare( : NULL; cache_return_entry_r( &li->li_cache, matched ); } else { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); } diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 93bd7ced40..e8cce87234 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -333,7 +333,7 @@ ldbm_cache_sync_daemon( sleep( li->li_dbsyncfreq ); - while (i && ldap_pvt_thread_pool_backload(&SLAPD_GLOBAL(connection_pool)) != 0) { + while (i && ldap_pvt_thread_pool_backload(&connection_pool) != 0) { Debug( LDAP_DEBUG_TRACE, "delay syncing %s\n", li->li_directory, 0, 0 ); sleep(li->li_dbsyncwaitinterval); i--; diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index aceed450de..81358859bf 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -70,7 +70,7 @@ ldbm_back_delete( ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -82,7 +82,7 @@ ldbm_back_delete( send_ldap_result( op, rs ); if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref ); - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index 9a7d9b6d22..f63de5be92 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -61,7 +61,7 @@ id2entry_add( Backend *be, Entry *e ) #endif key.dsize = sizeof(ID); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); data.dptr = entry2str( e, &len ); data.dsize = len + 1; @@ -69,7 +69,7 @@ id2entry_add( Backend *be, Entry *e ) flags = LDBM_REPLACE; rc = ldbm_cache_store( db, key, data, flags ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); ldbm_cache_close( be, db ); diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 31a498fd52..4754cf3c09 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -265,7 +265,7 @@ ldbm_back_modify( ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -276,7 +276,7 @@ ldbm_back_modify( send_ldap_result( op, rs ); if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref ); - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index c05d6741bd..5a6229f1bf 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -93,7 +93,7 @@ ldbm_back_modrdn( ber_bvarray_add( &deref, &tmpbv ); } } else { - deref = SLAPD_GLOBAL(default_referral); + deref = default_referral; } rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); @@ -105,7 +105,7 @@ ldbm_back_modrdn( send_ldap_result( op, rs ); if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref ); - if ( deref != SLAPD_GLOBAL(default_referral) ) { + if ( deref != default_referral ) { ber_bvarray_free( deref ); } free( (char *)rs->sr_matched ); diff --git a/servers/slapd/back-ldbm/referral.c b/servers/slapd/back-ldbm/referral.c index 838426549e..8f01f958dc 100644 --- a/servers/slapd/back-ldbm/referral.c +++ b/servers/slapd/back-ldbm/referral.c @@ -62,9 +62,9 @@ ldbm_back_referrals( cache_return_entry_r( &li->li_cache, matched ); - } else if ( SLAPD_GLOBAL(default_referral) != NULL ) { + } else if ( default_referral != NULL ) { rs->sr_err = LDAP_OTHER; - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); } diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index bd3a037738..2b09370615 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -102,7 +102,7 @@ ldbm_back_search( } } else { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, op->ors_scope ); } diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index 4607cb76d6..3b3decd93f 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -47,7 +47,7 @@ meta_back_open( BackendInfo *bi ) { - bi->bi_controls = SLAPD_GLOBAL(known_controls); + bi->bi_controls = slap_known_controls; return 0; } diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index e14fb05242..ce61417eb4 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -252,7 +252,7 @@ conn_create( assert( ep != NULL ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); #endif #ifdef HACK_LOCAL_TIME # ifdef HAVE_LOCALTIME_R @@ -280,7 +280,7 @@ conn_create( # endif /* HAVE_GMTIME_R */ #endif /* !HACK_LOCAL_TIME */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif snprintf( buf, sizeof( buf ), @@ -314,7 +314,7 @@ conn_create( } #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); #endif #ifdef HAVE_GMTIME_R @@ -332,7 +332,7 @@ conn_create( lutil_gentime( buf3, sizeof( buf3 ), ltm ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif /* HAVE_GMTIME_R */ /* monitored info */ diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 2fbee60ac0..c06e4d9eb1 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -618,25 +618,25 @@ monitor_back_db_open( * Start */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); #endif #ifdef HACK_LOCAL_TIME # ifdef HAVE_LOCALTIME_R - tms = localtime_r( &SLAPD_GLOBAL(starttime), &tm_buf ); + tms = localtime_r( &starttime, &tm_buf ); # else - tms = localtime( &SLAPD_GLOBAL(starttime) ); + tms = localtime( &starttime ); # endif /* HAVE_LOCALTIME_R */ lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone ); #else /* !HACK_LOCAL_TIME */ # ifdef HAVE_GMTIME_R - tms = gmtime_r( &SLAPD_GLOBAL(starttime), &tm_buf ); + tms = gmtime_r( &starttime, &tm_buf ); # else - tms = gmtime( &SLAPD_GLOBAL(starttime) ); + tms = gmtime( &starttime ); # endif /* HAVE_GMTIME_R */ lutil_gentime( tmbuf, sizeof(tmbuf), tms ); #endif /* !HACK_LOCAL_TIME */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif mi->mi_startTime.bv_val = tmbuf; diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 4f27f33984..96c635bdba 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -175,21 +175,21 @@ monitor_subsys_ops_update( ldap_pvt_mp_init( nInitiated ); ldap_pvt_mp_init( nCompleted ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); for ( i = 0; i < SLAP_OP_LAST; i++ ) { - ldap_pvt_mp_add( nInitiated, SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] ); - ldap_pvt_mp_add( nCompleted, SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] ); + ldap_pvt_mp_add( nInitiated, slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_add( nCompleted, slap_counters.sc_ops_completed_[ i ] ); } - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); } else { for ( i = 0; i < SLAP_OP_LAST; i++ ) { if ( dn_match( &rdn, &monitor_op[ i ].nrdn ) ) { - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); - ldap_pvt_mp_init_set( nInitiated, SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] ); - ldap_pvt_mp_init_set( nCompleted, SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); + ldap_pvt_mp_init_set( nInitiated, slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_init_set( nCompleted, slap_counters.sc_ops_completed_[ i ] ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); break; } } diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index d59767d444..9f3df46618 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -171,28 +171,28 @@ monitor_subsys_sent_update( return 0; } - ldap_pvt_thread_mutex_lock(&SLAPD_GLOBAL(counters).sc_sent_mutex); + ldap_pvt_thread_mutex_lock(&slap_counters.sc_sent_mutex); switch ( i ) { case MONITOR_SENT_ENTRIES: - ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_entries ); + ldap_pvt_mp_init_set( n, slap_counters.sc_entries ); break; case MONITOR_SENT_REFERRALS: - ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_refs ); + ldap_pvt_mp_init_set( n, slap_counters.sc_refs ); break; case MONITOR_SENT_PDU: - ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_pdu ); + ldap_pvt_mp_init_set( n, slap_counters.sc_pdu ); break; case MONITOR_SENT_BYTES: - ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_bytes ); + ldap_pvt_mp_init_set( n, slap_counters.sc_bytes ); break; default: assert(0); } - ldap_pvt_thread_mutex_unlock(&SLAPD_GLOBAL(counters).sc_sent_mutex); + ldap_pvt_thread_mutex_unlock(&slap_counters.sc_sent_mutex); a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter ); assert( a ); diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index e9185b5a69..ca96631998 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -73,7 +73,7 @@ monitor_subsys_thread_init( mi->mi_oc_monitoredObject->soc_cname.bv_val, mi->mi_oc_monitoredObject->soc_cname.bv_val, mi->mi_ad_monitoredInfo->ad_cname.bv_val, - SLAPD_GLOBAL(connection_pool_max), + connection_pool_max, mi->mi_creatorsName.bv_val, mi->mi_creatorsName.bv_val, mi->mi_startTime.bv_val, @@ -189,7 +189,7 @@ monitor_subsys_thread_update( } snprintf( buf, sizeof( buf ), "%d", - ldap_pvt_thread_pool_backload( &SLAPD_GLOBAL(connection_pool) ) ); + ldap_pvt_thread_pool_backload( &connection_pool ) ); len = strlen( buf ); if ( len > a->a_vals[ 0 ].bv_len ) { a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 ); diff --git a/servers/slapd/back-monitor/time.c b/servers/slapd/back-monitor/time.c index ed4cba40a2..2c894dd393 100644 --- a/servers/slapd/back-monitor/time.c +++ b/servers/slapd/back-monitor/time.c @@ -193,7 +193,7 @@ monitor_subsys_time_update( currtime = slap_get_time(); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); #endif #ifdef HACK_LOCAL_TIME # ifdef HAVE_LOCALTIME_R @@ -211,7 +211,7 @@ monitor_subsys_time_update( lutil_gentime( tmbuf, sizeof( tmbuf ), tm ); #endif /* !HACK_LOCAL_TIME */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif len = strlen( tmbuf ); diff --git a/servers/slapd/back-perl/add.c b/servers/slapd/back-perl/add.c index 11942e6e41..8a89f8948d 100644 --- a/servers/slapd/back-perl/add.c +++ b/servers/slapd/back-perl/add.c @@ -27,7 +27,7 @@ perl_back_add( int count; ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); { dSP; ENTER; SAVETMPS; @@ -55,7 +55,7 @@ perl_back_add( PUTBACK; FREETMPS; LEAVE; } - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); send_ldap_result( op, rs ); diff --git a/servers/slapd/back-relay/op.c b/servers/slapd/back-relay/op.c index dca3de486f..881e77a830 100644 --- a/servers/slapd/back-relay/op.c +++ b/servers/slapd/back-relay/op.c @@ -66,17 +66,17 @@ relay_back_select_backend( struct slap_op *op, struct slap_rep *rs, int err ) } if ( bd == NULL ) { - if ( SLAPD_GLOBAL(default_referral) ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + if ( default_referral ) { + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); if ( !rs->sr_ref ) { - rs->sr_ref = SLAPD_GLOBAL(default_referral); + rs->sr_ref = default_referral; } rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index 33bd70797f..d1d02296bc 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -71,9 +71,9 @@ shell_back_add( fprintf( wfp, "ADD\n" ); fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid ); print_suffixes( wfp, op->o_bd ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); fprintf( wfp, "%s", entry2str( op->oq_add.rs_e, &len ) ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); fclose( wfp ); /* read in the result and send it along */ diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index 2b3f8232fb..19fd90ef72 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -889,7 +889,7 @@ backsql_add( Operation *op, SlapReply *rs ) op->oq_add.rs_e->e_name.bv_val, 0, 0 ); /* check schema */ - if ( SLAPD_GLOBAL(schemachecking) ) { + if ( global_schemacheck ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e, diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 638b754075..1153bd0ec7 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -565,7 +565,7 @@ next:; bsi, 0, AVL_INORDER ); } - if ( SLAPD_GLOBAL(schemachecking) ) { + if ( global_schemacheck ) { const char *text = NULL; char textbuf[ 1024 ]; size_t textlen = sizeof( textbuf ); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 14df526356..4c1d58a1be 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -344,9 +344,9 @@ int backend_startup(Backend *be) } } - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(runqueue).rq_mutex ); - LDAP_STAILQ_INIT( &SLAPD_GLOBAL(runqueue).task_list ); - LDAP_STAILQ_INIT( &SLAPD_GLOBAL(runqueue).run_list ); + ldap_pvt_thread_mutex_init( &syncrepl_rq.rq_mutex ); + LDAP_STAILQ_INIT( &syncrepl_rq.task_list ); + LDAP_STAILQ_INIT( &syncrepl_rq.run_list ); /* open each backend database */ for( i = 0; i < nBackendDB; i++ ) { @@ -378,10 +378,10 @@ int backend_startup(Backend *be) LDAP_STAILQ_FOREACH( si, &backendDB[i].be_syncinfo, si_next ) { si->si_be = &backendDB[i]; init_syncrepl( si ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); - ldap_pvt_runqueue_insert( &SLAPD_GLOBAL(runqueue), + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + ldap_pvt_runqueue_insert( &syncrepl_rq, si->si_interval, do_syncrepl, (void *) si ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); } } } @@ -782,7 +782,7 @@ be_isroot_pw( Operation *op ) } #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_lock( &passwd_mutex ); #ifdef SLAPD_SPASSWD lutil_passwd_sasl_conn = op->o_conn->c_sasl_authctx; #endif @@ -794,7 +794,7 @@ be_isroot_pw( Operation *op ) #ifdef SLAPD_SPASSWD lutil_passwd_sasl_conn = NULL; #endif - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_unlock( &passwd_mutex ); #endif return result == 0; @@ -1109,7 +1109,7 @@ backend_check_restrictions( return rs->sr_err; } - if( !( SLAPD_GLOBAL(allows) & SLAP_ALLOW_UPDATE_ANON ) && + if( !( global_allows & SLAP_ALLOW_UPDATE_ANON ) && op->o_ndn.bv_len == 0 ) { rs->sr_text = "modifications require authentication"; diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index ad3f34a917..f65ee40f47 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -577,7 +577,7 @@ int glue_sub_init( ) { int i, j; - int cont = SLAPD_GLOBAL(num_subordinates); + int cont = num_subordinates; BackendDB *b1, *be; BackendInfo *bi = NULL; glueinfo *gi; diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index f06652000d..836e9d4ce5 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -183,7 +183,7 @@ do_bind( "requested protocol version not supported" ); goto cleanup; - } else if (!( SLAPD_GLOBAL(allows) & SLAP_ALLOW_BIND_V2 ) && + } else if (!( global_allows & SLAP_ALLOW_BIND_V2 ) && version < LDAP_VERSION3 ) { send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, @@ -298,7 +298,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) } if( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming_auth); + ber_len_t max = sockbuf_max_incoming_auth; ber_sockbuf_ctrl( op->o_conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } @@ -373,20 +373,20 @@ fe_op_bind( Operation *op, SlapReply *rs ) rs->sr_err = LDAP_SUCCESS; if( !BER_BVISEMPTY( &op->orb_cred ) && - !( SLAPD_GLOBAL(allows) & SLAP_ALLOW_BIND_ANON_CRED )) + !( global_allows & SLAP_ALLOW_BIND_ANON_CRED )) { /* cred is not empty, disallow */ rs->sr_err = LDAP_INVALID_CREDENTIALS; } else if ( !BER_BVISEMPTY( &op->o_req_ndn ) && - !( SLAPD_GLOBAL(allows) & SLAP_ALLOW_BIND_ANON_DN )) + !( global_allows & SLAP_ALLOW_BIND_ANON_DN )) { /* DN is not empty, disallow */ rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "unauthenticated bind (DN with no password) disallowed"; - } else if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_BIND_ANON ) { + } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) { /* disallow */ rs->sr_err = LDAP_INAPPROPRIATE_AUTH; rs->sr_text = "anonymous bind disallowed"; @@ -404,7 +404,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) op->o_protocol, 0, 0 ); goto cleanup; - } else if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_BIND_SIMPLE ) { + } else if ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) { /* disallow simple authentication */ rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "unwilling to perform simple authentication"; @@ -418,7 +418,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND } else if ( op->orb_method == LDAP_AUTH_KRBV41 ) { - if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_BIND_KRBV4 ) { + if ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) { /* disallow krbv4 authentication */ rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "unwilling to perform Kerberos V4 bind"; @@ -533,7 +533,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); BER_BVZERO( &op->o_req_ndn ); if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming_auth); + ber_len_t max = sockbuf_max_incoming_auth; ber_sockbuf_ctrl( op->o_conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } @@ -572,7 +572,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) ber_dupbv( &op->o_conn->c_ndn, &op->o_req_ndn ); if( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming_auth); + ber_len_t max = sockbuf_max_incoming_auth; ber_sockbuf_ctrl( op->o_conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 66d0d85c14..506e34736b 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -203,14 +203,14 @@ fe_op_compare( Operation *op, SlapReply *rs ) */ op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); rs->sr_err = LDAP_REFERRAL; - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; send_ldap_result( op, rs ); - if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); rs->sr_err = 0; goto cleanup; } diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 9b4877058c..5a03edbf9e 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "slap.h" #ifdef LDAP_SLAPI @@ -46,11 +45,38 @@ /* * defaults for various global variables */ +slap_mask_t global_allows = 0; +slap_mask_t global_disallows = 0; +char *replogfile; +int global_gentlehup = 0; +int global_idletimeout = 0; +char *global_host = NULL; +char *global_realm = NULL; +char *ldap_srvtab = ""; +char **default_passwd_hash = NULL; int cargc = 0, cargv_size = 0; char **cargv; +struct berval default_search_base = BER_BVNULL; +struct berval default_search_nbase = BER_BVNULL; +unsigned num_subordinates = 0; + +ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT; +ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH; + +int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT; +int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH; + +char *slapd_pid_file = NULL; +char *slapd_args_file = NULL; char *strtok_quote_ptr; +int use_reverse_lookup = 0; + +#ifdef LDAP_SLAPI +int slapi_plugins_used = 0; +#endif + static char *fp_getline(FILE *fp, int *lineno); static void fp_getline_init(int *lineno); static int fp_parse_line(int lineno, char *line); @@ -61,64 +87,6 @@ static int load_ucdata(char *path); static int add_syncrepl LDAP_P(( Backend *, char **, int )); static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *)); -Global slap_Configuration; -extern BackendDB slap_frontendDB, *frontendDB; - -void config_init(void) { - /* system config defaults */ - Global *g = &slap_Configuration; - memset(g, 0, sizeof(slap_Configuration)); - - /* because we need frontendDB* before frontend_init, paint it black */ - frontendDB = &slap_frontendDB; - memset(frontendDB, 0, sizeof(frontendDB)); - - g->schemachecking = 1; - - g->connection_pool_max = SLAP_MAX_WORKER_THREADS; - - g->sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT; - g->sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH; - - g->conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT; - g->conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH; - - g->local_ssf = LDAP_PVT_SASL_LOCAL_SSF; - - /* XXX scope issue */ -#ifdef notdef -#ifdef LDAP_DEBUG - g->syslog = LDAP_DEBUG_STATS; -#endif - -#ifdef LOG_DEBUG - g->syslog_level = LOG_DEBUG; -#endif -#endif - -#ifdef HAVE_SYSCONF - g->dtblsize = sysconf( _SC_OPEN_MAX ); -#elif HAVE_GETDTABLESIZE - g->dtblsize = getdtablesize(); -#else - g->dtblsize = FD_SETSIZE; -#endif - -#ifdef FD_SETSIZE - if(g->dtblsize > FD_SETSIZE) g->dtblsize = FD_SETSIZE; -#endif /* !FD_SETSIZE */ - - g->index_substr_if_minlen = SLAP_INDEX_SUBSTR_IF_MINLEN_DEFAULT; - g->index_substr_if_maxlen = SLAP_INDEX_SUBSTR_IF_MAXLEN_DEFAULT; - g->index_substr_any_len = SLAP_INDEX_SUBSTR_ANY_LEN_DEFAULT; - g->index_substr_any_step = SLAP_INDEX_SUBSTR_ANY_STEP_DEFAULT; - - /* XXX when doing mutex, we may have to know slapMode */ - - frontendDB->be_private = g; -} - - int read_config( const char *fname, int depth ) { @@ -241,7 +209,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(local_ssf) = ssf; + local_ssf = ssf; /* set thread concurrency */ } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) { @@ -271,7 +239,6 @@ read_config( const char *fname, int depth ) } ldap_pvt_thread_set_concurrency( c ); - SLAPD_GLOBAL(conf_concurrency) = c; /* set substring initial/final index minimum length */ } else if ( strcasecmp( cargv[0], "index_substr_if_minlen" ) == 0 ) { @@ -283,14 +250,14 @@ read_config( const char *fname, int depth ) return( 1 ); } min = atoi( cargv[1] ); - if( min < 1 || min > SLAPD_GLOBAL(index_substr_if_maxlen) ) { + if( min < 1 || min > index_substr_if_maxlen ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid min value (%ld) in " "\"index_substr_if_minlen \" line.\n", fname, lineno, min ); return( 1 ); } - SLAPD_GLOBAL(index_substr_if_minlen) = min; + index_substr_if_minlen = min; /* set substring initial/final index maximum length */ } else if ( strcasecmp( cargv[0], "index_substr_if_maxlen" ) == 0 ) { @@ -302,14 +269,14 @@ read_config( const char *fname, int depth ) return( 1 ); } max = atol( cargv[1] ); - if( max < 1 || max < SLAPD_GLOBAL(index_substr_if_minlen) ) { + if( max < 1 || max < index_substr_if_minlen ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: invalid max value (%ld) in " "\"index_substr_maxlen \" line.\n", fname, lineno, max ); return( 1 ); } - SLAPD_GLOBAL(index_substr_if_maxlen) = max; + index_substr_if_maxlen = max; /* set substring any index len */ } else if ( strcasecmp( cargv[0], "index_substr_any_len" ) == 0 ) { @@ -328,7 +295,7 @@ read_config( const char *fname, int depth ) fname, lineno, len ); return( 1 ); } - SLAPD_GLOBAL(index_substr_any_len) = len; + index_substr_any_len = len; /* set substring any index step */ } else if ( strcasecmp( cargv[0], "index_substr_any_step" ) == 0 ) { @@ -347,7 +314,7 @@ read_config( const char *fname, int depth ) fname, lineno, step ); return( 1 ); } - SLAPD_GLOBAL(index_substr_any_step) = step; + index_substr_any_step = step; /* set sockbuf max */ } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) { @@ -371,7 +338,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(sockbuf_max_incoming) = max; + sockbuf_max_incoming = max; /* set sockbuf max authenticated */ } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) { @@ -395,7 +362,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(sockbuf_max_incoming_auth) = max; + sockbuf_max_incoming_auth = max; /* set conn pending max */ } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) { @@ -419,7 +386,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(conn_max_pending) = max; + slap_conn_max_pending = max; /* set conn pending max authenticated */ } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) { @@ -443,7 +410,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(conn_max_pending_auth) = max; + slap_conn_max_pending_auth = max; /* default search base */ } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) { @@ -470,14 +437,14 @@ read_config( const char *fname, int depth ) return 1; } - if ( SLAPD_GLOBAL(default_search_nbase).bv_len ) { + if ( default_search_nbase.bv_len ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: " "default search base \"%s\" already defined " "(discarding old)\n", - fname, lineno, SLAPD_GLOBAL(default_search_base).bv_val ); + fname, lineno, default_search_base.bv_val ); - free( SLAPD_GLOBAL(default_search_base).bv_val ); - free( SLAPD_GLOBAL(default_search_nbase).bv_val ); + free( default_search_base.bv_val ); + free( default_search_nbase.bv_val ); } if ( load_ucdata( NULL ) < 0 ) return 1; @@ -489,8 +456,8 @@ read_config( const char *fname, int depth ) dn.bv_len = strlen( dn.bv_val ); rc = dnPrettyNormal( NULL, &dn, - &SLAPD_GLOBAL(default_search_base), - &SLAPD_GLOBAL(default_search_nbase), NULL ); + &default_search_base, + &default_search_nbase, NULL ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, @@ -527,10 +494,10 @@ read_config( const char *fname, int depth ) return( 1 ); } - ldap_pvt_thread_pool_maxthreads( &SLAPD_GLOBAL(connection_pool), c ); + ldap_pvt_thread_pool_maxthreads( &connection_pool, c ); /* save for later use */ - SLAPD_GLOBAL(connection_pool_max) = c; + connection_pool_max = c; /* get pid file name */ } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) { @@ -542,7 +509,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(pid_file) = ch_strdup( cargv[1] ); + slapd_pid_file = ch_strdup( cargv[1] ); /* get args file name */ } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) { @@ -554,7 +521,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - SLAPD_GLOBAL(args_file) = ch_strdup( cargv[1] ); + slapd_args_file = ch_strdup( cargv[1] ); } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) { /* ignore */ ; @@ -571,7 +538,7 @@ read_config( const char *fname, int depth ) return( 1 ); } - if ( SLAPD_GLOBAL(default_passwd_hash) != NULL ) { + if ( default_passwd_hash != NULL ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: already set default password_hash!\n", fname, lineno, 0 ); @@ -585,10 +552,10 @@ read_config( const char *fname, int depth ) "%s: line %d: password scheme \"%s\" not available\n", fname, lineno, cargv[i] ); } else { - ldap_charray_add( &SLAPD_GLOBAL(default_passwd_hash), cargv[i] ); + ldap_charray_add( &default_passwd_hash, cargv[i] ); } } - if( !SLAPD_GLOBAL(default_passwd_hash) ) { + if( !default_passwd_hash ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: no valid hashes found\n", fname, lineno, 0 ); @@ -606,7 +573,6 @@ read_config( const char *fname, int depth ) } lutil_salt_format( cargv[1] ); - SLAPD_GLOBAL(conf_salt_format) = ch_strdup(cargv[1]); #ifdef SLAP_AUTH_REWRITE /* use authid rewrite instead of sasl regexp */ @@ -802,7 +768,7 @@ read_config( const char *fname, int depth ) } else { SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE; - SLAPD_GLOBAL(num_subordinates)++; + num_subordinates++; } /* add an overlay to this backend */ @@ -891,11 +857,11 @@ read_config( const char *fname, int depth ) free( ndn.bv_val ); return( 1 ); - } else if( pdn.bv_len == 0 && SLAPD_GLOBAL(default_search_nbase).bv_len ) { + } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: " "suffix DN empty and default " "search base provided \"%s\" (assuming okay)\n", - fname, lineno, SLAPD_GLOBAL(default_search_base).bv_val ); + fname, lineno, default_search_base.bv_val ); } ber_bvarray_add( &be->be_suffix, &pdn ); @@ -1169,7 +1135,7 @@ restrict_unknown:; } } - SLAPD_GLOBAL(allows) |= allows; + global_allows |= allows; /* disallow these features */ } else if ( strcasecmp( cargv[0], "disallows" ) == 0 || @@ -1217,7 +1183,7 @@ restrict_unknown:; } } - SLAPD_GLOBAL(disallows) |= disallows; + global_disallows |= disallows; /* require these features */ } else if ( strcasecmp( cargv[0], "requires" ) == 0 || @@ -1376,7 +1342,7 @@ restrict_unknown:; vals[0].bv_val = cargv[1]; vals[0].bv_len = strlen( vals[0].bv_val ); - if( value_add( &SLAPD_GLOBAL(default_referral), vals ) ) + if( value_add( &default_referral, vals ) ) return LDAP_OTHER; /* start of a new database definition */ @@ -1472,16 +1438,16 @@ restrict_unknown:; Debug( LDAP_DEBUG_ANY, "%s: line %d: schema checking disabled! your mileage may vary!\n", fname, lineno, 0 ); - SLAPD_GLOBAL(schemachecking) = 0; + global_schemacheck = 0; } else { - SLAPD_GLOBAL(schemachecking) = 1; + global_schemacheck = 1; } /* specify access control info */ } else if ( strcasecmp( cargv[0], "access" ) == 0 ) { parse_acl( be, fname, lineno, cargc, cargv ); - /* debug level to log things to ldap_syslog */ + /* debug level to log things to syslog */ } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) { if ( cargc < 2 ) { Debug( LDAP_DEBUG_ANY, @@ -1766,7 +1732,7 @@ restrict_unknown:; if ( be ) { be->be_replogfile = ch_strdup( cargv[1] ); } else { - frontendDB->be_replogfile = ch_strdup( cargv[1] ); + replogfile = ch_strdup( cargv[1] ); } /* file from which to read additional rootdse attrs */ @@ -1824,9 +1790,9 @@ restrict_unknown:; return( 1 ); } if ( strcasecmp( cargv[1], "off" ) == 0 ) { - SLAPD_GLOBAL(gentlehup) = 0; + global_gentlehup = 0; } else { - SLAPD_GLOBAL(gentlehup) = 1; + global_gentlehup = 1; } #endif @@ -1851,7 +1817,7 @@ restrict_unknown:; return( 1 ); } - SLAPD_GLOBAL(idletimeout) = i; + global_idletimeout = i; /* include another config file */ } else if ( strcasecmp( cargv[0], "include" ) == 0 ) { @@ -1881,7 +1847,7 @@ restrict_unknown:; return( 1 ); } - SLAPD_GLOBAL(ldap_srvtab) = ch_strdup( cargv[1] ); + ldap_srvtab = ch_strdup( cargv[1] ); #ifdef SLAPD_MODULES } else if (strcasecmp( cargv[0], "moduleload") == 0 ) { @@ -1986,9 +1952,9 @@ restrict_unknown:; } if ( !strcasecmp( cargv[1], "on" ) ) { - SLAPD_GLOBAL(use_reverse_lookup) = 1; + use_reverse_lookup = 1; } else if ( !strcasecmp( cargv[1], "off" ) ) { - SLAPD_GLOBAL(use_reverse_lookup) = 0; + use_reverse_lookup = 0; } else { Debug( LDAP_DEBUG_ANY, "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n", @@ -2027,7 +1993,7 @@ restrict_unknown:; "config read failed.\n", fname, lineno, 0 ); return( 1 ); } - SLAPD_GLOBAL(slapi_plugins_used)++; + slapi_plugins_used++; #else /* !defined( LDAP_SLAPI ) */ Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI " @@ -2345,15 +2311,14 @@ config_destroy( ) free( frontendDB->be_schemadn.bv_val ); if ( frontendDB->be_acl ) acl_destroy( frontendDB->be_acl, NULL ); - /* globals are part of frontendDB */ - if ( SLAPD_GLOBAL(args_file) ) - free ( SLAPD_GLOBAL(args_file) ); - if ( SLAPD_GLOBAL(pid_file) ) - free ( SLAPD_GLOBAL(pid_file) ); - if ( SLAPD_GLOBAL(default_passwd_hash) ) - ldap_charray_free( SLAPD_GLOBAL(default_passwd_hash) ); } free( line ); + if ( slapd_args_file ) + free ( slapd_args_file ); + if ( slapd_pid_file ) + free ( slapd_pid_file ); + if ( default_passwd_hash ) + ldap_charray_free( default_passwd_hash ); } static int diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 2cea2a8f56..44c4e9faf7 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -107,19 +107,19 @@ int connections_init(void) ldap_pvt_thread_mutex_init( &connections_mutex ); ldap_pvt_thread_mutex_init( &conn_nextid_mutex ); - connections = (Connection *) ch_calloc( SLAPD_GLOBAL(dtblsize), sizeof(Connection) ); + connections = (Connection *) ch_calloc( dtblsize, sizeof(Connection) ); if( connections == NULL ) { Debug( LDAP_DEBUG_ANY, "connections_init: allocation (%d*%ld) of connection array failed\n", - SLAPD_GLOBAL(dtblsize), (long) sizeof(Connection), 0 ); + dtblsize, (long) sizeof(Connection), 0 ); return -1; } assert( connections[0].c_struct_state == SLAP_C_UNINITIALIZED ); - assert( connections[SLAPD_GLOBAL(dtblsize)-1].c_struct_state == SLAP_C_UNINITIALIZED ); + assert( connections[dtblsize-1].c_struct_state == SLAP_C_UNINITIALIZED ); - for (i=0; ic_n_ops_executing || c->c_conn_state == SLAP_C_CLIENT ) continue; - if( difftime( c->c_activitytime+SLAPD_GLOBAL(idletimeout), now) < 0 ) { + if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) { /* close it */ connection_closing( c ); connection_close( c ); @@ -256,7 +256,7 @@ static Connection* connection_get( ber_socket_t s ) { ber_socket_t i, sd; - for(i=0; i 0 ) + if ( global_idletimeout > 0 ) #endif /* ! SLAPD_MONITOR */ { c->c_activitytime = slap_get_time(); @@ -360,7 +360,7 @@ long connection_init( assert( s >= 0 ); #ifndef HAVE_WINSOCK - assert( s < SLAPD_GLOBAL(dtblsize) ); + assert( s < dtblsize ); #endif ldap_pvt_thread_mutex_lock( &connections_mutex ); @@ -373,7 +373,7 @@ long connection_init( ber_socket_t i; c = NULL; - for( i=0; i < SLAPD_GLOBAL(dtblsize); i++) { + for( i=0; i < dtblsize; i++) { ber_socket_t sd; if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) { @@ -406,7 +406,7 @@ long connection_init( if( c == NULL ) { Debug( LDAP_DEBUG_ANY, "connection_init(%d): connection table full " - "(%d/%d)\n", s, i, SLAPD_GLOBAL(dtblsize)); + "(%d/%d)\n", s, i, dtblsize); ldap_pvt_thread_mutex_unlock( &connections_mutex ); return -1; } @@ -445,7 +445,7 @@ long connection_init( c->c_sb = ber_sockbuf_alloc( ); { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming); + ber_len_t max = sockbuf_max_incoming; ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } @@ -457,7 +457,7 @@ long connection_init( ldap_pvt_thread_cond_init( &c->c_write_cv ); #ifdef LDAP_SLAPI - if ( SLAPD_GLOBAL(slapi_plugins_used) ) { + if ( slapi_plugins_used ) { slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION, c ); } #endif @@ -513,7 +513,7 @@ long connection_init( c->c_protocol = 0; #ifndef SLAPD_MONITOR - if ( SLAPD_GLOBAL(idletimeout) > 0 ) + if ( global_idletimeout > 0 ) #endif /* ! SLAPD_MONITOR */ { c->c_activitytime = c->c_starttime = slap_get_time(); @@ -592,7 +592,7 @@ void connection2anonymous( Connection *c ) assert( c != NULL ); { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming); + ber_len_t max = sockbuf_max_incoming; ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } @@ -676,7 +676,7 @@ connection_destroy( Connection *c ) c->c_sb = ber_sockbuf_alloc( ); { - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming); + ber_len_t max = sockbuf_max_incoming; ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max ); } @@ -685,7 +685,7 @@ connection_destroy( Connection *c ) #ifdef LDAP_SLAPI /* call destructors, then constructors; avoids unnecessary allocation */ - if ( SLAPD_GLOBAL(slapi_plugins_used) ) { + if ( slapi_plugins_used ) { slapi_int_clear_object_extensions( SLAPI_X_EXT_CONNECTION, c ); } #endif @@ -809,7 +809,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) { assert( connections != NULL ); assert( index != NULL ); - assert( *index <= SLAPD_GLOBAL(dtblsize) ); + assert( *index <= dtblsize ); if( c != NULL ) { ldap_pvt_thread_mutex_unlock( &c->c_mutex ); @@ -817,7 +817,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) c = NULL; - for(; *index < SLAPD_GLOBAL(dtblsize); (*index)++) { + for(; *index < dtblsize; (*index)++) { if( connections[*index].c_struct_state == SLAP_C_UNINITIALIZED ) { assert( connections[*index].c_conn_state == SLAP_C_INVALID ); #ifndef HAVE_WINSOCK @@ -865,16 +865,16 @@ void connection_done( Connection *c ) /* FIXME: returns 0 in case of failure */ #define INCR_OP_INITIATED(index) \ do { \ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); \ - ldap_pvt_mp_add_ulong(SLAPD_GLOBAL(counters).sc_ops_initiated_[(index)], 1); \ - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); \ + ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \ + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_initiated_[(index)], 1); \ + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \ } while (0) #define INCR_OP_COMPLETED(index) \ do { \ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); \ - ldap_pvt_mp_add_ulong(SLAPD_GLOBAL(counters).sc_ops_completed, 1); \ - ldap_pvt_mp_add_ulong(SLAPD_GLOBAL(counters).sc_ops_completed_[(index)], 1); \ - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); \ + ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); \ + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_completed, 1); \ + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_completed_[(index)], 1); \ + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); \ } while (0) #else /* !SLAPD_MONITOR */ #define INCR_OP_INITIATED(index) @@ -896,10 +896,10 @@ connection_operation( void *ctx, void *arg_v ) void *memctx_null = NULL; ber_len_t memsiz; - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex ); /* FIXME: returns 0 in case of failure */ - ldap_pvt_mp_add_ulong(SLAPD_GLOBAL(counters).sc_ops_initiated, 1); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_mp_add_ulong(slap_counters.sc_ops_initiated, 1); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); op->o_threadctx = ctx; @@ -1053,7 +1053,7 @@ operations_error: assert( 0 ); } #endif /* SLAPD_MONITOR */ - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex ); if ( op->o_cancel == SLAP_CANCEL_REQ ) { op->o_cancel = LDAP_TOO_LATE; @@ -1190,7 +1190,7 @@ int connection_read(ber_socket_t s) if ( c->c_conn_state == SLAP_C_CLIENT ) { slapd_clr_read( s, 0 ); - ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(connection_pool), + ldap_pvt_thread_pool_submit( &connection_pool, c->c_clientfunc, c->c_clientarg ); connection_return( c ); ldap_pvt_thread_mutex_unlock( &connections_mutex ); @@ -1203,7 +1203,7 @@ int connection_read(ber_socket_t s) #ifdef HAVE_TLS if ( c->c_is_tls && c->c_needs_tls_accept ) { - rc = ldap_pvt_tls_accept( c->c_sb, SLAPD_GLOBAL(tls_ctx) ); + rc = ldap_pvt_tls_accept( c->c_sb, slap_tls_ctx ); if ( rc < 0 ) { #if 0 /* required by next #if 0 */ struct timeval tv; @@ -1490,7 +1490,7 @@ connection_input( defer = "closing"; } else if (tag != LDAP_REQ_ABANDON && conn->c_writewaiter) { defer = "awaiting write"; - } else if (conn->c_n_ops_executing >= SLAPD_GLOBAL(connection_pool_max)/2) { + } else if (conn->c_n_ops_executing >= connection_pool_max/2) { defer = "too many executing"; } else if (conn->c_conn_state == SLAP_C_BINDING) { defer = "binding"; @@ -1500,8 +1500,8 @@ connection_input( if( defer ) { int max = conn->c_dn.bv_len - ? SLAPD_GLOBAL(conn_max_pending_auth) - : SLAPD_GLOBAL(conn_max_pending); + ? slap_conn_max_pending_auth + : slap_conn_max_pending; Debug( LDAP_DEBUG_ANY, "connection_input: conn=%lu deferring operation: %s\n", @@ -1577,7 +1577,7 @@ connection_resched( Connection *conn ) } while ((op = LDAP_STAILQ_FIRST( &conn->c_pending_ops )) != NULL) { - if ( conn->c_n_ops_executing > SLAPD_GLOBAL(connection_pool_max)/2 ) { + if ( conn->c_n_ops_executing > connection_pool_max/2 ) { break; } LDAP_STAILQ_REMOVE_HEAD( &conn->c_pending_ops, o_next ); @@ -1642,7 +1642,7 @@ static int connection_op_activate( Operation *op ) LDAP_STAILQ_INSERT_TAIL( &op->o_conn->c_ops, op, o_next ); - status = ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(connection_pool), + status = ldap_pvt_thread_pool_submit( &connection_pool, connection_operation, (void *) op ); if ( status != 0 ) { diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index f0087be056..bdf2666ed9 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -68,8 +68,9 @@ static LDAP_SLIST_HEAD(ControlsList, slap_control) controls_list = LDAP_SLIST_HEAD_INITIALIZER(&controls_list); /* - * all known request control OIDs should be added to global known_controls + * all known request control OIDs should be added to this list */ +char **slap_known_controls = NULL; static char *proxy_authz_extops[] = { LDAP_EXOP_MODIFY_PASSWD, @@ -171,28 +172,28 @@ register_supported_control(const char *controloid, } sc->sc_parse = controlparsefn; - /* Update SLAPD_GLOBAL(known_controls), too. */ - if ( SLAPD_GLOBAL(known_controls) == NULL ) { - SLAPD_GLOBAL(known_controls) = (char **)SLAP_MALLOC( 2 * sizeof(char *) ); - if ( SLAPD_GLOBAL(known_controls) == NULL ) { + /* Update slap_known_controls, too. */ + if ( slap_known_controls == NULL ) { + slap_known_controls = (char **)SLAP_MALLOC( 2 * sizeof(char *) ); + if ( slap_known_controls == NULL ) { if ( sc->sc_extendedops != NULL ) { ldap_charray_free( sc->sc_extendedops ); } ch_free( sc ); return LDAP_NO_MEMORY; } - SLAPD_GLOBAL(known_controls)[0] = ch_strdup( sc->sc_oid ); - SLAPD_GLOBAL(known_controls)[1] = NULL; + slap_known_controls[0] = ch_strdup( sc->sc_oid ); + slap_known_controls[1] = NULL; } else { char **new_known_controls; - for ( i = 0; SLAPD_GLOBAL(known_controls)[i] != NULL; i++ ) { + for ( i = 0; slap_known_controls[i] != NULL; i++ ) { /* EMPTY */ ; } new_known_controls = (char **)SLAP_REALLOC( - SLAPD_GLOBAL(known_controls), (i + 2) * sizeof(char *) ); + slap_known_controls, (i + 2) * sizeof(char *) ); if ( new_known_controls == NULL ) { if ( sc->sc_extendedops != NULL ) { @@ -201,9 +202,9 @@ register_supported_control(const char *controloid, ch_free( sc ); return LDAP_NO_MEMORY; } - SLAPD_GLOBAL(known_controls) = new_known_controls; - SLAPD_GLOBAL(known_controls)[i++] = ch_strdup( sc->sc_oid ); - SLAPD_GLOBAL(known_controls)[i] = NULL; + slap_known_controls = new_known_controls; + slap_known_controls[i++] = ch_strdup( sc->sc_oid ); + slap_known_controls[i] = NULL; } LDAP_SLIST_NEXT( sc, sc_next ) = NULL; @@ -250,7 +251,7 @@ controls_destroy( void ) } ch_free( sc ); } - ldap_charray_free( SLAPD_GLOBAL(known_controls) ); + ldap_charray_free( slap_known_controls ); } /* diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 17d132c657..b8bd3a62f1 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -40,6 +40,8 @@ #include "ldap_rq.h" +#include + #ifdef HAVE_TCPD #include #define SLAP_STRING_UNKNOWN STRING_UNKNOWN @@ -63,6 +65,10 @@ int slap_inet4or6 = AF_INET; #endif /* globals */ +time_t starttime; +ber_socket_t dtblsize; +slap_ssf_t local_ssf = LDAP_PVT_SASL_LOCAL_SSF; + Listener **slap_listeners = NULL; #define SLAPD_LISTEN 10 @@ -79,6 +85,9 @@ static int waking; do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0) #endif +volatile sig_atomic_t slapd_shutdown = 0, slapd_gentle_shutdown = 0; +volatile sig_atomic_t slapd_abrupt_shutdown = 0; + static struct slap_daemon { ldap_pvt_thread_mutex_t sd_mutex; @@ -107,6 +116,7 @@ static struct slap_daemon { #define LDAPS_SRVTYPE_PREFIX "service:ldaps://" static char** slapd_srvurls = NULL; static SLPHandle slapd_hslp = 0; +int slapd_register_slp = 0; void slapd_slp_init( const char* urls ) { int i; @@ -278,7 +288,7 @@ void slapd_remove(ber_socket_t s, int wasactive, int wake) { emfile = 0; } ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - WAKE_LISTENER(wake || SLAPD_GLOBAL(gentle_shutdown) == 2); + WAKE_LISTENER(wake || slapd_gentle_shutdown == 2); } void slapd_clr_write(ber_socket_t s, int wake) { @@ -723,10 +733,10 @@ static int slap_open_listener( continue; } #ifndef HAVE_WINSOCK - if ( l.sl_sd >= SLAPD_GLOBAL(dtblsize) ) { + if ( l.sl_sd >= dtblsize ) { Debug( LDAP_DEBUG_ANY, "daemon: listener descriptor %ld is too great %ld\n", - (long) l.sl_sd, (long) SLAPD_GLOBAL(dtblsize), 0 ); + (long) l.sl_sd, (long) dtblsize, 0 ); tcp_close( l.sl_sd ); sal++; continue; @@ -886,6 +896,20 @@ int slapd_daemon_init( const char *urls ) return rc; } +#ifdef HAVE_SYSCONF + dtblsize = sysconf( _SC_OPEN_MAX ); +#elif HAVE_GETDTABLESIZE + dtblsize = getdtablesize(); +#else + dtblsize = FD_SETSIZE; +#endif + +#ifdef FD_SETSIZE + if(dtblsize > FD_SETSIZE) { + dtblsize = FD_SETSIZE; + } +#endif /* !FD_SETSIZE */ + /* open a pipe (or something equivalent connected to itself). * we write a byte on this fd whenever we catch a signal. The main * loop will be select'ing on this socket, and will wake up when @@ -940,7 +964,7 @@ int slapd_daemon_init( const char *urls ) i, 0, 0 ); #ifdef HAVE_SLP - if( SLAPD_GLOBAL(register_slp) ) { + if( slapd_register_slp ) { slapd_slp_init( urls ); slapd_slp_reg(); } @@ -961,7 +985,7 @@ slapd_daemon_destroy(void) sockdestroy(); #ifdef HAVE_SLP - if( SLAPD_GLOBAL(register_slp) ) { + if( slapd_register_slp ) { slapd_slp_dereg(); slapd_slp_deinit(); } @@ -1010,14 +1034,14 @@ slapd_daemon_task( #define SLAPD_IDLE_CHECK_LIMIT 4 - if ( SLAPD_GLOBAL(idletimeout) > 0 ) { + if ( global_idletimeout > 0 ) { last_idle_check = slap_get_time(); /* Set the select timeout. * Don't just truncate, preserve the fractions of * seconds to prevent sleeping for zero time. */ - idle.tv_sec = SLAPD_GLOBAL(idletimeout)/SLAPD_IDLE_CHECK_LIMIT; - idle.tv_usec = SLAPD_GLOBAL(idletimeout) - idle.tv_sec * SLAPD_IDLE_CHECK_LIMIT; + idle.tv_sec = global_idletimeout/SLAPD_IDLE_CHECK_LIMIT; + idle.tv_usec = global_idletimeout - idle.tv_sec * SLAPD_IDLE_CHECK_LIMIT; idle.tv_usec *= 1000000 / SLAPD_IDLE_CHECK_LIMIT; } else { idle.tv_sec = 0; @@ -1089,7 +1113,7 @@ slapd_daemon_task( #endif /* initialization complete. Here comes the loop. */ - while ( !SLAPD_GLOBAL(shutdown) ) { + while ( !slapd_shutdown ) { ber_socket_t i; int ns; int at; @@ -1111,30 +1135,30 @@ slapd_daemon_task( struct re_s* rtask; now = slap_get_time(); - if( ( SLAPD_GLOBAL(idletimeout) > 0 ) && + if( ( global_idletimeout > 0 ) && difftime( last_idle_check + - SLAPD_GLOBAL(idletimeout)/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) { + global_idletimeout/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) { connections_timeout_idle( now ); last_idle_check = now; } tv = idle; #ifdef SIGHUP - if( SLAPD_GLOBAL(gentle_shutdown) ) { + if( slapd_gentle_shutdown ) { ber_socket_t active; - if( SLAPD_GLOBAL(gentle_shutdown) == 1 ) { + if( slapd_gentle_shutdown == 1 ) { Debug( LDAP_DEBUG_ANY, "slapd gentle shutdown\n", 0, 0, 0 ); close_listeners( 1 ); frontendDB->be_restrictops |= SLAP_RESTRICT_OP_WRITES; - SLAPD_GLOBAL(gentle_shutdown) = 2; + slapd_gentle_shutdown = 2; } ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); active = slap_daemon.sd_nactives; ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); if( active == 0 ) { - SLAPD_GLOBAL(shutdown) = 2; + slapd_shutdown = 2; break; } } @@ -1176,9 +1200,9 @@ slapd_daemon_task( #ifndef HAVE_WINSOCK nfds = slap_daemon.sd_nfds; #else - nfds = SLAPD_GLOBAL(dtblsize); + nfds = dtblsize; #endif - if ( SLAPD_GLOBAL(idletimeout) && slap_daemon.sd_nactives ) + if ( global_idletimeout && slap_daemon.sd_nactives ) at = 1; ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); @@ -1192,21 +1216,22 @@ slapd_daemon_task( else tvp = NULL; - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); - rtask = ldap_pvt_runqueue_next_sched( &SLAPD_GLOBAL(runqueue), &cat ); + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat ); while ( cat && cat->tv_sec && cat->tv_sec <= now ) { - if ( ldap_pvt_runqueue_isrunning( &SLAPD_GLOBAL(runqueue), rtask )) { - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, 0 ); + if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { + ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); } else { - ldap_pvt_runqueue_runtask( &SLAPD_GLOBAL(runqueue), rtask ); - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, 0 ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); - ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(connection_pool), rtask->routine, (void *) rtask ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_runqueue_runtask( &syncrepl_rq, rtask ); + ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); + ldap_pvt_thread_pool_submit( &connection_pool, + rtask->routine, (void *) rtask ); + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); } - rtask = ldap_pvt_runqueue_next_sched( &SLAPD_GLOBAL(runqueue), &cat ); + rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat ); } - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); if ( cat != NULL ) { time_t diff = difftime( cat->tv_sec, now ); @@ -1256,7 +1281,7 @@ slapd_daemon_task( Debug( LDAP_DEBUG_CONNS, "daemon: select failed (%d): %s\n", err, sock_errstr(err), 0 ); - SLAPD_GLOBAL(shutdown) = 2; + slapd_shutdown = 2; } } continue; @@ -1270,7 +1295,7 @@ slapd_daemon_task( continue; default: /* something happened - deal with it */ - if( SLAPD_GLOBAL(shutdown) ) continue; + if( slapd_shutdown ) continue; ebadf = 0; Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n", @@ -1373,10 +1398,10 @@ slapd_daemon_task( #ifndef HAVE_WINSOCK /* make sure descriptor number isn't too great */ - if ( s >= SLAPD_GLOBAL(dtblsize) ) { + if ( s >= dtblsize ) { Debug( LDAP_DEBUG_ANY, "daemon: %ld beyond descriptor table size %ld\n", - (long) s, (long) SLAPD_GLOBAL(dtblsize), 0 ); + (long) s, (long) dtblsize, 0 ); slapd_close(s); ldap_pvt_thread_yield(); @@ -1444,7 +1469,7 @@ slapd_daemon_task( } sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path ); - ssf = SLAPD_GLOBAL(local_ssf); + ssf = local_ssf; { uid_t uid; gid_t gid; @@ -1502,7 +1527,7 @@ slapd_daemon_task( #endif ) { #ifdef SLAPD_RLOOKUPS - if ( SLAPD_GLOBAL(use_reverse_lookup) ) { + if ( use_reverse_lookup ) { char *herr; if (ldap_pvt_get_hname( (const struct sockaddr *)&from, len, hbuf, sizeof(hbuf), &herr ) == 0) { @@ -1662,12 +1687,12 @@ slapd_daemon_task( ldap_pvt_thread_yield(); } - if( SLAPD_GLOBAL(shutdown) == 1 ) { + if( slapd_shutdown == 1 ) { Debug( LDAP_DEBUG_TRACE, "daemon: shutdown requested and initiated.\n", 0, 0, 0 ); - } else if ( SLAPD_GLOBAL(shutdown) == 2 ) { + } else if ( slapd_shutdown == 2 ) { #ifdef HAVE_NT_SERVICE_MANAGER Debug( LDAP_DEBUG_TRACE, "daemon: shutdown initiated by Service Manager.\n", @@ -1683,22 +1708,22 @@ slapd_daemon_task( 0, 0, 0 ); } - if( SLAPD_GLOBAL(gentle_shutdown) != 2 ) { + if( slapd_gentle_shutdown != 2 ) { close_listeners ( 0 ); } free ( slap_listeners ); slap_listeners = NULL; - if( !SLAPD_GLOBAL(gentle_shutdown) ) { - SLAPD_GLOBAL(abrupt_shutdown) = 1; + if( !slapd_gentle_shutdown ) { + slapd_abrupt_shutdown = 1; connections_shutdown(); } Debug( LDAP_DEBUG_ANY, "slapd shutdown: waiting for %d threads to terminate\n", - ldap_pvt_thread_pool_backload(&SLAPD_GLOBAL(connection_pool)), 0, 0 ); - ldap_pvt_thread_pool_destroy(&SLAPD_GLOBAL(connection_pool), 1); + ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 ); + ldap_pvt_thread_pool_destroy(&connection_pool, 1); return NULL; } @@ -1805,13 +1830,20 @@ slap_sig_shutdown( int sig ) else #endif #ifdef SIGHUP - if (sig == SIGHUP && SLAPD_GLOBAL(gentlehup) && SLAPD_GLOBAL(gentle_shutdown) == 0) - SLAPD_GLOBAL(gentle_shutdown) = 1; + if (sig == SIGHUP && global_gentlehup && slapd_gentle_shutdown == 0) + slapd_gentle_shutdown = 1; else #endif - SLAPD_GLOBAL(shutdown) = 1; + slapd_shutdown = 1; - WAKE_LISTENER(1); + if ( sig == SIGTRAP ) + { + slapd_shutdown = 0; + VALGRIND_ATTACH_GDB(1); + } else + { + WAKE_LISTENER(1); + } /* reinstall self */ (void) SIGNAL_REINSTALL( sig, slap_sig_shutdown ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 62eee13b37..36a838b54a 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -117,16 +117,16 @@ fe_op_delete( Operation *op, SlapReply *rs ) */ op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; if ( rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); } else { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); @@ -244,7 +244,7 @@ fe_op_delete( Operation *op, SlapReply *rs ) #ifndef SLAPD_MULTIMASTER } else { BerVarray defref = op->o_bd->be_update_refs - ? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral); + ? op->o_bd->be_update_refs : default_referral; if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 3bd004c482..e77f7c6a4e 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -295,9 +295,9 @@ done2:; if( rs->sr_err != SLAPD_ABANDON ) { if ( rs->sr_err == LDAP_REFERRAL && rs->sr_ref == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, NULL, LDAP_SCOPE_DEFAULT ); - if ( !rs->sr_ref ) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if ( !rs->sr_ref ) rs->sr_ref = default_referral; if ( !rs->sr_ref ) { rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "referral missing"; @@ -306,7 +306,7 @@ done2:; send_ldap_extended( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } diff --git a/servers/slapd/frontend.c b/servers/slapd/frontend.c index 8999baa689..0aedfc0e84 100644 --- a/servers/slapd/frontend.c +++ b/servers/slapd/frontend.c @@ -80,7 +80,7 @@ frontend_init( void ) frontendDB->bd_info->bi_type = "frontend"; /* known controls */ - frontendDB->bd_info->bi_controls = SLAPD_GLOBAL(known_controls); + frontendDB->bd_info->bi_controls = slap_known_controls; /* calls */ frontendDB->bd_info->bi_op_add = fe_op_add; diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 30e1269bc9..b7a3fc3bac 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -44,6 +44,18 @@ */ int slap_debug = 0; +#ifdef LDAP_DEBUG +int ldap_syslog = LDAP_DEBUG_STATS; +#else +int ldap_syslog; +#endif + +#ifdef LOG_DEBUG +int ldap_syslog_level = LOG_DEBUG; +#endif + +BerVarray default_referral = NULL; + struct berval AllUser = BER_BVC( LDAP_ALL_USER_ATTRIBUTES ); struct berval AllOper = BER_BVC( LDAP_ALL_OPERATIONAL_ATTRIBUTES ); struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS ); @@ -51,22 +63,24 @@ struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS ); /* * global variables that need mutex protection */ -#ifdef LDAP_DEBUG -int ldap_syslog = LDAP_DEBUG_STATS; -#else -int ldap_syslog; +ldap_pvt_thread_pool_t connection_pool; +int connection_pool_max = SLAP_MAX_WORKER_THREADS; +#ifndef HAVE_GMTIME_R +ldap_pvt_thread_mutex_t gmtime_mutex; #endif - -#ifdef LOG_DEBUG -int ldap_syslog_level = LOG_DEBUG; -#else -int ldap_syslog_level; +#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) +ldap_pvt_thread_mutex_t passwd_mutex; #endif +slap_counters_t slap_counters; + /* * these mutexes must be used when calling the entry2str() * routine since it returns a pointer to static data. */ +ldap_pvt_thread_mutex_t entry2str_mutex; +ldap_pvt_thread_mutex_t replog_mutex; + static const char* slap_name = NULL; int slapMode = SLAP_UNDEFINED_MODE; @@ -99,34 +113,34 @@ slap_init( int mode, const char *name ) slap_name = name; - ldap_pvt_thread_pool_init( &SLAPD_GLOBAL(connection_pool), - SLAPD_GLOBAL(connection_pool_max), 0); + ldap_pvt_thread_pool_init( &connection_pool, + connection_pool_max, 0); - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(entry2str_mutex) ); - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(replog_mutex) ); + ldap_pvt_thread_mutex_init( &entry2str_mutex ); + ldap_pvt_thread_mutex_init( &replog_mutex ); - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(counters).sc_sent_mutex ); - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(counters).sc_ops_mutex ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_bytes ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_pdu ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_entries ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_refs ); + ldap_pvt_thread_mutex_init( &slap_counters.sc_sent_mutex ); + ldap_pvt_thread_mutex_init( &slap_counters.sc_ops_mutex ); + ldap_pvt_mp_init( slap_counters.sc_bytes ); + ldap_pvt_mp_init( slap_counters.sc_pdu ); + ldap_pvt_mp_init( slap_counters.sc_entries ); + ldap_pvt_mp_init( slap_counters.sc_refs ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_completed ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_initiated ); + ldap_pvt_mp_init( slap_counters.sc_ops_completed ); + ldap_pvt_mp_init( slap_counters.sc_ops_initiated ); #ifdef SLAPD_MONITOR for ( i = 0; i < SLAP_OP_LAST; i++ ) { - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] ); - ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] ); + ldap_pvt_mp_init( slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_init( slap_counters.sc_ops_completed_[ i ] ); } #endif /* SLAPD_MONITOR */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_init( &gmtime_mutex ); #endif #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_init( &passwd_mutex ); #endif rc = slap_sasl_init(); @@ -205,8 +219,8 @@ int slap_destroy(void) "%s destroy: freeing system resources.\n", slap_name, 0, 0 ); - if ( SLAPD_GLOBAL(default_referral) ) { - ber_bvarray_free( SLAPD_GLOBAL(default_referral) ); + if ( default_referral ) { + ber_bvarray_free( default_referral ); } rc = backend_destroy(); @@ -219,19 +233,19 @@ int slap_destroy(void) case SLAP_SERVER_MODE: case SLAP_TOOL_MODE: - ldap_pvt_thread_mutex_destroy( &SLAPD_GLOBAL(counters).sc_sent_mutex ); - ldap_pvt_thread_mutex_destroy( &SLAPD_GLOBAL(counters).sc_ops_mutex ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_bytes ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_pdu ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_entries ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_refs ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_completed ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_initiated ); + ldap_pvt_thread_mutex_destroy( &slap_counters.sc_sent_mutex ); + ldap_pvt_thread_mutex_destroy( &slap_counters.sc_ops_mutex ); + ldap_pvt_mp_clear( slap_counters.sc_bytes ); + ldap_pvt_mp_clear( slap_counters.sc_pdu ); + ldap_pvt_mp_clear( slap_counters.sc_entries ); + ldap_pvt_mp_clear( slap_counters.sc_refs ); + ldap_pvt_mp_clear( slap_counters.sc_ops_completed ); + ldap_pvt_mp_clear( slap_counters.sc_ops_initiated ); #ifdef SLAPD_MONITOR for ( i = 0; i < SLAP_OP_LAST; i++ ) { - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] ); - ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] ); + ldap_pvt_mp_clear( slap_counters.sc_ops_initiated_[ i ] ); + ldap_pvt_mp_clear( slap_counters.sc_ops_completed_[ i ] ); } #endif /* SLAPD_MONITOR */ break; diff --git a/servers/slapd/kerberos.c b/servers/slapd/kerberos.c index b7c6d70917..2fe5afe2f5 100644 --- a/servers/slapd/kerberos.c +++ b/servers/slapd/kerberos.c @@ -46,7 +46,7 @@ krbv4_ldap_auth( strcpy( instance, "*" ); if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad, - SLAPD_GLOBAL(ldap_srvtab) )) != KSUCCESS ) { + ldap_srvtab )) != KSUCCESS ) { Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n", krb_err_txt[err], 0, 0 ); return( LDAP_INVALID_CREDENTIALS ); diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 0270b05bfa..db8403c843 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -133,16 +133,18 @@ static int cnvt_str2int( char *, STRDISP_P, int ); static int check = CHECK_NONE; static int version = 0; +void *slap_tls_ctx; + static int slapd_opt_slp( const char *val, void *arg ) { #ifdef HAVE_SLP /* NULL is default */ if ( val == NULL || strcasecmp( val, "on" ) == 0 ) { - SLAPD_GLOBAL(register_slp) = 1; + slapd_register_slp = 1; } else if ( strcasecmp( val, "off" ) == 0 ) { - SLAPD_GLOBAL(register_slp) = 0; + slapd_register_slp = 0; /* NOTE: add support for URL specification? */ @@ -272,8 +274,6 @@ int main( int argc, char **argv ) slap_sl_mem_init(); - config_init(); /* sets frontendDB */ - serverName = lutil_progname( "slapd", argc, argv ); if ( strcmp( serverName, "slapd" ) ) { @@ -354,12 +354,13 @@ int main( int argc, char **argv ) break; case 'c': /* provide sync cookie, override if exist in replica */ - scp = (struct sync_cookie *) ch_calloc( 1, sizeof( struct sync_cookie )); + scp = (struct sync_cookie *) ch_calloc( 1, + sizeof( struct sync_cookie )); ber_str2bv( optarg, strlen( optarg ), 1, &cookie ); ber_bvarray_add( &scp->octet_str, &cookie ); slap_parse_sync_cookie( scp ); - LDAP_STAILQ_FOREACH( scp_entry, &SLAPD_GLOBAL(sync_cookie), sc_next ) { + LDAP_STAILQ_FOREACH( scp_entry, &slap_sync_cookie, sc_next ) { if ( scp->rid == scp_entry->rid ) { Debug( LDAP_DEBUG_ANY, "main: duplicated replica id in cookies\n", @@ -368,7 +369,7 @@ int main( int argc, char **argv ) goto destroy; } } - LDAP_STAILQ_INSERT_TAIL( &SLAPD_GLOBAL(sync_cookie), scp, sc_next ); + LDAP_STAILQ_INSERT_TAIL( &slap_sync_cookie, scp, sc_next ); break; case 'd': /* set debug level and 'do not detach' flag */ @@ -686,7 +687,7 @@ unhandled_option:; goto destroy; } /* Retrieve slapd's own ctx */ - ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &SLAPD_GLOBAL(tls_ctx) ); + ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx ); /* Restore previous ctx */ ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, def_ctx ); } @@ -703,6 +704,7 @@ unhandled_option:; #endif (void) SIGNAL( SIGINT, slap_sig_shutdown ); (void) SIGNAL( SIGTERM, slap_sig_shutdown ); + (void) SIGNAL( SIGTRAP, slap_sig_shutdown ); #ifdef LDAP_SIGCHLD (void) SIGNAL( LDAP_SIGCHLD, wait4child ); #endif @@ -723,7 +725,7 @@ unhandled_option:; * FIXME: moved here from slapd_daemon_task() * because back-monitor db_open() needs it */ - time( &SLAPD_GLOBAL(starttime) ); + time( &starttime ); if ( slap_startup( NULL ) != 0 ) { rc = 1; @@ -734,21 +736,21 @@ unhandled_option:; Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); - if ( SLAPD_GLOBAL(pid_file) != NULL ) { - FILE *fp = fopen( SLAPD_GLOBAL(pid_file), "w" ); + if ( slapd_pid_file != NULL ) { + FILE *fp = fopen( slapd_pid_file, "w" ); if( fp != NULL ) { fprintf( fp, "%d\n", (int) getpid() ); fclose( fp ); } else { - free(SLAPD_GLOBAL(pid_file)); - SLAPD_GLOBAL(pid_file) = NULL; + free(slapd_pid_file); + slapd_pid_file = NULL; } } - if ( SLAPD_GLOBAL(args_file) != NULL ) { - FILE *fp = fopen( SLAPD_GLOBAL(args_file), "w" ); + if ( slapd_args_file != NULL ) { + FILE *fp = fopen( slapd_args_file, "w" ); if( fp != NULL ) { for ( i = 0; i < g_argc; i++ ) { @@ -757,8 +759,8 @@ unhandled_option:; fprintf( fp, "\n" ); fclose( fp ); } else { - free(SLAPD_GLOBAL(args_file)); - SLAPD_GLOBAL(args_file) = NULL; + free(slapd_args_file); + slapd_args_file = NULL; } } @@ -783,9 +785,9 @@ destroy: /* remember an error during destroy */ rc |= slap_destroy(); - while ( !LDAP_STAILQ_EMPTY( &SLAPD_GLOBAL(sync_cookie) )) { - scp = LDAP_STAILQ_FIRST( &SLAPD_GLOBAL(sync_cookie) ); - LDAP_STAILQ_REMOVE_HEAD( &SLAPD_GLOBAL(sync_cookie), sc_next ); + while ( !LDAP_STAILQ_EMPTY( &slap_sync_cookie )) { + scp = LDAP_STAILQ_FIRST( &slap_sync_cookie ); + LDAP_STAILQ_REMOVE_HEAD( &slap_sync_cookie, sc_next ); ch_free( scp ); } @@ -825,11 +827,11 @@ stop: ldap_pvt_tls_destroy(); #endif - if ( SLAPD_GLOBAL(pid_file) != NULL ) { - unlink( SLAPD_GLOBAL(pid_file) ); + if ( slapd_pid_file != NULL ) { + unlink( slapd_pid_file ); } - if ( SLAPD_GLOBAL(args_file) != NULL ) { - unlink( SLAPD_GLOBAL(args_file) ); + if ( slapd_args_file != NULL ) { + unlink( slapd_args_file ); } config_destroy(); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 83a3823474..9158546c1a 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -299,15 +299,15 @@ fe_op_modify( Operation *op, SlapReply *rs ) */ op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; if (rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); } else { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); @@ -448,7 +448,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) /* send a referral */ } else { BerVarray defref = op->o_bd->be_update_refs - ? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral); + ? op->o_bd->be_update_refs : default_referral; if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, NULL, &op->o_req_dn, @@ -779,7 +779,7 @@ int slap_mods_opattrs( #ifdef HAVE_GMTIME_R ltm = gmtime_r( &now, <m_buf ); #else - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); ltm = gmtime( &now ); #endif /* HAVE_GMTIME_R */ lutil_gentime( timebuf, sizeof(timebuf), ltm ); @@ -787,7 +787,7 @@ int slap_mods_opattrs( slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif timestamp.bv_val = timebuf; @@ -805,7 +805,7 @@ int slap_mods_opattrs( if( op->o_tag == LDAP_REQ_ADD ) { struct berval tmpval; - if( SLAPD_GLOBAL(schemachecking) ) { + if( global_schemacheck ) { int rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) return rc; diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 3efcfcc608..1cfd673261 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -231,15 +231,15 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) */ op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; if ( rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); } else { send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); @@ -366,7 +366,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) #ifndef SLAPD_MULTIMASTER } else { BerVarray defref = op->o_bd->be_update_refs - ? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral); + ? op->o_bd->be_update_refs : default_referral; if ( defref != NULL ) { rs->sr_ref = referral_rewrite( defref, diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index 8ddd897755..27ec820fac 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -155,7 +155,7 @@ slap_op_alloc( op->o_sync_slog_list.stqh_last = &LDAP_STAILQ_FIRST( &op->o_sync_slog_list ); #if defined( LDAP_SLAPI ) - if ( SLAPD_GLOBAL(slapi_plugins_used) ) { + if ( slapi_plugins_used ) { op->o_pb = slapi_pblock_new(); slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op ); } diff --git a/servers/slapd/overlays/lastmod.c b/servers/slapd/overlays/lastmod.c index 6c832f41aa..1485713472 100644 --- a/servers/slapd/overlays/lastmod.c +++ b/servers/slapd/overlays/lastmod.c @@ -355,16 +355,16 @@ lastmod_op_func( Operation *op, SlapReply *rs ) return_referral:; op->o_bd->bd_info = (BackendInfo *)on->on_info; - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, op->ors_scope ); if ( !rs->sr_ref ) { - rs->sr_ref = SLAPD_GLOBAL( default_referral ); + rs->sr_ref = default_referral; } rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if ( rs->sr_ref != SLAPD_GLOBAL( default_referral )) { + if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } rs->sr_ref = NULL; @@ -400,14 +400,14 @@ best_guess( Operation *op, currtime = op->o_time; #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL( gmtime_mutex )); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); tm = gmtime( &currtime ); #else /* HAVE_GMTIME_R */ tm = gmtime_r( &currtime, &tm_buf ); #endif /* HAVE_GMTIME_R */ lutil_gentime( tmbuf, sizeof( tmbuf ), tm ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif ber_str2bv( tmbuf, 0, 1, bv_modifyTimestamp ); @@ -874,14 +874,14 @@ lastmod_db_open( * Start */ #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL( gmtime_mutex )); - tms = gmtime( &SLAPD_GLOBAL( starttime )); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); + tms = gmtime( &starttime ); #else /* HAVE_GMTIME_R */ - tms = gmtime_r( &SLAPD_GLOBAL( starttime ), &tm_buf ); + tms = gmtime_r( &starttime, &tm_buf ); #endif /* HAVE_GMTIME_R */ lutil_gentime( tmbuf, sizeof(tmbuf), tms ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL( gmtime_mutex )); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) { diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 3f4ffd31b9..3b667e5380 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1123,12 +1123,12 @@ proxy_cache_response( * wake it back up */ if ( cm->cc_paused ) { - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); if ( cm->cc_paused ) { cm->cc_paused = 0; - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), cm->cc_arg, 0 ); + ldap_pvt_runqueue_resched( &syncrepl_rq, cm->cc_arg, 0 ); } - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); } } @@ -1464,15 +1464,15 @@ consistency_check( } ldap_pvt_thread_mutex_unlock(&cm->remove_mutex); } - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); - if ( ldap_pvt_runqueue_isrunning( &SLAPD_GLOBAL(runqueue), rtask )) { - ldap_pvt_runqueue_stoptask( &SLAPD_GLOBAL(runqueue), rtask ); + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { + ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask ); } /* If there were no queries, defer processing for a while */ cm->cc_paused = pause; - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, pause ); + ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, pause ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); return NULL; } @@ -1730,10 +1730,10 @@ proxy_cache_open( /* There is no runqueue in TOOL mode */ if ( slapMode & SLAP_SERVER_MODE ) { - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); - ldap_pvt_runqueue_insert( &SLAPD_GLOBAL(runqueue), cm->cc_period, + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); + ldap_pvt_runqueue_insert( &syncrepl_rq, cm->cc_period, consistency_check, on ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); /* Cached database must have the rootdn */ if ( BER_BVISNULL( &cm->db.be_rootndn ) diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index 514a49f68c..958da9ee6b 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -710,10 +710,10 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs ) } now = slap_get_time(); /* stored for later consideration */ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); tm = gmtime(&now); lutil_gentime( nowstr, sizeof(nowstr), tm ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); if ( rs->sr_err == LDAP_INVALID_CREDENTIALS ) { int i = 0, fc = 0; @@ -1125,10 +1125,10 @@ ppolicy_add( struct tm *ltm; time_t now = slap_get_time(); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); ltm = gmtime( &now ); lutil_gentime( timebuf, sizeof(timebuf), ltm ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); timestamp.bv_val = timebuf; timestamp.bv_len = strlen(timebuf); @@ -1445,10 +1445,10 @@ do_modify: * up to date. */ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); ltm = gmtime( &now ); lutil_gentime( timebuf, sizeof(timebuf), ltm ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex )); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); timestamp.bv_val = timebuf; timestamp.bv_len = strlen(timebuf); @@ -1676,8 +1676,8 @@ ppolicy_db_init( on->on_bi.bi_private = ch_calloc( sizeof(pp_info), 1 ); - if ( SLAPD_GLOBAL(dtblsize) && !pwcons ) - pwcons = ch_calloc(sizeof(pw_conn), SLAPD_GLOBAL(dtblsize) ); + if ( dtblsize && !pwcons ) + pwcons = ch_calloc(sizeof(pw_conn), dtblsize ); return 0; } diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index c0adac5763..d848e7a6cc 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -119,7 +119,7 @@ int passwd_extop( if(!( !SLAP_SHADOW( op->o_bd ) || be_isupdate( op ))) { /* we SHOULD return a referral in this case */ BerVarray defref = op->o_bd->be_update_refs - ? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral); + ? op->o_bd->be_update_refs : default_referral; if( defref != NULL ) { rs->sr_ref = referral_rewrite( op->o_bd->be_update_refs, @@ -173,9 +173,9 @@ int passwd_extop( ml = ch_malloc( sizeof(Modifications) ); if ( !qpw->rs_modtail ) qpw->rs_modtail = &ml->sml_next; - if ( SLAPD_GLOBAL(default_passwd_hash) ) { - for ( nhash = 0; SLAPD_GLOBAL(default_passwd_hash)[nhash]; nhash++ ); - hashes = SLAPD_GLOBAL(default_passwd_hash); + if ( default_passwd_hash ) { + for ( nhash = 0; default_passwd_hash[nhash]; nhash++ ); + hashes = default_passwd_hash; } else { nhash = 1; hashes = (char **)defhash; @@ -395,7 +395,7 @@ slap_passwd_check( struct berval *bv; #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_lock( &passwd_mutex ); #ifdef SLAPD_SPASSWD lutil_passwd_sasl_conn = conn->c_sasl_authctx; #endif @@ -412,7 +412,7 @@ slap_passwd_check( #ifdef SLAPD_SPASSWD lutil_passwd_sasl_conn = NULL; #endif - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_unlock( &passwd_mutex ); #endif return result; @@ -445,13 +445,13 @@ slap_passwd_hash_type( assert( hash ); #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_lock( &passwd_mutex ); #endif lutil_passwd_hash( cred , hash, new, text ); #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(passwd_mutex) ); + ldap_pvt_thread_mutex_unlock( &passwd_mutex ); #endif } @@ -462,8 +462,8 @@ slap_passwd_hash( const char **text ) { char *hash = NULL; - if ( SLAPD_GLOBAL(default_passwd_hash) ) { - hash = SLAPD_GLOBAL(default_passwd_hash)[0]; + if ( default_passwd_hash ) { + hash = default_passwd_hash[0]; } if ( !hash ) { hash = (char *)defhash[0]; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 8e09977b87..244d4ccd86 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -376,6 +376,10 @@ LDAP_SLAPD_F (char **) slap_str2clist LDAP_P(( char ***, char *, const char * )); +#ifdef LDAP_SLAPI +LDAP_SLAPD_V (int) slapi_plugins_used; +#endif + /* * connection.c */ @@ -470,6 +474,11 @@ LDAP_SLAPD_F (void) slapd_clr_write LDAP_P((ber_socket_t s, int wake)); LDAP_SLAPD_F (void) slapd_set_read LDAP_P((ber_socket_t s, int wake)); LDAP_SLAPD_F (void) slapd_clr_read LDAP_P((ber_socket_t s, int wake)); +LDAP_SLAPD_V (volatile sig_atomic_t) slapd_abrupt_shutdown; +LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown; +LDAP_SLAPD_V (int) slapd_register_slp; +LDAP_SLAPD_V (slap_ssf_t) local_ssf; + /* * dn.c */ @@ -655,6 +664,8 @@ LDAP_SLAPD_V( const struct berval ) slap_empty_bv; LDAP_SLAPD_V( const struct berval ) slap_unknown_bv; LDAP_SLAPD_V( const struct berval ) slap_true_bv; LDAP_SLAPD_V( const struct berval ) slap_false_bv; +LDAP_SLAPD_V( struct slap_sync_cookie_s ) slap_sync_cookie; +LDAP_SLAPD_V( void * ) slap_tls_ctx; /* * index.c @@ -664,19 +675,19 @@ LDAP_SLAPD_F (int) slap_str2index LDAP_P(( const char *str, slap_mask_t *idx )); /* * init.c */ -LDAP_SLAPD_V( int ) ldap_syslog; -LDAP_SLAPD_V( int ) ldap_syslog_level; - LDAP_SLAPD_F (int) slap_init LDAP_P((int mode, const char* name)); LDAP_SLAPD_F (int) slap_startup LDAP_P(( Backend *be )); LDAP_SLAPD_F (int) slap_shutdown LDAP_P(( Backend *be )); LDAP_SLAPD_F (int) slap_destroy LDAP_P((void)); +LDAP_SLAPD_V (char **) slap_known_controls; + /* * kerberos.c */ #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND -LDAP_SLAPD_F (int) krbv4_ldap_auth(); +LDAP_SLAPD_V (char *) ldap_srvtab; +LDAP_SLAPD_V (int) krbv4_ldap_auth(); #endif /* @@ -1136,6 +1147,7 @@ LDAP_SLAPD_F( int ) mods_structural_class( /* * schema_init.c */ +LDAP_SLAPD_V( int ) schema_init_done; LDAP_SLAPD_F (int) slap_schema_init LDAP_P((void)); LDAP_SLAPD_F (void) schema_destroy LDAP_P(( void )); @@ -1208,6 +1220,8 @@ LDAP_SLAPD_F (Filter *) str2filter_x LDAP_P(( Operation *op, const char *str )); * syncrepl.c */ +LDAP_SLAPD_V (struct runqueue_s) syncrepl_rq; + LDAP_SLAPD_F (void) init_syncrepl LDAP_P((syncinfo_t *)); LDAP_SLAPD_F (void*) do_syncrepl LDAP_P((void *, void *)); LDAP_SLAPD_F (int) syncrepl_message_to_entry LDAP_P(( @@ -1294,13 +1308,62 @@ LDAP_SLAPD_F (int) value_add_one LDAP_P(( /* * Other... */ +LDAP_SLAPD_V(unsigned) num_subordinates; + +LDAP_SLAPD_V (unsigned int) index_substr_if_minlen; +LDAP_SLAPD_V (unsigned int) index_substr_if_maxlen; +LDAP_SLAPD_V (unsigned int) index_substr_any_len; +LDAP_SLAPD_V (unsigned int) index_substr_any_step; + +LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming; +LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_auth; +LDAP_SLAPD_V (int) slap_conn_max_pending; +LDAP_SLAPD_V (int) slap_conn_max_pending_auth; + +LDAP_SLAPD_V (slap_mask_t) global_allows; +LDAP_SLAPD_V (slap_mask_t) global_disallows; + +LDAP_SLAPD_V (BerVarray) default_referral; +LDAP_SLAPD_V (char *) replogfile; LDAP_SLAPD_V (const char) Versionstr[]; +LDAP_SLAPD_V (int) global_gentlehup; +LDAP_SLAPD_V (int) global_idletimeout; +LDAP_SLAPD_V (int) global_schemacheck; +LDAP_SLAPD_V (char *) global_host; +LDAP_SLAPD_V (char *) global_realm; +LDAP_SLAPD_V (char **) default_passwd_hash; LDAP_SLAPD_V (int) lber_debug; +LDAP_SLAPD_V (int) ldap_syslog; +LDAP_SLAPD_V (struct berval) default_search_base; +LDAP_SLAPD_V (struct berval) default_search_nbase; + +LDAP_SLAPD_V (slap_counters_t) slap_counters; + +LDAP_SLAPD_V (char *) slapd_pid_file; +LDAP_SLAPD_V (char *) slapd_args_file; +LDAP_SLAPD_V (time_t) starttime; /* use time(3) -- no mutex */ #define slap_get_time() time( NULL ) +LDAP_SLAPD_V (ldap_pvt_thread_pool_t) connection_pool; +LDAP_SLAPD_V (int) connection_pool_max; + +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) entry2str_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) replog_mutex; + +#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) passwd_mutex; +#endif +#ifndef HAVE_GMTIME_R +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) gmtime_mutex; +#endif + +LDAP_SLAPD_V (ber_socket_t) dtblsize; + +LDAP_SLAPD_V (int) use_reverse_lookup; + LDAP_SLAPD_V (struct berval) AllUser; LDAP_SLAPD_V (struct berval) AllOper; LDAP_SLAPD_V (struct berval) NoAttrs; diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index 8ebc23ac75..f8ac323a84 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -135,14 +135,14 @@ replog( Operation *op ) int subsets = 0; long now = slap_get_time(); - if ( op->o_bd->be_replogfile == NULL && frontendDB->be_replogfile == NULL ) { + if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) { return; } - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(replog_mutex) ); + ldap_pvt_thread_mutex_lock( &replog_mutex ); if ( (fp = lock_fopen( op->o_bd->be_replogfile ? op->o_bd->be_replogfile : - frontendDB->be_replogfile, "a", &lfp )) == NULL ) { - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) ); + replogfile, "a", &lfp )) == NULL ) { + ldap_pvt_thread_mutex_unlock( &replog_mutex ); return; } @@ -183,7 +183,7 @@ replog( Operation *op ) /* if no replicas matched, drop the log * (should we log it anyway?) */ lock_fclose( fp, lfp ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) ); + ldap_pvt_thread_mutex_unlock( &replog_mutex ); return; } @@ -231,7 +231,7 @@ replog( Operation *op ) } lock_fclose( fp, lfp ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) ); + ldap_pvt_thread_mutex_unlock( &replog_mutex ); } static void diff --git a/servers/slapd/result.c b/servers/slapd/result.c index a9fae8697e..fe2f6e0c2f 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -447,10 +447,10 @@ send_ldap_response( } #endif /* LDAP_SLAPI */ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_pdu, 1 ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_bytes, bytes ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); + ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, bytes ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); cleanup:; /* Tell caller that we did this for real, as opposed to being @@ -1175,11 +1175,11 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) } rs->sr_nentries++; - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_bytes, bytes ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_entries, 1 ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_pdu, 1 ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); + ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, bytes ); + ldap_pvt_mp_add_ulong( slap_counters.sc_entries, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); } Statslog( LDAP_DEBUG_STATS2, "%s ENTRY dn=\"%s\"\n", @@ -1364,11 +1364,11 @@ slap_send_search_reference( Operation *op, SlapReply *rs ) bytes = send_ldap_ber( op->o_conn, ber ); ber_free_buf( ber ); - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_bytes, bytes ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_refs, 1 ); - ldap_pvt_mp_add_ulong( SLAPD_GLOBAL(counters).sc_pdu, 1 ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_sent_mutex ); + ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex ); + ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, bytes ); + ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 ); + ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 ); + ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex ); #ifdef LDAP_CONNECTIONLESS } #endif diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 96450daa39..642decbc88 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -169,7 +169,7 @@ root_dse_info( /* supportedLDAPVersion */ for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) { char buf[BUFSIZ]; - if (!( SLAPD_GLOBAL(allows) & SLAP_ALLOW_BIND_V2 ) && + if (!( global_allows & SLAP_ALLOW_BIND_V2 ) && ( i < LDAP_VERSION3 ) ) { /* version 2 and lower are disallowed */ @@ -197,8 +197,8 @@ root_dse_info( ldap_charray_free( supportedSASLMechanisms ); } - if ( SLAPD_GLOBAL(default_referral) != NULL ) { - if( attr_merge( e, ad_ref, SLAPD_GLOBAL(default_referral), NULL /* FIXME */ ) ) { + if ( default_referral != NULL ) { + if( attr_merge( e, ad_ref, default_referral, NULL /* FIXME */ ) ) { return LDAP_OTHER; } } diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 557fa439b3..3363294e01 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -116,7 +116,7 @@ int slap_sasl_config( int cargc, char **cargv, char *line, return( 1 ); } - if ( SLAPD_GLOBAL(host) != NULL ) { + if ( global_host != NULL ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: already set sasl-host!\n", fname, lineno, 0 ); @@ -124,7 +124,7 @@ int slap_sasl_config( int cargc, char **cargv, char *line, return 1; } else { - SLAPD_GLOBAL(host) = ch_strdup( cargv[1] ); + global_host = ch_strdup( cargv[1] ); } /* set SASL realm */ @@ -137,7 +137,7 @@ int slap_sasl_config( int cargc, char **cargv, char *line, return( 1 ); } - if ( SLAPD_GLOBAL(realm) != NULL ) { + if ( global_realm != NULL ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: already set sasl-realm!\n", fname, lineno, 0 ); @@ -145,7 +145,7 @@ int slap_sasl_config( int cargc, char **cargv, char *line, return 1; } else { - SLAPD_GLOBAL(realm) = ch_strdup( cargv[1] ); + global_realm = ch_strdup( cargv[1] ); } /* SASL security properties */ @@ -969,8 +969,8 @@ int slap_sasl_destroy( void ) #ifdef HAVE_CYRUS_SASL sasl_done(); #endif - free( SLAPD_GLOBAL(host) ); - SLAPD_GLOBAL(host) = NULL; + free( global_host ); + global_host = NULL; return 0; } @@ -1029,8 +1029,8 @@ int slap_sasl_open( Connection *conn, int reopen ) conn->c_sasl_layers = 0; - if( SLAPD_GLOBAL(host) == NULL ) { - SLAPD_GLOBAL(host) = ldap_pvt_get_fqdn( NULL ); + if( global_host == NULL ) { + global_host = ldap_pvt_get_fqdn( NULL ); } /* create new SASL context */ @@ -1061,7 +1061,7 @@ int slap_sasl_open( Connection *conn, int reopen ) *p = ';'; } } - sc = sasl_server_new( "ldap", SLAPD_GLOBAL(host), SLAPD_GLOBAL(realm), + sc = sasl_server_new( "ldap", global_host, global_realm, iplocalport, ipremoteport, session_callbacks, SASL_SUCCESS_DATA, &ctx ); if ( iplocalport != NULL ) { ch_free( iplocalport ); @@ -1070,7 +1070,7 @@ int slap_sasl_open( Connection *conn, int reopen ) ch_free( ipremoteport ); } #else - sc = sasl_server_new( "ldap", SLAPD_GLOBAL(host), SLAPD_GLOBAL(realm), + sc = sasl_server_new( "ldap", global_host, global_realm, session_callbacks, SASL_SECURITY_LAYER, &ctx ); #endif diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index e9de67d782..69d243b04d 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -135,14 +135,14 @@ schema_info( Entry **entry, const char **text ) */ #ifdef HAVE_GMTIME_R - ltm = gmtime_r( &SLAPD_GLOBAL(starttime), <m_buf ); + ltm = gmtime_r( &starttime, <m_buf ); #else - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) ); - ltm = gmtime( &SLAPD_GLOBAL(starttime) ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); + ltm = gmtime( &starttime ); #endif /* HAVE_GMTIME_R */ lutil_gentime( timebuf, sizeof(timebuf), ltm ); #ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) ); + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); #endif vals[0].bv_val = timebuf; diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 9648849c21..0da634d812 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -112,7 +112,7 @@ entry_schema_check( } /* it's a REALLY bad idea to disable schema checks */ - if( !SLAPD_GLOBAL(schemachecking) ) return LDAP_SUCCESS; + if( !global_schemacheck ) return LDAP_SUCCESS; /* find the structural object class attribute */ asc = attr_find( e->e_attrs, ad_structuralObjectClass ); @@ -384,7 +384,7 @@ entry_schema_check( } } } - } else if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_AUX_WO_CR ) { + } else if ( global_disallows & SLAP_DISALLOW_AUX_WO_CR ) { k = -1; } else { k = 0; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 373ff96906..7c85723617 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -60,6 +60,11 @@ #define IA5StringApproxIndexer approxIndexer #define IA5StringApproxFilter approxFilter +unsigned int index_substr_if_minlen = SLAP_INDEX_SUBSTR_IF_MINLEN_DEFAULT; +unsigned int index_substr_if_maxlen = SLAP_INDEX_SUBSTR_IF_MAXLEN_DEFAULT; +unsigned int index_substr_any_len = SLAP_INDEX_SUBSTR_ANY_LEN_DEFAULT; +unsigned int index_substr_any_step = SLAP_INDEX_SUBSTR_ANY_STEP_DEFAULT; + static int inValidate( Syntax *syntax, @@ -406,26 +411,26 @@ octetStringSubstringsIndexer( for( i=0; values[i].bv_val != NULL; i++ ) { /* count number of indices to generate */ if( flags & SLAP_INDEX_SUBSTR_INITIAL ) { - if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_if_maxlen) ) { - nkeys += SLAPD_GLOBAL(index_substr_if_maxlen) - - (SLAPD_GLOBAL(index_substr_if_minlen) - 1); - } else if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) { - nkeys += values[i].bv_len - (SLAPD_GLOBAL(index_substr_if_minlen) - 1); + if( values[i].bv_len >= index_substr_if_maxlen ) { + nkeys += index_substr_if_maxlen - + (index_substr_if_minlen - 1); + } else if( values[i].bv_len >= index_substr_if_minlen ) { + nkeys += values[i].bv_len - (index_substr_if_minlen - 1); } } if( flags & SLAP_INDEX_SUBSTR_ANY ) { - if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) { - nkeys += values[i].bv_len - (SLAPD_GLOBAL(index_substr_any_len) - 1); + if( values[i].bv_len >= index_substr_any_len ) { + nkeys += values[i].bv_len - (index_substr_any_len - 1); } } if( flags & SLAP_INDEX_SUBSTR_FINAL ) { - if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_if_maxlen) ) { - nkeys += SLAPD_GLOBAL(index_substr_if_maxlen) - - (SLAPD_GLOBAL(index_substr_if_minlen) - 1); - } else if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) { - nkeys += values[i].bv_len - (SLAPD_GLOBAL(index_substr_if_minlen) - 1); + if( values[i].bv_len >= index_substr_if_maxlen ) { + nkeys += index_substr_if_maxlen - + (index_substr_if_minlen - 1); + } else if( values[i].bv_len >= index_substr_if_minlen ) { + nkeys += values[i].bv_len - (index_substr_if_minlen - 1); } } } @@ -446,25 +451,25 @@ octetStringSubstringsIndexer( ber_len_t j,max; if( ( flags & SLAP_INDEX_SUBSTR_ANY ) && - ( values[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) ) + ( values[i].bv_len >= index_substr_any_len ) ) { char pre = SLAP_INDEX_SUBSTR_PREFIX; - max = values[i].bv_len - (SLAPD_GLOBAL(index_substr_any_len) - 1); + max = values[i].bv_len - (index_substr_any_len - 1); for( j=0; jsa_initial.bv_val != NULL && - sa->sa_initial.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) + sa->sa_initial.bv_len >= index_substr_if_minlen ) { nkeys++; - if ( sa->sa_initial.bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) && + if ( sa->sa_initial.bv_len > index_substr_if_maxlen && ( flags & SLAP_INDEX_SUBSTR_ANY )) { - nkeys += (sa->sa_initial.bv_len - SLAPD_GLOBAL(index_substr_if_maxlen)) / SLAPD_GLOBAL(index_substr_any_step); + nkeys += (sa->sa_initial.bv_len - index_substr_if_maxlen) / index_substr_any_step; } } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { ber_len_t i; for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { - if( sa->sa_any[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) { + if( sa->sa_any[i].bv_len >= index_substr_any_len ) { /* don't bother accounting with stepping */ nkeys += sa->sa_any[i].bv_len - - ( SLAPD_GLOBAL(index_substr_any_len) - 1 ); + ( index_substr_any_len - 1 ); } } } if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && - sa->sa_final.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) + sa->sa_final.bv_len >= index_substr_if_minlen ) { nkeys++; - if ( sa->sa_final.bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) && + if ( sa->sa_final.bv_len > index_substr_if_maxlen && ( flags & SLAP_INDEX_SUBSTR_ANY )) { - nkeys += (sa->sa_final.bv_len - SLAPD_GLOBAL(index_substr_if_maxlen)) / SLAPD_GLOBAL(index_substr_any_step); + nkeys += (sa->sa_final.bv_len - index_substr_if_maxlen) / index_substr_any_step; } } @@ -569,13 +574,13 @@ octetStringSubstringsFilter ( if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && - sa->sa_initial.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) + sa->sa_initial.bv_len >= index_substr_if_minlen ) { pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX; value = &sa->sa_initial; - klen = SLAPD_GLOBAL(index_substr_if_maxlen) < value->bv_len - ? SLAPD_GLOBAL(index_substr_if_maxlen) : value->bv_len; + klen = index_substr_if_maxlen < value->bv_len + ? index_substr_if_maxlen : value->bv_len; hashDigestify( &HASHcontext, HASHdigest, prefix, pre, syntax, mr, (unsigned char *)value->bv_val, klen ); @@ -584,14 +589,14 @@ octetStringSubstringsFilter ( /* If initial is too long and we have subany indexed, use it * to match the excess... */ - if (value->bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) && (flags & SLAP_INDEX_SUBSTR_ANY)) + if (value->bv_len > index_substr_if_maxlen && (flags & SLAP_INDEX_SUBSTR_ANY)) { ber_len_t j; pre = SLAP_INDEX_SUBSTR_PREFIX; - for ( j=SLAPD_GLOBAL(index_substr_if_maxlen)-1; j <= value->bv_len - SLAPD_GLOBAL(index_substr_any_len); j+=SLAPD_GLOBAL(index_substr_any_step) ) + for ( j=index_substr_if_maxlen-1; j <= value->bv_len - index_substr_any_len; j+=index_substr_any_step ) { hashDigestify( &HASHcontext, HASHdigest, prefix, pre, - syntax, mr, (unsigned char *)&value->bv_val[j], SLAPD_GLOBAL(index_substr_any_len) ); + syntax, mr, (unsigned char *)&value->bv_val[j], index_substr_any_len ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } } @@ -600,18 +605,18 @@ octetStringSubstringsFilter ( if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { ber_len_t i, j; pre = SLAP_INDEX_SUBSTR_PREFIX; - klen = SLAPD_GLOBAL(index_substr_any_len); + klen = index_substr_any_len; for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { - if( sa->sa_any[i].bv_len < SLAPD_GLOBAL(index_substr_any_len) ) { + if( sa->sa_any[i].bv_len < index_substr_any_len ) { continue; } value = &sa->sa_any[i]; for(j=0; - j <= value->bv_len - SLAPD_GLOBAL(index_substr_any_len); - j += SLAPD_GLOBAL(index_substr_any_step) ) + j <= value->bv_len - index_substr_any_len; + j += index_substr_any_step ) { hashDigestify( &HASHcontext, HASHdigest, prefix, pre, syntax, mr, (unsigned char *)&value->bv_val[j], klen ); @@ -622,13 +627,13 @@ octetStringSubstringsFilter ( if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && - sa->sa_final.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) ) + sa->sa_final.bv_len >= index_substr_if_minlen ) { pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX; value = &sa->sa_final; - klen = SLAPD_GLOBAL(index_substr_if_maxlen) < value->bv_len - ? SLAPD_GLOBAL(index_substr_if_maxlen) : value->bv_len; + klen = index_substr_if_maxlen < value->bv_len + ? index_substr_if_maxlen : value->bv_len; hashDigestify( &HASHcontext, HASHdigest, prefix, pre, syntax, mr, (unsigned char *)&value->bv_val[value->bv_len-klen], klen ); @@ -637,14 +642,14 @@ octetStringSubstringsFilter ( /* If final is too long and we have subany indexed, use it * to match the excess... */ - if (value->bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) && (flags & SLAP_INDEX_SUBSTR_ANY)) + if (value->bv_len > index_substr_if_maxlen && (flags & SLAP_INDEX_SUBSTR_ANY)) { ber_len_t j; pre = SLAP_INDEX_SUBSTR_PREFIX; - for ( j=0; j <= value->bv_len - SLAPD_GLOBAL(index_substr_if_maxlen); j+=SLAPD_GLOBAL(index_substr_any_step) ) + for ( j=0; j <= value->bv_len - index_substr_if_maxlen; j+=index_substr_any_step ) { hashDigestify( &HASHcontext, HASHdigest, prefix, pre, - syntax, mr, (unsigned char *)&value->bv_val[j], SLAPD_GLOBAL(index_substr_any_len) ); + syntax, mr, (unsigned char *)&value->bv_val[j], index_substr_any_len ); ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } } @@ -3615,7 +3620,7 @@ slap_schema_init( void ) int i; /* we should only be called once (from main) */ - assert( SLAPD_GLOBAL(schema_init_done) == 0 ); + assert( schema_init_done == 0 ); for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) { res = register_syntax( &syntax_defs[i] ); @@ -3648,7 +3653,7 @@ slap_schema_init( void ) } res = slap_schema_load(); - SLAPD_GLOBAL(schema_init_done) = 1; + schema_init_done = 1; return res; } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 56bef5e6f8..e81009a57b 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -26,6 +26,8 @@ #define OCDEBUG 0 +int schema_init_done = 0; + struct slap_internal_schema slap_schema; static int @@ -1256,7 +1258,7 @@ int slap_schema_check( void ) { /* we should only be called once after schema_init() was called */ - assert( SLAPD_GLOBAL(schema_init_done) == 1 ); + assert( schema_init_done == 1 ); /* * cycle thru attributeTypes to build matchingRuleUse @@ -1265,7 +1267,7 @@ slap_schema_check( void ) return LDAP_OTHER; } - ++SLAPD_GLOBAL(schema_init_done); + ++schema_init_done; return LDAP_SUCCESS; } diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 6205f382fb..630d7c3289 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -25,6 +25,8 @@ #include "slap.h" #include "ldap_schema.h" +int global_schemacheck = 1; /* schemacheck ON is default */ + static void oc_usage(void); static void at_usage(void); diff --git a/servers/slapd/search.c b/servers/slapd/search.c index e1b43f3ef9..9c8043e5c6 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -335,12 +335,12 @@ fe_op_search( Operation *op, SlapReply *rs ) break; } - if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &SLAPD_GLOBAL(default_search_nbase) ) ) { + if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &default_search_nbase ) ) { slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx ); slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - ber_dupbv_x( &op->o_req_dn, &SLAPD_GLOBAL(default_search_base), op->o_tmpmemctx ); - ber_dupbv_x( &op->o_req_ndn, &SLAPD_GLOBAL(default_search_nbase), op->o_tmpmemctx ); + ber_dupbv_x( &op->o_req_dn, &default_search_base, op->o_tmpmemctx ); + ber_dupbv_x( &op->o_req_ndn, &default_search_nbase, op->o_tmpmemctx ); } /* @@ -363,14 +363,14 @@ fe_op_search( Operation *op, SlapReply *rs ) op->o_bd = select_backend( &op->o_req_ndn, be_manageDSAit, 1 ); if ( op->o_bd == NULL ) { - rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral), + rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, op->ors_scope ); - if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral); + if (!rs->sr_ref) rs->sr_ref = default_referral; rs->sr_err = LDAP_REFERRAL; send_ldap_result( op, rs ); - if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) + if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; goto return_results; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 5922bcf6cd..6b762c6bbc 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -55,7 +55,6 @@ #include "ldap_pvt.h" #include "ldap_pvt_thread.h" #include "ldap_queue.h" -#include "ldap_rq.h" LDAP_BEGIN_DECL @@ -2364,15 +2363,13 @@ typedef struct slap_conn { } Connection; -#define SLAPD_GLOBAL(x) (((Global*)frontendDB->be_private)->x) - #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG) #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \ do { \ if ( ldap_debug & (level) ) \ fprintf( stderr, (fmt), (connid), (opid), (arg1), (arg2), (arg3) );\ if ( ldap_syslog & (level) ) \ - syslog( (ldap_syslog_level), (fmt), (connid), (opid), (arg1), \ + syslog( ldap_syslog_level, (fmt), (connid), (opid), (arg1), \ (arg2), (arg3) ); \ } while (0) #define StatslogTest( level ) ((ldap_debug | ldap_syslog) & (level)) @@ -2638,63 +2635,6 @@ typedef struct asntype_to_matchingrule_table { } AsnTypetoMatchingRuleTable; #endif - -typedef struct global_configuration { - unsigned num_subordinates; - ber_len_t sockbuf_max_incoming; - ber_len_t sockbuf_max_incoming_auth; - int conn_max_pending; - int conn_max_pending_auth; - slap_mask_t allows; - slap_mask_t disallows; - int gentlehup; - int idletimeout; - int schemachecking; - char *host; - char *realm; - char **default_passwd_hash; - BerVarray default_referral; - struct berval default_search_base; - struct berval default_search_nbase; - char **known_controls; - int schema_init_done; - char *pid_file; - char *args_file; - time_t starttime; - char *ldap_srvtab; - int connection_pool_max; - slap_ssf_t local_ssf; - ber_socket_t dtblsize; - unsigned int index_substr_if_minlen; - unsigned int index_substr_if_maxlen; - unsigned int index_substr_any_len; - unsigned int index_substr_any_step; - int use_reverse_lookup; /* but ignored if !SLAPD_RLOOKUPS */ - int slapi_plugins_used; /* but ignored if !LDAP_SLAPI */ - - volatile sig_atomic_t abrupt_shutdown; - volatile sig_atomic_t gentle_shutdown; - volatile sig_atomic_t shutdown; - struct slap_sync_cookie_s sync_cookie; - void *tls_ctx; - runqueue_t runqueue; - slap_counters_t counters; - ldap_pvt_thread_pool_t connection_pool; - ldap_pvt_thread_mutex_t entry2str_mutex; - ldap_pvt_thread_mutex_t replog_mutex; -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_t gmtime_mutex; -#endif -#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_t passwd_mutex; -#endif - - /* --- these are just copies */ - int conf_debug; - int conf_concurrency; - char *conf_salt_format; -} Global; - LDAP_END_DECL #include "proto-slap.h" diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index 9596a077ed..2d64827816 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -156,7 +156,7 @@ slapadd( int argc, char **argv ) break; } - if( SLAPD_GLOBAL(schemachecking) ) { + if( global_schemacheck ) { Attribute *sc = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass ); Attribute *oc = attr_find( e->e_attrs, diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index 2d9023df27..6da5f80915 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -121,8 +121,6 @@ slap_tool_init( free( leakfilename ); #endif - config_init(); /* sets frontendDB */ - switch( tool ) { case SLAPADD: options = "b:cd:f:i:l:n:prtuvWw"; diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index 72d303debc..c8e9783803 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -125,7 +125,7 @@ slapi_int_init_connection( int OpType ) { Connection *pConn; - ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming); + ber_len_t max = sockbuf_max_incoming; pConn = (Connection *) slapi_ch_calloc(1, sizeof(Connection)); if (pConn == NULL) { @@ -1180,12 +1180,12 @@ slapi_search_internal( } } - if ( !op->o_req_ndn.bv_len && !BER_BVISNULL( &SLAPD_GLOBAL(default_search_nbase) ) ) { + if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) { slapi_ch_free( (void **)&op->o_req_dn.bv_val ); slapi_ch_free( (void **)&op->o_req_ndn.bv_val ); - ber_dupbv( &op->o_req_dn, &SLAPD_GLOBAL(default_search_base) ); - ber_dupbv( &op->o_req_ndn, &SLAPD_GLOBAL(default_search_nbase) ); + ber_dupbv( &op->o_req_dn, &default_search_base ); + ber_dupbv( &op->o_req_ndn, &default_search_nbase ); } if ( slapi_control_present( controls, diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index bfaf858755..7209e43e98 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -134,9 +134,9 @@ slapi_entry2str( #ifdef LDAP_SLAPI char *ret; - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); ret = entry2str( e, len ); - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); return ret; #else /* LDAP_SLAPI */ diff --git a/servers/slapd/starttls.c b/servers/slapd/starttls.c index 7ab7328012..b953e3e3e5 100644 --- a/servers/slapd/starttls.c +++ b/servers/slapd/starttls.c @@ -55,7 +55,7 @@ starttls_extop ( Operation *op, SlapReply *rs ) goto done; } - if ( !( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_TLS_2_ANON ) && + if ( !( global_disallows & SLAP_DISALLOW_TLS_2_ANON ) && ( op->o_conn->c_dn.bv_len != 0 ) ) { Statslog( LDAP_DEBUG_STATS, @@ -66,7 +66,7 @@ starttls_extop ( Operation *op, SlapReply *rs ) connection2anonymous( op->o_conn ); } - if ( ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_TLS_AUTHC ) && + if ( ( global_disallows & SLAP_DISALLOW_TLS_AUTHC ) && ( op->o_conn->c_dn.bv_len != 0 ) ) { rs->sr_text = "cannot start TLS after authentication"; @@ -75,8 +75,8 @@ starttls_extop ( Operation *op, SlapReply *rs ) } /* fail if TLS could not be initialized */ - if ( SLAPD_GLOBAL(tls_ctx) == NULL ) { - if (SLAPD_GLOBAL(default_referral) != NULL) { + if ( slap_tls_ctx == NULL ) { + if (default_referral != NULL) { /* caller will put the referral in the result */ rc = LDAP_REFERRAL; goto done; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index c94e4e58a0..2389fcb1b5 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -50,6 +50,8 @@ static int null_callback( struct slap_op *, struct slap_rep * ); static AttributeDescription *sync_descs[4]; +struct runqueue_s syncrepl_rq; + void init_syncrepl(syncinfo_t *si) { @@ -404,7 +406,7 @@ do_syncrep1( build_new_dn( &op->o_req_ndn, psub, &syncrepl_cn_bv, op->o_tmpmemctx ); op->o_req_dn = op->o_req_ndn; - LDAP_STAILQ_FOREACH( sc, &SLAPD_GLOBAL(sync_cookie), sc_next ) { + LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) { if ( si->si_rid == sc->rid ) { cmdline_cookie_found = 1; break; @@ -416,7 +418,7 @@ do_syncrep1( BerVarray cookie = NULL; struct berval cookie_bv; - LDAP_STAILQ_REMOVE( &SLAPD_GLOBAL(sync_cookie), sc, sync_cookie, sc_next ); + LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next ); slap_sync_cookie_free( &si->si_syncCookie, 0 ); /* read stored cookie if it exists */ @@ -550,7 +552,7 @@ do_syncrep2( BerVarray syncUUIDs = NULL; ber_tag_t si_tag; - if ( SLAPD_GLOBAL(shutdown) ) { + if ( slapd_shutdown ) { rc = -2; goto done; } @@ -573,7 +575,7 @@ do_syncrep2( while (( rc = ldap_result( si->si_ld, LDAP_RES_ANY, LDAP_MSG_ONE, tout_p, &res )) > 0 ) { - if ( SLAPD_GLOBAL(shutdown) ) { + if ( slapd_shutdown ) { rc = -2; goto done; } @@ -888,7 +890,7 @@ do_syncrepl( return NULL; } - if ( SLAPD_GLOBAL(shutdown) && si->si_ld ) { + if ( slapd_shutdown && si->si_ld ) { ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s ); connection_client_stop( s ); ldap_unbind( si->si_ld ); @@ -950,10 +952,10 @@ do_syncrepl( * 3) for Refresh and Success, reschedule to run * 4) for Persist and Success, reschedule to defer */ - ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex ); - if ( ldap_pvt_runqueue_isrunning( &SLAPD_GLOBAL(runqueue), rtask )) { - ldap_pvt_runqueue_stoptask( &SLAPD_GLOBAL(runqueue), rtask ); + if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) { + ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask ); } if ( dostop ) { @@ -965,7 +967,7 @@ do_syncrepl( defer = 0; } rtask->interval.tv_sec = si->si_interval; - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, defer ); + ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, defer ); if ( si->si_retrynum ) { for ( i = 0; si->si_retrynum_init[i] != -2; i++ ) { si->si_retrynum[i] = si->si_retrynum_init[i]; @@ -979,19 +981,19 @@ do_syncrepl( } if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) { - ldap_pvt_runqueue_remove( &SLAPD_GLOBAL(runqueue), rtask ); + ldap_pvt_runqueue_remove( &syncrepl_rq, rtask ); LDAP_STAILQ_REMOVE( &be->be_syncinfo, si, syncinfo_s, si_next ); syncinfo_free( si ); } else if ( si->si_retrynum[i] >= -1 ) { if ( si->si_retrynum[i] > 0 ) si->si_retrynum[i]--; rtask->interval.tv_sec = si->si_retryinterval[i]; - ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, 0 ); + ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 ); slap_wake_listener(); } } - ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex ); + ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex ); return NULL; }