ITS#3353 consolidate slapd globals into a single struct

This commit is contained in:
Howard Chu 2004-10-01 07:33:16 +00:00
parent db62156db6
commit fda3d6260e
67 changed files with 598 additions and 614 deletions

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) rs->sr_ref = default_referral;
if ( !rs->sr_ref ) rs->sr_ref = SLAPD_GLOBAL(default_referral);
if ( rs->sr_ref ) {
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if ( rs->sr_ref != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(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 : default_referral;
? op->o_bd->be_update_refs : SLAPD_GLOBAL(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 = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
send_ldap_result( op, rs );
if ( rs->sr_ref != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( rs->sr_ref );
}
} else {

View File

@ -74,7 +74,7 @@ dn2entry_retry:
e = NULL;
} else {
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}

View File

@ -165,7 +165,7 @@ retry: /* transaction retry */
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( rs->sr_ref );
}
if ( deref != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -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, connection_pool_max * 3 );
bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, SLAPD_GLOBAL(connection_pool_max) * 3 );
if ( bdb->bi_idl_cache_max_size ) {
bdb->bi_idl_tree = NULL;

View File

@ -399,7 +399,7 @@ retry: /* transaction retry */
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( rs->sr_ref );
}
if ( deref != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -188,7 +188,7 @@ retry: /* transaction retry */
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -94,9 +94,9 @@ dn2entry_retry:
bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
e = NULL;
} else if ( default_referral != NULL ) {
} else if ( SLAPD_GLOBAL(default_referral) != NULL ) {
rc = LDAP_OTHER;
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}

View File

@ -612,7 +612,7 @@ dn2entry_retry:
}
} else {
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &sop->o_req_dn, sop->oq_search.rs_scope );
}

View File

@ -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 = default_referral;
rs->sr_ref = SLAPD_GLOBAL(default_referral);
send_ldap_result( op, rs );
return LDAP_REFERRAL;
}

View File

@ -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 = default_referral;
rs->sr_ref = SLAPD_GLOBAL(default_referral);
send_ldap_result( op, rs );
rs->sr_ref = NULL;
goto done;

View File

@ -46,12 +46,12 @@ int init_module(int argc, char *argv[]) {
#endif /* SLAPD_LDAP */
static int
int
ldap_back_open(
BackendInfo *bi
)
{
bi->bi_controls = slap_known_controls;
bi->bi_controls = SLAPD_GLOBAL(known_controls);
return 0;
}

View File

@ -109,7 +109,7 @@ ldbm_back_add(
cache_return_entry_r( &li->li_cache, matched );
} else {
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}

View File

@ -48,7 +48,7 @@ ldbm_back_compare(
: NULL;
cache_return_entry_r( &li->li_cache, matched );
} else {
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}

View File

@ -70,7 +70,7 @@ ldbm_back_delete(
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -61,7 +61,7 @@ id2entry_add( Backend *be, Entry *e )
#endif
key.dsize = sizeof(ID);
ldap_pvt_thread_mutex_lock( &entry2str_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &entry2str_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) );
ldbm_cache_close( be, db );

View File

@ -265,7 +265,7 @@ ldbm_back_modify(
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -93,7 +93,7 @@ ldbm_back_modrdn(
ber_bvarray_add( &deref, &tmpbv );
}
} else {
deref = default_referral;
deref = SLAPD_GLOBAL(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 != default_referral ) {
if ( deref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( deref );
}
free( (char *)rs->sr_matched );

View File

@ -62,9 +62,9 @@ ldbm_back_referrals(
cache_return_entry_r( &li->li_cache, matched );
} else if ( default_referral != NULL ) {
} else if ( SLAPD_GLOBAL(default_referral) != NULL ) {
rs->sr_err = LDAP_OTHER;
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}

View File

@ -102,7 +102,7 @@ ldbm_back_search(
}
} else {
rs->sr_ref = referral_rewrite( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, op->ors_scope );
}

View File

@ -47,7 +47,7 @@ meta_back_open(
BackendInfo *bi
)
{
bi->bi_controls = slap_known_controls;
bi->bi_controls = SLAPD_GLOBAL(known_controls);
return 0;
}

View File

@ -252,7 +252,7 @@ conn_create(
assert( ep != NULL );
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
snprintf( buf, sizeof( buf ),
@ -314,7 +314,7 @@ conn_create(
}
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif /* HAVE_GMTIME_R */
/* monitored info */

View File

@ -618,25 +618,25 @@ monitor_back_db_open(
* Start
*/
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
#ifdef HACK_LOCAL_TIME
# ifdef HAVE_LOCALTIME_R
tms = localtime_r( &starttime, &tm_buf );
tms = localtime_r( &SLAPD_GLOBAL(starttime), &tm_buf );
# else
tms = localtime( &starttime );
tms = localtime( &SLAPD_GLOBAL(starttime) );
# endif /* HAVE_LOCALTIME_R */
lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
#else /* !HACK_LOCAL_TIME */
# ifdef HAVE_GMTIME_R
tms = gmtime_r( &starttime, &tm_buf );
tms = gmtime_r( &SLAPD_GLOBAL(starttime), &tm_buf );
# else
tms = gmtime( &starttime );
tms = gmtime( &SLAPD_GLOBAL(starttime) );
# endif /* HAVE_GMTIME_R */
lutil_gentime( tmbuf, sizeof(tmbuf), tms );
#endif /* !HACK_LOCAL_TIME */
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
mi->mi_startTime.bv_val = tmbuf;

View File

@ -175,21 +175,21 @@ monitor_subsys_ops_update(
ldap_pvt_mp_init( nInitiated );
ldap_pvt_mp_init( nCompleted );
ldap_pvt_thread_mutex_lock( &slap_counters.sc_ops_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex );
for ( i = 0; i < SLAP_OP_LAST; 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_mp_add( nInitiated, SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] );
ldap_pvt_mp_add( nCompleted, SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] );
}
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &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 );
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 );
break;
}
}

View File

@ -171,28 +171,28 @@ monitor_subsys_sent_update(
return 0;
}
ldap_pvt_thread_mutex_lock(&slap_counters.sc_sent_mutex);
ldap_pvt_thread_mutex_lock(&SLAPD_GLOBAL(counters).sc_sent_mutex);
switch ( i ) {
case MONITOR_SENT_ENTRIES:
ldap_pvt_mp_init_set( n, slap_counters.sc_entries );
ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_entries );
break;
case MONITOR_SENT_REFERRALS:
ldap_pvt_mp_init_set( n, slap_counters.sc_refs );
ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_refs );
break;
case MONITOR_SENT_PDU:
ldap_pvt_mp_init_set( n, slap_counters.sc_pdu );
ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_pdu );
break;
case MONITOR_SENT_BYTES:
ldap_pvt_mp_init_set( n, slap_counters.sc_bytes );
ldap_pvt_mp_init_set( n, SLAPD_GLOBAL(counters).sc_bytes );
break;
default:
assert(0);
}
ldap_pvt_thread_mutex_unlock(&slap_counters.sc_sent_mutex);
ldap_pvt_thread_mutex_unlock(&SLAPD_GLOBAL(counters).sc_sent_mutex);
a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
assert( a );

View File

@ -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,
connection_pool_max,
SLAPD_GLOBAL(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( &connection_pool ) );
ldap_pvt_thread_pool_backload( &SLAPD_GLOBAL(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 );

View File

@ -193,7 +193,7 @@ monitor_subsys_time_update(
currtime = slap_get_time();
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
len = strlen( tmbuf );

View File

@ -27,7 +27,7 @@ perl_back_add(
int count;
ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
ldap_pvt_thread_mutex_lock( &entry2str_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) );
{
dSP; ENTER; SAVETMPS;
@ -55,7 +55,7 @@ perl_back_add(
PUTBACK; FREETMPS; LEAVE;
}
ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) );
ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
send_ldap_result( op, rs );

View File

@ -66,17 +66,17 @@ relay_back_select_backend( struct slap_op *op, struct slap_rep *rs, int err )
}
if ( bd == NULL ) {
if ( default_referral ) {
rs->sr_ref = referral_rewrite( default_referral,
if ( SLAPD_GLOBAL(default_referral) ) {
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) {
rs->sr_ref = default_referral;
rs->sr_ref = SLAPD_GLOBAL(default_referral);
}
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if ( rs->sr_ref != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( rs->sr_ref );
}

View File

@ -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( &entry2str_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) );
fprintf( wfp, "%s", entry2str( op->oq_add.rs_e, &len ) );
ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) );
fclose( wfp );
/* read in the result and send it along */

View File

@ -344,9 +344,9 @@ int backend_startup(Backend *be)
}
}
ldap_pvt_thread_mutex_init( &syncrepl_rq.rq_mutex );
LDAP_STAILQ_INIT( &syncrepl_rq.task_list );
LDAP_STAILQ_INIT( &syncrepl_rq.run_list );
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 );
/* 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( &syncrepl_rq.rq_mutex );
ldap_pvt_runqueue_insert( &syncrepl_rq,
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex );
ldap_pvt_runqueue_insert( &SLAPD_GLOBAL(runqueue),
si->si_interval, do_syncrepl, (void *) si );
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex );
}
}
}
@ -782,7 +782,7 @@ be_isroot_pw( Operation *op )
}
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_lock( &passwd_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &passwd_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(passwd_mutex) );
#endif
return result == 0;
@ -1109,7 +1109,7 @@ backend_check_restrictions(
return rs->sr_err;
}
if( !( global_allows & SLAP_ALLOW_UPDATE_ANON ) &&
if( !( SLAPD_GLOBAL(allows) & SLAP_ALLOW_UPDATE_ANON ) &&
op->o_ndn.bv_len == 0 )
{
rs->sr_text = "modifications require authentication";

View File

@ -577,7 +577,7 @@ int
glue_sub_init( )
{
int i, j;
int cont = num_subordinates;
int cont = SLAPD_GLOBAL(num_subordinates);
BackendDB *b1, *be;
BackendInfo *bi = NULL;
glueinfo *gi;

View File

@ -183,7 +183,7 @@ do_bind(
"requested protocol version not supported" );
goto cleanup;
} else if (!( global_allows & SLAP_ALLOW_BIND_V2 ) &&
} else if (!( SLAPD_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 = sockbuf_max_incoming_auth;
ber_len_t max = SLAPD_GLOBAL(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 ) &&
!( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
!( SLAPD_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 ) &&
!( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
!( SLAPD_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 ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
} else if ( SLAPD_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 ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) {
} else if ( SLAPD_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 ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) {
if ( SLAPD_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 = sockbuf_max_incoming_auth;
ber_len_t max = SLAPD_GLOBAL(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 = sockbuf_max_incoming_auth;
ber_len_t max = SLAPD_GLOBAL(sockbuf_max_incoming_auth);
ber_sockbuf_ctrl( op->o_conn->c_sb,
LBER_SB_OPT_SET_MAX_INCOMING, &max );
}

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
rs->sr_err = LDAP_REFERRAL;
if (!rs->sr_ref) rs->sr_ref = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
if (rs->sr_ref != SLAPD_GLOBAL(default_referral)) ber_bvarray_free( rs->sr_ref );
rs->sr_err = 0;
goto cleanup;
}

View File

@ -33,6 +33,7 @@
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/errno.h>
#include <ac/unistd.h>
#include "slap.h"
#ifdef LDAP_SLAPI
@ -45,38 +46,11 @@
/*
* 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);
@ -87,6 +61,64 @@ 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 )
{
@ -209,7 +241,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
local_ssf = ssf;
SLAPD_GLOBAL(local_ssf) = ssf;
/* set thread concurrency */
} else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
@ -239,6 +271,7 @@ 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 ) {
@ -250,14 +283,14 @@ read_config( const char *fname, int depth )
return( 1 );
}
min = atoi( cargv[1] );
if( min < 1 || min > index_substr_if_maxlen ) {
if( min < 1 || min > SLAPD_GLOBAL(index_substr_if_maxlen) ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: invalid min value (%ld) in "
"\"index_substr_if_minlen <length>\" line.\n",
fname, lineno, min );
return( 1 );
}
index_substr_if_minlen = min;
SLAPD_GLOBAL(index_substr_if_minlen) = min;
/* set substring initial/final index maximum length */
} else if ( strcasecmp( cargv[0], "index_substr_if_maxlen" ) == 0 ) {
@ -269,14 +302,14 @@ read_config( const char *fname, int depth )
return( 1 );
}
max = atol( cargv[1] );
if( max < 1 || max < index_substr_if_minlen ) {
if( max < 1 || max < SLAPD_GLOBAL(index_substr_if_minlen) ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: invalid max value (%ld) in "
"\"index_substr_maxlen <length>\" line.\n",
fname, lineno, max );
return( 1 );
}
index_substr_if_maxlen = max;
SLAPD_GLOBAL(index_substr_if_maxlen) = max;
/* set substring any index len */
} else if ( strcasecmp( cargv[0], "index_substr_any_len" ) == 0 ) {
@ -295,7 +328,7 @@ read_config( const char *fname, int depth )
fname, lineno, len );
return( 1 );
}
index_substr_any_len = len;
SLAPD_GLOBAL(index_substr_any_len) = len;
/* set substring any index step */
} else if ( strcasecmp( cargv[0], "index_substr_any_step" ) == 0 ) {
@ -314,7 +347,7 @@ read_config( const char *fname, int depth )
fname, lineno, step );
return( 1 );
}
index_substr_any_step = step;
SLAPD_GLOBAL(index_substr_any_step) = step;
/* set sockbuf max */
} else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
@ -338,7 +371,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
sockbuf_max_incoming = max;
SLAPD_GLOBAL(sockbuf_max_incoming) = max;
/* set sockbuf max authenticated */
} else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
@ -362,7 +395,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
sockbuf_max_incoming_auth = max;
SLAPD_GLOBAL(sockbuf_max_incoming_auth) = max;
/* set conn pending max */
} else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
@ -386,7 +419,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
slap_conn_max_pending = max;
SLAPD_GLOBAL(conn_max_pending) = max;
/* set conn pending max authenticated */
} else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
@ -410,7 +443,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
slap_conn_max_pending_auth = max;
SLAPD_GLOBAL(conn_max_pending_auth) = max;
/* default search base */
} else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
@ -437,14 +470,14 @@ read_config( const char *fname, int depth )
return 1;
}
if ( default_search_nbase.bv_len ) {
if ( SLAPD_GLOBAL(default_search_nbase).bv_len ) {
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"default search base \"%s\" already defined "
"(discarding old)\n",
fname, lineno, default_search_base.bv_val );
fname, lineno, SLAPD_GLOBAL(default_search_base).bv_val );
free( default_search_base.bv_val );
free( default_search_nbase.bv_val );
free( SLAPD_GLOBAL(default_search_base).bv_val );
free( SLAPD_GLOBAL(default_search_nbase).bv_val );
}
if ( load_ucdata( NULL ) < 0 ) return 1;
@ -456,8 +489,8 @@ read_config( const char *fname, int depth )
dn.bv_len = strlen( dn.bv_val );
rc = dnPrettyNormal( NULL, &dn,
&default_search_base,
&default_search_nbase, NULL );
&SLAPD_GLOBAL(default_search_base),
&SLAPD_GLOBAL(default_search_nbase), NULL );
if( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY,
@ -494,10 +527,10 @@ read_config( const char *fname, int depth )
return( 1 );
}
ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
ldap_pvt_thread_pool_maxthreads( &SLAPD_GLOBAL(connection_pool), c );
/* save for later use */
connection_pool_max = c;
SLAPD_GLOBAL(connection_pool_max) = c;
/* get pid file name */
} else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
@ -509,7 +542,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
slapd_pid_file = ch_strdup( cargv[1] );
SLAPD_GLOBAL(pid_file) = ch_strdup( cargv[1] );
/* get args file name */
} else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
@ -521,7 +554,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
slapd_args_file = ch_strdup( cargv[1] );
SLAPD_GLOBAL(args_file) = ch_strdup( cargv[1] );
} else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
/* ignore */ ;
@ -538,7 +571,7 @@ read_config( const char *fname, int depth )
return( 1 );
}
if ( default_passwd_hash != NULL ) {
if ( SLAPD_GLOBAL(default_passwd_hash) != NULL ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: already set default password_hash!\n",
fname, lineno, 0 );
@ -552,10 +585,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( &default_passwd_hash, cargv[i] );
ldap_charray_add( &SLAPD_GLOBAL(default_passwd_hash), cargv[i] );
}
}
if( !default_passwd_hash ) {
if( !SLAPD_GLOBAL(default_passwd_hash) ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: no valid hashes found\n",
fname, lineno, 0 );
@ -573,6 +606,7 @@ 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 */
@ -768,7 +802,7 @@ read_config( const char *fname, int depth )
} else {
SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
num_subordinates++;
SLAPD_GLOBAL(num_subordinates)++;
}
/* add an overlay to this backend */
@ -857,11 +891,11 @@ read_config( const char *fname, int depth )
free( ndn.bv_val );
return( 1 );
} else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
} else if( pdn.bv_len == 0 && SLAPD_GLOBAL(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, default_search_base.bv_val );
fname, lineno, SLAPD_GLOBAL(default_search_base).bv_val );
}
ber_bvarray_add( &be->be_suffix, &pdn );
@ -1135,7 +1169,7 @@ restrict_unknown:;
}
}
global_allows |= allows;
SLAPD_GLOBAL(allows) |= allows;
/* disallow these features */
} else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
@ -1183,7 +1217,7 @@ restrict_unknown:;
}
}
global_disallows |= disallows;
SLAPD_GLOBAL(disallows) |= disallows;
/* require these features */
} else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
@ -1342,7 +1376,7 @@ restrict_unknown:;
vals[0].bv_val = cargv[1];
vals[0].bv_len = strlen( vals[0].bv_val );
if( value_add( &default_referral, vals ) )
if( value_add( &SLAPD_GLOBAL(default_referral), vals ) )
return LDAP_OTHER;
/* start of a new database definition */
@ -1438,16 +1472,16 @@ restrict_unknown:;
Debug( LDAP_DEBUG_ANY,
"%s: line %d: schema checking disabled! your mileage may vary!\n",
fname, lineno, 0 );
global_schemacheck = 0;
SLAPD_GLOBAL(schemachecking) = 0;
} else {
global_schemacheck = 1;
SLAPD_GLOBAL(schemachecking) = 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 syslog */
/* debug level to log things to ldap_syslog */
} else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
if ( cargc < 2 ) {
Debug( LDAP_DEBUG_ANY,
@ -1732,7 +1766,7 @@ restrict_unknown:;
if ( be ) {
be->be_replogfile = ch_strdup( cargv[1] );
} else {
replogfile = ch_strdup( cargv[1] );
frontendDB->be_replogfile = ch_strdup( cargv[1] );
}
/* file from which to read additional rootdse attrs */
@ -1790,9 +1824,9 @@ restrict_unknown:;
return( 1 );
}
if ( strcasecmp( cargv[1], "off" ) == 0 ) {
global_gentlehup = 0;
SLAPD_GLOBAL(gentlehup) = 0;
} else {
global_gentlehup = 1;
SLAPD_GLOBAL(gentlehup) = 1;
}
#endif
@ -1817,7 +1851,7 @@ restrict_unknown:;
return( 1 );
}
global_idletimeout = i;
SLAPD_GLOBAL(idletimeout) = i;
/* include another config file */
} else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
@ -1847,7 +1881,7 @@ restrict_unknown:;
return( 1 );
}
ldap_srvtab = ch_strdup( cargv[1] );
SLAPD_GLOBAL(ldap_srvtab) = ch_strdup( cargv[1] );
#ifdef SLAPD_MODULES
} else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
@ -1952,9 +1986,9 @@ restrict_unknown:;
}
if ( !strcasecmp( cargv[1], "on" ) ) {
use_reverse_lookup = 1;
SLAPD_GLOBAL(use_reverse_lookup) = 1;
} else if ( !strcasecmp( cargv[1], "off" ) ) {
use_reverse_lookup = 0;
SLAPD_GLOBAL(use_reverse_lookup) = 0;
} else {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
@ -1993,7 +2027,7 @@ restrict_unknown:;
"config read failed.\n", fname, lineno, 0 );
return( 1 );
}
slapi_plugins_used++;
SLAPD_GLOBAL(slapi_plugins_used)++;
#else /* !defined( LDAP_SLAPI ) */
Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
@ -2311,14 +2345,15 @@ 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

View File

@ -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( dtblsize, sizeof(Connection) );
connections = (Connection *) ch_calloc( SLAPD_GLOBAL(dtblsize), sizeof(Connection) );
if( connections == NULL ) {
Debug( LDAP_DEBUG_ANY,
"connections_init: allocation (%d*%ld) of connection array failed\n",
dtblsize, (long) sizeof(Connection), 0 );
SLAPD_GLOBAL(dtblsize), (long) sizeof(Connection), 0 );
return -1;
}
assert( connections[0].c_struct_state == SLAP_C_UNINITIALIZED );
assert( connections[dtblsize-1].c_struct_state == SLAP_C_UNINITIALIZED );
assert( connections[SLAPD_GLOBAL(dtblsize)-1].c_struct_state == SLAP_C_UNINITIALIZED );
for (i=0; i<dtblsize; i++) connections[i].c_conn_idx = i;
for (i=0; i<SLAPD_GLOBAL(dtblsize); i++) connections[i].c_conn_idx = i;
/*
* per entry initialization of the Connection array initialization
@ -144,14 +144,14 @@ int connections_destroy(void)
return -1;
}
for ( i = 0; i < dtblsize; i++ ) {
for ( i = 0; i < SLAPD_GLOBAL(dtblsize); i++ ) {
if( connections[i].c_struct_state != SLAP_C_UNINITIALIZED ) {
ber_sockbuf_free( connections[i].c_sb );
ldap_pvt_thread_mutex_destroy( &connections[i].c_mutex );
ldap_pvt_thread_mutex_destroy( &connections[i].c_write_mutex );
ldap_pvt_thread_cond_destroy( &connections[i].c_write_cv );
#ifdef LDAP_SLAPI
if ( slapi_plugins_used ) {
if ( SLAPD_GLOBAL(slapi_plugins_used) ) {
slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, &connections[i] );
}
#endif
@ -175,13 +175,13 @@ int connections_shutdown(void)
ldap_pvt_thread_mutex_lock( &connections_mutex );
for ( i = 0; i < dtblsize; i++ ) {
for ( i = 0; i < SLAPD_GLOBAL(dtblsize); i++ ) {
if( connections[i].c_struct_state != SLAP_C_USED ) {
continue;
}
/* give persistent clients a chance to cleanup */
if( connections[i].c_conn_state == SLAP_C_CLIENT ) {
ldap_pvt_thread_pool_submit( &connection_pool,
ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(connection_pool),
connections[i].c_clientfunc, connections[i].c_clientarg );
continue;
}
@ -218,7 +218,7 @@ int connections_timeout_idle(time_t now)
if( c->c_n_ops_executing ||
c->c_conn_state == SLAP_C_CLIENT ) continue;
if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
if( difftime( c->c_activitytime+SLAPD_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<dtblsize; i++) {
for(i=0; i<SLAPD_GLOBAL(dtblsize); i++) {
if( connections[i].c_struct_state == SLAP_C_UNINITIALIZED ) {
assert( connections[i].c_conn_state == SLAP_C_INVALID );
assert( connections[i].c_sb == 0 );
@ -315,7 +315,7 @@ static Connection* connection_get( ber_socket_t s )
assert( sd != AC_SOCKET_INVALID );
#ifndef SLAPD_MONITOR
if ( global_idletimeout > 0 )
if ( SLAPD_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 < dtblsize );
assert( s < SLAPD_GLOBAL(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 < dtblsize; i++) {
for( i=0; i < SLAPD_GLOBAL(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, dtblsize);
"(%d/%d)\n", s, i, SLAPD_GLOBAL(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 = sockbuf_max_incoming;
ber_len_t max = SLAPD_GLOBAL(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 ( slapi_plugins_used ) {
if ( SLAPD_GLOBAL(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 ( global_idletimeout > 0 )
if ( SLAPD_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 = sockbuf_max_incoming;
ber_len_t max = SLAPD_GLOBAL(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 = sockbuf_max_incoming;
ber_len_t max = SLAPD_GLOBAL(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 ( slapi_plugins_used ) {
if ( SLAPD_GLOBAL(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 <= dtblsize );
assert( *index <= SLAPD_GLOBAL(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 < dtblsize; (*index)++) {
for(; *index < SLAPD_GLOBAL(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( &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 ); \
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 ); \
} while (0)
#define INCR_OP_COMPLETED(index) \
do { \
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 ); \
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 ); \
} 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( &slap_counters.sc_ops_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(counters).sc_ops_mutex );
/* FIXME: returns 0 in case of failure */
ldap_pvt_mp_add_ulong(slap_counters.sc_ops_initiated, 1);
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
ldap_pvt_mp_add_ulong(SLAPD_GLOBAL(counters).sc_ops_initiated, 1);
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(counters).sc_ops_mutex );
op->o_threadctx = ctx;
@ -1053,7 +1053,7 @@ operations_error:
assert( 0 );
}
#endif /* SLAPD_MONITOR */
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_ops_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &connection_pool,
ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(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, slap_tls_ctx );
rc = ldap_pvt_tls_accept( c->c_sb, SLAPD_GLOBAL(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 >= connection_pool_max/2) {
} else if (conn->c_n_ops_executing >= SLAPD_GLOBAL(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
? slap_conn_max_pending_auth
: slap_conn_max_pending;
? SLAPD_GLOBAL(conn_max_pending_auth)
: SLAPD_GLOBAL(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 > connection_pool_max/2 ) {
if ( conn->c_n_ops_executing > SLAPD_GLOBAL(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( &connection_pool,
status = ldap_pvt_thread_pool_submit( &SLAPD_GLOBAL(connection_pool),
connection_operation, (void *) op );
if ( status != 0 ) {

View File

@ -68,9 +68,8 @@ static LDAP_SLIST_HEAD(ControlsList, slap_control) controls_list
= LDAP_SLIST_HEAD_INITIALIZER(&controls_list);
/*
* all known request control OIDs should be added to this list
* all known request control OIDs should be added to global known_controls
*/
char **slap_known_controls = NULL;
static char *proxy_authz_extops[] = {
LDAP_EXOP_MODIFY_PASSWD,
@ -172,28 +171,28 @@ register_supported_control(const char *controloid,
}
sc->sc_parse = controlparsefn;
/* Update slap_known_controls, too. */
if ( slap_known_controls == NULL ) {
slap_known_controls = (char **)SLAP_MALLOC( 2 * sizeof(char *) );
if ( slap_known_controls == NULL ) {
/* 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 ) {
if ( sc->sc_extendedops != NULL ) {
ldap_charray_free( sc->sc_extendedops );
}
ch_free( sc );
return LDAP_NO_MEMORY;
}
slap_known_controls[0] = ch_strdup( sc->sc_oid );
slap_known_controls[1] = NULL;
SLAPD_GLOBAL(known_controls)[0] = ch_strdup( sc->sc_oid );
SLAPD_GLOBAL(known_controls)[1] = NULL;
} else {
char **new_known_controls;
for ( i = 0; slap_known_controls[i] != NULL; i++ ) {
for ( i = 0; SLAPD_GLOBAL(known_controls)[i] != NULL; i++ ) {
/* EMPTY */ ;
}
new_known_controls = (char **)SLAP_REALLOC(
slap_known_controls, (i + 2) * sizeof(char *) );
SLAPD_GLOBAL(known_controls), (i + 2) * sizeof(char *) );
if ( new_known_controls == NULL ) {
if ( sc->sc_extendedops != NULL ) {
@ -202,9 +201,9 @@ register_supported_control(const char *controloid,
ch_free( sc );
return LDAP_NO_MEMORY;
}
slap_known_controls = new_known_controls;
slap_known_controls[i++] = ch_strdup( sc->sc_oid );
slap_known_controls[i] = NULL;
SLAPD_GLOBAL(known_controls) = new_known_controls;
SLAPD_GLOBAL(known_controls)[i++] = ch_strdup( sc->sc_oid );
SLAPD_GLOBAL(known_controls)[i] = NULL;
}
LDAP_SLIST_NEXT( sc, sc_next ) = NULL;
@ -251,7 +250,7 @@ controls_destroy( void )
}
ch_free( sc );
}
ldap_charray_free( slap_known_controls );
ldap_charray_free( SLAPD_GLOBAL(known_controls) );
}
/*

View File

@ -63,10 +63,6 @@ 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
@ -83,9 +79,6 @@ 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;
@ -114,7 +107,6 @@ 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;
@ -286,7 +278,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_gentle_shutdown == 2);
WAKE_LISTENER(wake || SLAPD_GLOBAL(gentle_shutdown) == 2);
}
void slapd_clr_write(ber_socket_t s, int wake) {
@ -731,10 +723,10 @@ static int slap_open_listener(
continue;
}
#ifndef HAVE_WINSOCK
if ( l.sl_sd >= dtblsize ) {
if ( l.sl_sd >= SLAPD_GLOBAL(dtblsize) ) {
Debug( LDAP_DEBUG_ANY,
"daemon: listener descriptor %ld is too great %ld\n",
(long) l.sl_sd, (long) dtblsize, 0 );
(long) l.sl_sd, (long) SLAPD_GLOBAL(dtblsize), 0 );
tcp_close( l.sl_sd );
sal++;
continue;
@ -894,20 +886,6 @@ 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
@ -962,7 +940,7 @@ int slapd_daemon_init( const char *urls )
i, 0, 0 );
#ifdef HAVE_SLP
if( slapd_register_slp ) {
if( SLAPD_GLOBAL(register_slp) ) {
slapd_slp_init( urls );
slapd_slp_reg();
}
@ -983,7 +961,7 @@ slapd_daemon_destroy(void)
sockdestroy();
#ifdef HAVE_SLP
if( slapd_register_slp ) {
if( SLAPD_GLOBAL(register_slp) ) {
slapd_slp_dereg();
slapd_slp_deinit();
}
@ -1032,14 +1010,14 @@ slapd_daemon_task(
#define SLAPD_IDLE_CHECK_LIMIT 4
if ( global_idletimeout > 0 ) {
if ( SLAPD_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 = global_idletimeout/SLAPD_IDLE_CHECK_LIMIT;
idle.tv_usec = global_idletimeout - idle.tv_sec * SLAPD_IDLE_CHECK_LIMIT;
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_usec *= 1000000 / SLAPD_IDLE_CHECK_LIMIT;
} else {
idle.tv_sec = 0;
@ -1111,7 +1089,7 @@ slapd_daemon_task(
#endif
/* initialization complete. Here comes the loop. */
while ( !slapd_shutdown ) {
while ( !SLAPD_GLOBAL(shutdown) ) {
ber_socket_t i;
int ns;
int at;
@ -1133,30 +1111,30 @@ slapd_daemon_task(
struct re_s* rtask;
now = slap_get_time();
if( ( global_idletimeout > 0 ) &&
if( ( SLAPD_GLOBAL(idletimeout) > 0 ) &&
difftime( last_idle_check +
global_idletimeout/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) {
SLAPD_GLOBAL(idletimeout)/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) {
connections_timeout_idle( now );
last_idle_check = now;
}
tv = idle;
#ifdef SIGHUP
if( slapd_gentle_shutdown ) {
if( SLAPD_GLOBAL(gentle_shutdown) ) {
ber_socket_t active;
if( slapd_gentle_shutdown == 1 ) {
if( SLAPD_GLOBAL(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_gentle_shutdown = 2;
SLAPD_GLOBAL(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_shutdown = 2;
SLAPD_GLOBAL(shutdown) = 2;
break;
}
}
@ -1198,9 +1176,9 @@ slapd_daemon_task(
#ifndef HAVE_WINSOCK
nfds = slap_daemon.sd_nfds;
#else
nfds = dtblsize;
nfds = SLAPD_GLOBAL(dtblsize);
#endif
if ( global_idletimeout && slap_daemon.sd_nactives )
if ( SLAPD_GLOBAL(idletimeout) && slap_daemon.sd_nactives )
at = 1;
ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
@ -1214,22 +1192,21 @@ slapd_daemon_task(
else
tvp = NULL;
ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex );
rtask = ldap_pvt_runqueue_next_sched( &SLAPD_GLOBAL(runqueue), &cat );
while ( cat && cat->tv_sec && cat->tv_sec <= now ) {
if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) {
ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, 0 );
if ( ldap_pvt_runqueue_isrunning( &SLAPD_GLOBAL(runqueue), rtask )) {
ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, 0 );
} else {
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 );
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 );
}
rtask = ldap_pvt_runqueue_next_sched( &syncrepl_rq, &cat );
rtask = ldap_pvt_runqueue_next_sched( &SLAPD_GLOBAL(runqueue), &cat );
}
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex );
if ( cat != NULL ) {
time_t diff = difftime( cat->tv_sec, now );
@ -1279,7 +1256,7 @@ slapd_daemon_task(
Debug( LDAP_DEBUG_CONNS,
"daemon: select failed (%d): %s\n",
err, sock_errstr(err), 0 );
slapd_shutdown = 2;
SLAPD_GLOBAL(shutdown) = 2;
}
}
continue;
@ -1293,7 +1270,7 @@ slapd_daemon_task(
continue;
default: /* something happened - deal with it */
if( slapd_shutdown ) continue;
if( SLAPD_GLOBAL(shutdown) ) continue;
ebadf = 0;
Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n",
@ -1396,10 +1373,10 @@ slapd_daemon_task(
#ifndef HAVE_WINSOCK
/* make sure descriptor number isn't too great */
if ( s >= dtblsize ) {
if ( s >= SLAPD_GLOBAL(dtblsize) ) {
Debug( LDAP_DEBUG_ANY,
"daemon: %ld beyond descriptor table size %ld\n",
(long) s, (long) dtblsize, 0 );
(long) s, (long) SLAPD_GLOBAL(dtblsize), 0 );
slapd_close(s);
ldap_pvt_thread_yield();
@ -1467,7 +1444,7 @@ slapd_daemon_task(
}
sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
ssf = local_ssf;
ssf = SLAPD_GLOBAL(local_ssf);
{
uid_t uid;
gid_t gid;
@ -1525,7 +1502,7 @@ slapd_daemon_task(
#endif
) {
#ifdef SLAPD_RLOOKUPS
if ( use_reverse_lookup ) {
if ( SLAPD_GLOBAL(use_reverse_lookup) ) {
char *herr;
if (ldap_pvt_get_hname( (const struct sockaddr *)&from, len, hbuf,
sizeof(hbuf), &herr ) == 0) {
@ -1685,12 +1662,12 @@ slapd_daemon_task(
ldap_pvt_thread_yield();
}
if( slapd_shutdown == 1 ) {
if( SLAPD_GLOBAL(shutdown) == 1 ) {
Debug( LDAP_DEBUG_TRACE,
"daemon: shutdown requested and initiated.\n",
0, 0, 0 );
} else if ( slapd_shutdown == 2 ) {
} else if ( SLAPD_GLOBAL(shutdown) == 2 ) {
#ifdef HAVE_NT_SERVICE_MANAGER
Debug( LDAP_DEBUG_TRACE,
"daemon: shutdown initiated by Service Manager.\n",
@ -1706,22 +1683,22 @@ slapd_daemon_task(
0, 0, 0 );
}
if( slapd_gentle_shutdown != 2 ) {
if( SLAPD_GLOBAL(gentle_shutdown) != 2 ) {
close_listeners ( 0 );
}
free ( slap_listeners );
slap_listeners = NULL;
if( !slapd_gentle_shutdown ) {
slapd_abrupt_shutdown = 1;
if( !SLAPD_GLOBAL(gentle_shutdown) ) {
SLAPD_GLOBAL(abrupt_shutdown) = 1;
connections_shutdown();
}
Debug( LDAP_DEBUG_ANY,
"slapd shutdown: waiting for %d threads to terminate\n",
ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 );
ldap_pvt_thread_pool_destroy(&connection_pool, 1);
ldap_pvt_thread_pool_backload(&SLAPD_GLOBAL(connection_pool)), 0, 0 );
ldap_pvt_thread_pool_destroy(&SLAPD_GLOBAL(connection_pool), 1);
return NULL;
}
@ -1828,11 +1805,11 @@ slap_sig_shutdown( int sig )
else
#endif
#ifdef SIGHUP
if (sig == SIGHUP && global_gentlehup && slapd_gentle_shutdown == 0)
slapd_gentle_shutdown = 1;
if (sig == SIGHUP && SLAPD_GLOBAL(gentlehup) && SLAPD_GLOBAL(gentle_shutdown) == 0)
SLAPD_GLOBAL(gentle_shutdown) = 1;
else
#endif
slapd_shutdown = 1;
SLAPD_GLOBAL(shutdown) = 1;
WAKE_LISTENER(1);

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
if (rs->sr_ref != SLAPD_GLOBAL(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 : default_referral;
? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral);
if ( defref != NULL ) {
rs->sr_ref = referral_rewrite( defref,

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, NULL, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) rs->sr_ref = default_referral;
if ( !rs->sr_ref ) rs->sr_ref = SLAPD_GLOBAL(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 != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
}

View File

@ -80,7 +80,7 @@ frontend_init( void )
frontendDB->bd_info->bi_type = "frontend";
/* known controls */
frontendDB->bd_info->bi_controls = slap_known_controls;
frontendDB->bd_info->bi_controls = SLAPD_GLOBAL(known_controls);
/* calls */
frontendDB->bd_info->bi_op_add = fe_op_add;

View File

@ -44,18 +44,6 @@
*/
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 );
@ -63,24 +51,22 @@ struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS );
/*
* global variables that need mutex protection
*/
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
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_t passwd_mutex;
#ifdef LDAP_DEBUG
int ldap_syslog = LDAP_DEBUG_STATS;
#else
int ldap_syslog;
#endif
slap_counters_t slap_counters;
#ifdef LOG_DEBUG
int ldap_syslog_level = LOG_DEBUG;
#else
int ldap_syslog_level;
#endif
/*
* 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;
@ -113,31 +99,31 @@ slap_init( int mode, const char *name )
slap_name = name;
ldap_pvt_thread_pool_init( &connection_pool,
connection_pool_max, 0);
ldap_pvt_thread_pool_init( &SLAPD_GLOBAL(connection_pool),
SLAPD_GLOBAL(connection_pool_max), 0);
ldap_pvt_thread_mutex_init( &entry2str_mutex );
ldap_pvt_thread_mutex_init( &replog_mutex );
ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(entry2str_mutex) );
ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(replog_mutex) );
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_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_mp_init( slap_counters.sc_ops_completed );
ldap_pvt_mp_init( slap_counters.sc_ops_initiated );
ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_completed );
ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_initiated );
#ifdef SLAPD_MONITOR
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
ldap_pvt_mp_init( slap_counters.sc_ops_initiated_[ i ] );
ldap_pvt_mp_init( slap_counters.sc_ops_completed_[ i ] );
ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] );
ldap_pvt_mp_init( SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] );
}
#endif /* SLAPD_MONITOR */
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_init( &gmtime_mutex );
ldap_pvt_thread_mutex_init( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_init( &passwd_mutex );
@ -219,8 +205,8 @@ int slap_destroy(void)
"%s destroy: freeing system resources.\n",
slap_name, 0, 0 );
if ( default_referral ) {
ber_bvarray_free( default_referral );
if ( SLAPD_GLOBAL(default_referral) ) {
ber_bvarray_free( SLAPD_GLOBAL(default_referral) );
}
rc = backend_destroy();
@ -233,19 +219,19 @@ int slap_destroy(void)
case SLAP_SERVER_MODE:
case SLAP_TOOL_MODE:
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 );
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 );
#ifdef SLAPD_MONITOR
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
ldap_pvt_mp_clear( slap_counters.sc_ops_initiated_[ i ] );
ldap_pvt_mp_clear( slap_counters.sc_ops_completed_[ i ] );
ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_initiated_[ i ] );
ldap_pvt_mp_clear( SLAPD_GLOBAL(counters).sc_ops_completed_[ i ] );
}
#endif /* SLAPD_MONITOR */
break;

View File

@ -46,7 +46,7 @@ krbv4_ldap_auth(
strcpy( instance, "*" );
if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
ldap_srvtab )) != KSUCCESS ) {
SLAPD_GLOBAL(ldap_srvtab) )) != KSUCCESS ) {
Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n",
krb_err_txt[err], 0, 0 );
return( LDAP_INVALID_CREDENTIALS );

View File

@ -133,18 +133,16 @@ 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_register_slp = 1;
SLAPD_GLOBAL(register_slp) = 1;
} else if ( strcasecmp( val, "off" ) == 0 ) {
slapd_register_slp = 0;
SLAPD_GLOBAL(register_slp) = 0;
/* NOTE: add support for URL specification? */
@ -274,6 +272,8 @@ 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,13 +354,12 @@ 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, &slap_sync_cookie, sc_next ) {
LDAP_STAILQ_FOREACH( scp_entry, &SLAPD_GLOBAL(sync_cookie), sc_next ) {
if ( scp->rid == scp_entry->rid ) {
Debug( LDAP_DEBUG_ANY,
"main: duplicated replica id in cookies\n",
@ -369,7 +368,7 @@ int main( int argc, char **argv )
goto destroy;
}
}
LDAP_STAILQ_INSERT_TAIL( &slap_sync_cookie, scp, sc_next );
LDAP_STAILQ_INSERT_TAIL( &SLAPD_GLOBAL(sync_cookie), scp, sc_next );
break;
case 'd': /* set debug level and 'do not detach' flag */
@ -687,7 +686,7 @@ unhandled_option:;
goto destroy;
}
/* Retrieve slapd's own ctx */
ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &SLAPD_GLOBAL(tls_ctx) );
/* Restore previous ctx */
ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, def_ctx );
}
@ -724,7 +723,7 @@ unhandled_option:;
* FIXME: moved here from slapd_daemon_task()
* because back-monitor db_open() needs it
*/
time( &starttime );
time( &SLAPD_GLOBAL(starttime) );
if ( slap_startup( NULL ) != 0 ) {
rc = 1;
@ -735,21 +734,21 @@ unhandled_option:;
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
if ( slapd_pid_file != NULL ) {
FILE *fp = fopen( slapd_pid_file, "w" );
if ( SLAPD_GLOBAL(pid_file) != NULL ) {
FILE *fp = fopen( SLAPD_GLOBAL(pid_file), "w" );
if( fp != NULL ) {
fprintf( fp, "%d\n", (int) getpid() );
fclose( fp );
} else {
free(slapd_pid_file);
slapd_pid_file = NULL;
free(SLAPD_GLOBAL(pid_file));
SLAPD_GLOBAL(pid_file) = NULL;
}
}
if ( slapd_args_file != NULL ) {
FILE *fp = fopen( slapd_args_file, "w" );
if ( SLAPD_GLOBAL(args_file) != NULL ) {
FILE *fp = fopen( SLAPD_GLOBAL(args_file), "w" );
if( fp != NULL ) {
for ( i = 0; i < g_argc; i++ ) {
@ -758,8 +757,8 @@ unhandled_option:;
fprintf( fp, "\n" );
fclose( fp );
} else {
free(slapd_args_file);
slapd_args_file = NULL;
free(SLAPD_GLOBAL(args_file));
SLAPD_GLOBAL(args_file) = NULL;
}
}
@ -784,9 +783,9 @@ destroy:
/* remember an error during destroy */
rc |= slap_destroy();
while ( !LDAP_STAILQ_EMPTY( &slap_sync_cookie )) {
scp = LDAP_STAILQ_FIRST( &slap_sync_cookie );
LDAP_STAILQ_REMOVE_HEAD( &slap_sync_cookie, sc_next );
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 );
ch_free( scp );
}
@ -826,11 +825,11 @@ stop:
ldap_pvt_tls_destroy();
#endif
if ( slapd_pid_file != NULL ) {
unlink( slapd_pid_file );
if ( SLAPD_GLOBAL(pid_file) != NULL ) {
unlink( SLAPD_GLOBAL(pid_file) );
}
if ( slapd_args_file != NULL ) {
unlink( slapd_args_file );
if ( SLAPD_GLOBAL(args_file) != NULL ) {
unlink( SLAPD_GLOBAL(args_file) );
}
config_destroy();

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
if (rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
if (rs->sr_ref != SLAPD_GLOBAL(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 : default_referral;
? op->o_bd->be_update_refs : SLAPD_GLOBAL(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, &ltm_buf );
#else
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( global_schemacheck ) {
if( SLAPD_GLOBAL(schemachecking) ) {
int rc = mods_structural_class( mods, &tmpval,
text, textbuf, textlen );
if( rc != LDAP_SUCCESS ) return rc;

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
if (rs->sr_ref != SLAPD_GLOBAL(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 : default_referral;
? op->o_bd->be_update_refs : SLAPD_GLOBAL(default_referral);
if ( defref != NULL ) {
rs->sr_ref = referral_rewrite( defref,

View File

@ -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 ( slapi_plugins_used ) {
if ( SLAPD_GLOBAL(slapi_plugins_used) ) {
op->o_pb = slapi_pblock_new();
slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
}

View File

@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, op->ors_scope );
if ( !rs->sr_ref ) {
rs->sr_ref = default_referral;
rs->sr_ref = SLAPD_GLOBAL( default_referral );
}
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if ( rs->sr_ref != default_referral ) {
if ( rs->sr_ref != SLAPD_GLOBAL( 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( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL( 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( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &gmtime_mutex );
tms = gmtime( &starttime );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL( gmtime_mutex ));
tms = gmtime( &SLAPD_GLOBAL( starttime ));
#else /* HAVE_GMTIME_R */
tms = gmtime_r( &starttime, &tm_buf );
tms = gmtime_r( &SLAPD_GLOBAL( starttime ), &tm_buf );
#endif /* HAVE_GMTIME_R */
lutil_gentime( tmbuf, sizeof(tmbuf), tms );
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL( gmtime_mutex ));
#endif
if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) {

View File

@ -1123,12 +1123,12 @@ proxy_cache_response(
* wake it back up
*/
if ( cm->cc_paused ) {
ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex );
if ( cm->cc_paused ) {
cm->cc_paused = 0;
ldap_pvt_runqueue_resched( &syncrepl_rq, cm->cc_arg, 0 );
ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), cm->cc_arg, 0 );
}
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex );
}
}
@ -1464,15 +1464,15 @@ consistency_check(
}
ldap_pvt_thread_mutex_unlock(&cm->remove_mutex);
}
ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) {
ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask );
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 );
}
/* If there were no queries, defer processing for a while */
cm->cc_paused = pause;
ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, pause );
ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, pause );
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).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( &syncrepl_rq.rq_mutex );
ldap_pvt_runqueue_insert( &syncrepl_rq, cm->cc_period,
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex );
ldap_pvt_runqueue_insert( &SLAPD_GLOBAL(runqueue), cm->cc_period,
consistency_check, on );
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex );
/* Cached database must have the rootdn */
if ( BER_BVISNULL( &cm->db.be_rootndn )

View File

@ -710,10 +710,10 @@ ppolicy_bind_resp( Operation *op, SlapReply *rs )
}
now = slap_get_time(); /* stored for later consideration */
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex ));
tm = gmtime(&now);
lutil_gentime( nowstr, sizeof(nowstr), tm );
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex ));
ltm = gmtime( &now );
lutil_gentime( timebuf, sizeof(timebuf), ltm );
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &gmtime_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex ));
ltm = gmtime( &now );
lutil_gentime( timebuf, sizeof(timebuf), ltm );
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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 ( dtblsize && !pwcons )
pwcons = ch_calloc(sizeof(pw_conn), dtblsize );
if ( SLAPD_GLOBAL(dtblsize) && !pwcons )
pwcons = ch_calloc(sizeof(pw_conn), SLAPD_GLOBAL(dtblsize) );
return 0;
}

View File

@ -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 : default_referral;
? op->o_bd->be_update_refs : SLAPD_GLOBAL(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 ( default_passwd_hash ) {
for ( nhash = 0; default_passwd_hash[nhash]; nhash++ );
hashes = default_passwd_hash;
if ( SLAPD_GLOBAL(default_passwd_hash) ) {
for ( nhash = 0; SLAPD_GLOBAL(default_passwd_hash)[nhash]; nhash++ );
hashes = SLAPD_GLOBAL(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( &passwd_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(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( &passwd_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &passwd_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(passwd_mutex) );
#endif
lutil_passwd_hash( cred , hash, new, text );
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(passwd_mutex) );
#endif
}
@ -462,8 +462,8 @@ slap_passwd_hash(
const char **text )
{
char *hash = NULL;
if ( default_passwd_hash ) {
hash = default_passwd_hash[0];
if ( SLAPD_GLOBAL(default_passwd_hash) ) {
hash = SLAPD_GLOBAL(default_passwd_hash)[0];
}
if ( !hash ) {
hash = (char *)defhash[0];

View File

@ -376,10 +376,6 @@ 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
*/
@ -474,11 +470,6 @@ 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
*/
@ -664,8 +655,6 @@ 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
@ -675,19 +664,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_V (char *) ldap_srvtab;
LDAP_SLAPD_V (int) krbv4_ldap_auth();
LDAP_SLAPD_F (int) krbv4_ldap_auth();
#endif
/*
@ -1147,7 +1136,6 @@ 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 ));
@ -1220,8 +1208,6 @@ 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((
@ -1308,62 +1294,13 @@ 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;

View File

@ -135,14 +135,14 @@ replog( Operation *op )
int subsets = 0;
long now = slap_get_time();
if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) {
if ( op->o_bd->be_replogfile == NULL && frontendDB->be_replogfile == NULL ) {
return;
}
ldap_pvt_thread_mutex_lock( &replog_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(replog_mutex) );
if ( (fp = lock_fopen( op->o_bd->be_replogfile ? op->o_bd->be_replogfile :
replogfile, "a", &lfp )) == NULL ) {
ldap_pvt_thread_mutex_unlock( &replog_mutex );
frontendDB->be_replogfile, "a", &lfp )) == NULL ) {
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(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( &replog_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
return;
}
@ -231,7 +231,7 @@ replog( Operation *op )
}
lock_fclose( fp, lfp );
ldap_pvt_thread_mutex_unlock( &replog_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
}
static void

View File

@ -447,10 +447,10 @@ send_ldap_response(
}
#endif /* LDAP_SLAPI */
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 );
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 );
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( &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 );
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 );
}
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( &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 );
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 );
#ifdef LDAP_CONNECTIONLESS
}
#endif

View File

@ -169,7 +169,7 @@ root_dse_info(
/* supportedLDAPVersion */
for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
char buf[BUFSIZ];
if (!( global_allows & SLAP_ALLOW_BIND_V2 ) &&
if (!( SLAPD_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 ( default_referral != NULL ) {
if( attr_merge( e, ad_ref, default_referral, NULL /* FIXME */ ) ) {
if ( SLAPD_GLOBAL(default_referral) != NULL ) {
if( attr_merge( e, ad_ref, SLAPD_GLOBAL(default_referral), NULL /* FIXME */ ) ) {
return LDAP_OTHER;
}
}

View File

@ -116,7 +116,7 @@ int slap_sasl_config( int cargc, char **cargv, char *line,
return( 1 );
}
if ( global_host != NULL ) {
if ( SLAPD_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 {
global_host = ch_strdup( cargv[1] );
SLAPD_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 ( global_realm != NULL ) {
if ( SLAPD_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 {
global_realm = ch_strdup( cargv[1] );
SLAPD_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( global_host );
global_host = NULL;
free( SLAPD_GLOBAL(host) );
SLAPD_GLOBAL(host) = NULL;
return 0;
}
@ -1029,8 +1029,8 @@ int slap_sasl_open( Connection *conn, int reopen )
conn->c_sasl_layers = 0;
if( global_host == NULL ) {
global_host = ldap_pvt_get_fqdn( NULL );
if( SLAPD_GLOBAL(host) == NULL ) {
SLAPD_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", global_host, global_realm,
sc = sasl_server_new( "ldap", SLAPD_GLOBAL(host), SLAPD_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", global_host, global_realm,
sc = sasl_server_new( "ldap", SLAPD_GLOBAL(host), SLAPD_GLOBAL(realm),
session_callbacks, SASL_SECURITY_LAYER, &ctx );
#endif

View File

@ -135,14 +135,14 @@ schema_info( Entry **entry, const char **text )
*/
#ifdef HAVE_GMTIME_R
ltm = gmtime_r( &starttime, &ltm_buf );
ltm = gmtime_r( &SLAPD_GLOBAL(starttime), &ltm_buf );
#else
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
ltm = gmtime( &starttime );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(gmtime_mutex) );
ltm = gmtime( &SLAPD_GLOBAL(starttime) );
#endif /* HAVE_GMTIME_R */
lutil_gentime( timebuf, sizeof(timebuf), ltm );
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(gmtime_mutex) );
#endif
vals[0].bv_val = timebuf;

View File

@ -112,7 +112,7 @@ entry_schema_check(
}
/* it's a REALLY bad idea to disable schema checks */
if( !global_schemacheck ) return LDAP_SUCCESS;
if( !SLAPD_GLOBAL(schemachecking) ) 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 ( global_disallows & SLAP_DISALLOW_AUX_WO_CR ) {
} else if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_AUX_WO_CR ) {
k = -1;
} else {
k = 0;

View File

@ -60,11 +60,6 @@
#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,
@ -411,26 +406,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 >= 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( 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( flags & SLAP_INDEX_SUBSTR_ANY ) {
if( values[i].bv_len >= index_substr_any_len ) {
nkeys += values[i].bv_len - (index_substr_any_len - 1);
if( values[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) {
nkeys += values[i].bv_len - (SLAPD_GLOBAL(index_substr_any_len) - 1);
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
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( 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);
}
}
}
@ -451,25 +446,25 @@ octetStringSubstringsIndexer(
ber_len_t j,max;
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( values[i].bv_len >= index_substr_any_len ) )
( values[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
max = values[i].bv_len - (index_substr_any_len - 1);
max = values[i].bv_len - (SLAPD_GLOBAL(index_substr_any_len) - 1);
for( j=0; j<max; j++ ) {
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)&values[i].bv_val[j], index_substr_any_len);
syntax, mr, (unsigned char *)&values[i].bv_val[j], SLAPD_GLOBAL(index_substr_any_len));
ber_dupbv_x( &keys[nkeys++], &digest, ctx );
}
}
/* skip if too short */
if( values[i].bv_len < index_substr_if_minlen ) continue;
if( values[i].bv_len < SLAPD_GLOBAL(index_substr_if_minlen) ) continue;
max = index_substr_if_maxlen < values[i].bv_len
? index_substr_if_maxlen : values[i].bv_len;
max = SLAPD_GLOBAL(index_substr_if_maxlen) < values[i].bv_len
? SLAPD_GLOBAL(index_substr_if_maxlen) : values[i].bv_len;
for( j=index_substr_if_minlen; j<=max; j++ ) {
for( j=SLAPD_GLOBAL(index_substr_if_minlen); j<=max; j++ ) {
char pre;
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
@ -525,36 +520,36 @@ octetStringSubstringsFilter (
if( flags & SLAP_INDEX_SUBSTR_INITIAL &&
sa->sa_initial.bv_val != NULL &&
sa->sa_initial.bv_len >= index_substr_if_minlen )
sa->sa_initial.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) )
{
nkeys++;
if ( sa->sa_initial.bv_len > index_substr_if_maxlen &&
if ( sa->sa_initial.bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) &&
( flags & SLAP_INDEX_SUBSTR_ANY ))
{
nkeys += (sa->sa_initial.bv_len - index_substr_if_maxlen) / index_substr_any_step;
nkeys += (sa->sa_initial.bv_len - SLAPD_GLOBAL(index_substr_if_maxlen)) / SLAPD_GLOBAL(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 >= index_substr_any_len ) {
if( sa->sa_any[i].bv_len >= SLAPD_GLOBAL(index_substr_any_len) ) {
/* don't bother accounting with stepping */
nkeys += sa->sa_any[i].bv_len -
( index_substr_any_len - 1 );
( SLAPD_GLOBAL(index_substr_any_len) - 1 );
}
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL &&
sa->sa_final.bv_val != NULL &&
sa->sa_final.bv_len >= index_substr_if_minlen )
sa->sa_final.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) )
{
nkeys++;
if ( sa->sa_final.bv_len > index_substr_if_maxlen &&
if ( sa->sa_final.bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) &&
( flags & SLAP_INDEX_SUBSTR_ANY ))
{
nkeys += (sa->sa_final.bv_len - index_substr_if_maxlen) / index_substr_any_step;
nkeys += (sa->sa_final.bv_len - SLAPD_GLOBAL(index_substr_if_maxlen)) / SLAPD_GLOBAL(index_substr_any_step);
}
}
@ -574,13 +569,13 @@ octetStringSubstringsFilter (
if( flags & SLAP_INDEX_SUBSTR_INITIAL &&
sa->sa_initial.bv_val != NULL &&
sa->sa_initial.bv_len >= index_substr_if_minlen )
sa->sa_initial.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
value = &sa->sa_initial;
klen = index_substr_if_maxlen < value->bv_len
? index_substr_if_maxlen : value->bv_len;
klen = SLAPD_GLOBAL(index_substr_if_maxlen) < value->bv_len
? SLAPD_GLOBAL(index_substr_if_maxlen) : value->bv_len;
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)value->bv_val, klen );
@ -589,14 +584,14 @@ octetStringSubstringsFilter (
/* If initial is too long and we have subany indexed, use it
* to match the excess...
*/
if (value->bv_len > index_substr_if_maxlen && (flags & SLAP_INDEX_SUBSTR_ANY))
if (value->bv_len > SLAPD_GLOBAL(index_substr_if_maxlen) && (flags & SLAP_INDEX_SUBSTR_ANY))
{
ber_len_t j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
for ( j=index_substr_if_maxlen-1; j <= value->bv_len - index_substr_any_len; j+=index_substr_any_step )
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) )
{
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)&value->bv_val[j], index_substr_any_len );
syntax, mr, (unsigned char *)&value->bv_val[j], SLAPD_GLOBAL(index_substr_any_len) );
ber_dupbv_x( &keys[nkeys++], &digest, ctx );
}
}
@ -605,18 +600,18 @@ octetStringSubstringsFilter (
if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
ber_len_t i, j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
klen = index_substr_any_len;
klen = SLAPD_GLOBAL(index_substr_any_len);
for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) {
if( sa->sa_any[i].bv_len < index_substr_any_len ) {
if( sa->sa_any[i].bv_len < SLAPD_GLOBAL(index_substr_any_len) ) {
continue;
}
value = &sa->sa_any[i];
for(j=0;
j <= value->bv_len - index_substr_any_len;
j += index_substr_any_step )
j <= value->bv_len - SLAPD_GLOBAL(index_substr_any_len);
j += SLAPD_GLOBAL(index_substr_any_step) )
{
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)&value->bv_val[j], klen );
@ -627,13 +622,13 @@ octetStringSubstringsFilter (
if( flags & SLAP_INDEX_SUBSTR_FINAL &&
sa->sa_final.bv_val != NULL &&
sa->sa_final.bv_len >= index_substr_if_minlen )
sa->sa_final.bv_len >= SLAPD_GLOBAL(index_substr_if_minlen) )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
value = &sa->sa_final;
klen = index_substr_if_maxlen < value->bv_len
? index_substr_if_maxlen : value->bv_len;
klen = SLAPD_GLOBAL(index_substr_if_maxlen) < value->bv_len
? SLAPD_GLOBAL(index_substr_if_maxlen) : value->bv_len;
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)&value->bv_val[value->bv_len-klen], klen );
@ -642,14 +637,14 @@ octetStringSubstringsFilter (
/* If final is too long and we have subany indexed, use it
* to match the excess...
*/
if (value->bv_len > index_substr_if_maxlen && (flags & SLAP_INDEX_SUBSTR_ANY))
if (value->bv_len > SLAPD_GLOBAL(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 - index_substr_if_maxlen; j+=index_substr_any_step )
for ( j=0; j <= value->bv_len - SLAPD_GLOBAL(index_substr_if_maxlen); j+=SLAPD_GLOBAL(index_substr_any_step) )
{
hashDigestify( &HASHcontext, HASHdigest, prefix, pre,
syntax, mr, (unsigned char *)&value->bv_val[j], index_substr_any_len );
syntax, mr, (unsigned char *)&value->bv_val[j], SLAPD_GLOBAL(index_substr_any_len) );
ber_dupbv_x( &keys[nkeys++], &digest, ctx );
}
}
@ -3620,7 +3615,7 @@ slap_schema_init( void )
int i;
/* we should only be called once (from main) */
assert( schema_init_done == 0 );
assert( SLAPD_GLOBAL(schema_init_done) == 0 );
for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
res = register_syntax( &syntax_defs[i] );
@ -3653,7 +3648,7 @@ slap_schema_init( void )
}
res = slap_schema_load();
schema_init_done = 1;
SLAPD_GLOBAL(schema_init_done) = 1;
return res;
}

View File

@ -26,8 +26,6 @@
#define OCDEBUG 0
int schema_init_done = 0;
struct slap_internal_schema slap_schema;
static int
@ -1258,7 +1256,7 @@ int
slap_schema_check( void )
{
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
assert( SLAPD_GLOBAL(schema_init_done) == 1 );
/*
* cycle thru attributeTypes to build matchingRuleUse
@ -1267,7 +1265,7 @@ slap_schema_check( void )
return LDAP_OTHER;
}
++schema_init_done;
++SLAPD_GLOBAL(schema_init_done);
return LDAP_SUCCESS;
}

View File

@ -25,8 +25,6 @@
#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);

View File

@ -335,12 +335,12 @@ fe_op_search( Operation *op, SlapReply *rs )
break;
}
if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &default_search_nbase ) ) {
if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &SLAPD_GLOBAL(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, &default_search_base, op->o_tmpmemctx );
ber_dupbv_x( &op->o_req_ndn, &default_search_nbase, 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 );
}
/*
@ -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( default_referral,
rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
NULL, &op->o_req_dn, op->ors_scope );
if (!rs->sr_ref) rs->sr_ref = default_referral;
if (!rs->sr_ref) rs->sr_ref = SLAPD_GLOBAL(default_referral);
rs->sr_err = LDAP_REFERRAL;
send_ldap_result( op, rs );
if (rs->sr_ref != default_referral)
if (rs->sr_ref != SLAPD_GLOBAL(default_referral))
ber_bvarray_free( rs->sr_ref );
rs->sr_ref = NULL;
goto return_results;

View File

@ -55,6 +55,7 @@
#include "ldap_pvt.h"
#include "ldap_pvt_thread.h"
#include "ldap_queue.h"
#include "ldap_rq.h"
LDAP_BEGIN_DECL
@ -2363,13 +2364,15 @@ 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))
@ -2635,6 +2638,63 @@ 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"

View File

@ -156,7 +156,7 @@ slapadd( int argc, char **argv )
break;
}
if( global_schemacheck ) {
if( SLAPD_GLOBAL(schemachecking) ) {
Attribute *sc = attr_find( e->e_attrs,
slap_schema.si_ad_structuralObjectClass );
Attribute *oc = attr_find( e->e_attrs,

View File

@ -121,6 +121,8 @@ slap_tool_init(
free( leakfilename );
#endif
config_init(); /* sets frontendDB */
switch( tool ) {
case SLAPADD:
options = "b:cd:f:i:l:n:prtuvWw";

View File

@ -134,9 +134,9 @@ slapi_entry2str(
#ifdef LDAP_SLAPI
char *ret;
ldap_pvt_thread_mutex_lock( &entry2str_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(entry2str_mutex) );
ret = entry2str( e, len );
ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(entry2str_mutex) );
return ret;
#else /* LDAP_SLAPI */

View File

@ -55,7 +55,7 @@ starttls_extop ( Operation *op, SlapReply *rs )
goto done;
}
if ( !( global_disallows & SLAP_DISALLOW_TLS_2_ANON ) &&
if ( !( SLAPD_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 ( ( global_disallows & SLAP_DISALLOW_TLS_AUTHC ) &&
if ( ( SLAPD_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 ( slap_tls_ctx == NULL ) {
if (default_referral != NULL) {
if ( SLAPD_GLOBAL(tls_ctx) == NULL ) {
if (SLAPD_GLOBAL(default_referral) != NULL) {
/* caller will put the referral in the result */
rc = LDAP_REFERRAL;
goto done;

View File

@ -46,8 +46,6 @@ 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)
{
@ -405,7 +403,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, &slap_sync_cookie, sc_next ) {
LDAP_STAILQ_FOREACH( sc, &SLAPD_GLOBAL(sync_cookie), sc_next ) {
if ( si->si_rid == sc->rid ) {
cmdline_cookie_found = 1;
break;
@ -417,7 +415,7 @@ do_syncrep1(
BerVarray cookie = NULL;
struct berval cookie_bv;
LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
LDAP_STAILQ_REMOVE( &SLAPD_GLOBAL(sync_cookie), sc, sync_cookie, sc_next );
slap_sync_cookie_free( &si->si_syncCookie, 0 );
/* read stored cookie if it exists */
@ -551,7 +549,7 @@ do_syncrep2(
BerVarray syncUUIDs = NULL;
ber_tag_t si_tag;
if ( slapd_shutdown ) {
if ( SLAPD_GLOBAL(shutdown) ) {
rc = -2;
goto done;
}
@ -574,7 +572,7 @@ do_syncrep2(
while (( rc = ldap_result( si->si_ld, LDAP_RES_ANY, LDAP_MSG_ONE,
tout_p, &res )) > 0 )
{
if ( slapd_shutdown ) {
if ( SLAPD_GLOBAL(shutdown) ) {
rc = -2;
goto done;
}
@ -889,7 +887,7 @@ do_syncrepl(
return NULL;
}
if ( slapd_shutdown && si->si_ld ) {
if ( SLAPD_GLOBAL(shutdown) && si->si_ld ) {
ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
connection_client_stop( s );
ldap_unbind( si->si_ld );
@ -951,10 +949,10 @@ do_syncrepl(
* 3) for Refresh and Success, reschedule to run
* 4) for Persist and Success, reschedule to defer
*/
ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(runqueue).rq_mutex );
if ( ldap_pvt_runqueue_isrunning( &syncrepl_rq, rtask )) {
ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask );
if ( ldap_pvt_runqueue_isrunning( &SLAPD_GLOBAL(runqueue), rtask )) {
ldap_pvt_runqueue_stoptask( &SLAPD_GLOBAL(runqueue), rtask );
}
if ( dostop ) {
@ -966,7 +964,7 @@ do_syncrepl(
defer = 0;
}
rtask->interval.tv_sec = si->si_interval;
ldap_pvt_runqueue_resched( &syncrepl_rq, rtask, defer );
ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), 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];
@ -980,19 +978,19 @@ do_syncrepl(
}
if ( !si->si_retrynum || si->si_retrynum[i] == -2 ) {
ldap_pvt_runqueue_remove( &syncrepl_rq, rtask );
ldap_pvt_runqueue_remove( &SLAPD_GLOBAL(runqueue), 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( &syncrepl_rq, rtask, 0 );
ldap_pvt_runqueue_resched( &SLAPD_GLOBAL(runqueue), rtask, 0 );
slap_wake_listener();
}
}
ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(runqueue).rq_mutex );
return NULL;
}