*/
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 {
#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 {
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 );
}
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 );
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 );
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;
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 );
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 );
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 );
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 );
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 );
}
}
} 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 );
}
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;
}
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;
#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;
}
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 );
}
: 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 );
}
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 );
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 );
#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;
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 );
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 );
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 );
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 );
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 );
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 );
}
}
} 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 );
}
BackendInfo *bi
)
{
- bi->bi_controls = slap_known_controls;
+ bi->bi_controls = SLAPD_GLOBAL(known_controls);
return 0;
}
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
# 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 ),
}
#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
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 */
* 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;
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;
}
}
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 );
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,
}
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 );
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
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 );
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;
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 );
}
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 );
}
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 */
}
}
- 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++ ) {
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 );
}
}
}
}
#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
#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;
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";
glue_sub_init( )
{
int i, j;
- int cont = num_subordinates;
+ int cont = SLAPD_GLOBAL(num_subordinates);
BackendDB *b1, *be;
BackendInfo *bi = NULL;
glueinfo *gi;
"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,
}
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 );
}
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";
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";
#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";
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 );
}
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 );
}
*/
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;
}
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/errno.h>
+#include <ac/unistd.h>
#include "slap.h"
#ifdef LDAP_SLAPI
/*
* 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);
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 )
{
return( 1 );
}
- local_ssf = ssf;
+ SLAPD_GLOBAL(local_ssf) = ssf;
/* set thread concurrency */
} else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
}
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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 ) {
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;
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,
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 ) {
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 ) {
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 */ ;
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 );
"%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 );
}
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 */
} else {
SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
- num_subordinates++;
+ SLAPD_GLOBAL(num_subordinates)++;
}
/* add an overlay to this backend */
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 );
}
}
- global_allows |= allows;
+ SLAPD_GLOBAL(allows) |= allows;
/* disallow these features */
} else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
}
}
- global_disallows |= disallows;
+ SLAPD_GLOBAL(disallows) |= disallows;
/* require these features */
} else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
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 */
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,
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 */
return( 1 );
}
if ( strcasecmp( cargv[1], "off" ) == 0 ) {
- global_gentlehup = 0;
+ SLAPD_GLOBAL(gentlehup) = 0;
} else {
- global_gentlehup = 1;
+ SLAPD_GLOBAL(gentlehup) = 1;
}
#endif
return( 1 );
}
- global_idletimeout = i;
+ SLAPD_GLOBAL(idletimeout) = i;
/* include another config file */
} else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
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 ) {
}
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",
"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 "
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
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
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
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;
}
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 );
{
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 );
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();
assert( s >= 0 );
#ifndef HAVE_WINSOCK
- assert( s < dtblsize );
+ assert( s < SLAPD_GLOBAL(dtblsize) );
#endif
ldap_pvt_thread_mutex_lock( &connections_mutex );
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 ) {
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;
}
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 );
}
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
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();
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 );
}
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 );
}
#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
{
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 );
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
/* 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)
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;
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;
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 );
#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;
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";
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",
}
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 );
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 ) {
= 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,
}
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 ) {
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;
}
ch_free( sc );
}
- ldap_charray_free( slap_known_controls );
+ ldap_charray_free( SLAPD_GLOBAL(known_controls) );
}
/*
#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
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;
#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;
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) {
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;
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
i, 0, 0 );
#ifdef HAVE_SLP
- if( slapd_register_slp ) {
+ if( SLAPD_GLOBAL(register_slp) ) {
slapd_slp_init( urls );
slapd_slp_reg();
}
sockdestroy();
#ifdef HAVE_SLP
- if( slapd_register_slp ) {
+ if( SLAPD_GLOBAL(register_slp) ) {
slapd_slp_dereg();
slapd_slp_deinit();
}
#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;
#endif
/* initialization complete. Here comes the loop. */
- while ( !slapd_shutdown ) {
+ while ( !SLAPD_GLOBAL(shutdown) ) {
ber_socket_t i;
int ns;
int at;
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;
}
}
#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 );
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 );
Debug( LDAP_DEBUG_CONNS,
"daemon: select failed (%d): %s\n",
err, sock_errstr(err), 0 );
- slapd_shutdown = 2;
+ SLAPD_GLOBAL(shutdown) = 2;
}
}
continue;
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",
#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();
}
sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
- ssf = local_ssf;
+ ssf = SLAPD_GLOBAL(local_ssf);
{
uid_t uid;
gid_t gid;
#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) {
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",
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;
}
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);
*/
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" );
#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,
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";
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;
}
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;
*/
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 );
/*
* 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;
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 );
"%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();
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;
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 );
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? */
slap_sl_mem_init();
+ config_init(); /* sets frontendDB */
+
serverName = lutil_progname( "slapd", argc, argv );
if ( strcmp( serverName, "slapd" ) ) {
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",
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 */
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 );
}
* 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;
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++ ) {
fprintf( fp, "\n" );
fclose( fp );
} else {
- free(slapd_args_file);
- slapd_args_file = NULL;
+ free(SLAPD_GLOBAL(args_file));
+ SLAPD_GLOBAL(args_file) = NULL;
}
}
/* 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 );
}
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();
*/
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" );
/* 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,
#ifdef HAVE_GMTIME_R
ltm = gmtime_r( &now, <m_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 );
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;
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;
*/
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" );
#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,
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 );
}
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;
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 );
* 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 ) ) {
* 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 );
}
}
}
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;
}
/* 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 )
}
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;
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);
* 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);
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;
}
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,
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;
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
#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;
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
}
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];
char ***,
char *,
const char * ));
-#ifdef LDAP_SLAPI
-LDAP_SLAPD_V (int) slapi_plugins_used;
-#endif
-
/*
* connection.c
*/
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
*/
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
/*
* 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
/*
/*
* 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 ));
* 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((
/*
* 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;
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;
}
/* 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;
}
}
lock_fclose( fp, lfp );
- ldap_pvt_thread_mutex_unlock( &replog_mutex );
+ ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
}
static void
}
#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
}
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",
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
/* 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 */
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;
}
}
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 );
return 1;
} else {
- global_host = ch_strdup( cargv[1] );
+ SLAPD_GLOBAL(host) = ch_strdup( cargv[1] );
}
/* set SASL realm */
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 );
return 1;
} else {
- global_realm = ch_strdup( cargv[1] );
+ SLAPD_GLOBAL(realm) = ch_strdup( cargv[1] );
}
/* SASL security properties */
#ifdef HAVE_CYRUS_SASL
sasl_done();
#endif
- free( global_host );
- global_host = NULL;
+ free( SLAPD_GLOBAL(host) );
+ SLAPD_GLOBAL(host) = NULL;
return 0;
}
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 */
*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 );
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
*/
#ifdef HAVE_GMTIME_R
- ltm = gmtime_r( &starttime, <m_buf );
+ ltm = gmtime_r( &SLAPD_GLOBAL(starttime), <m_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;
}
/* 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 );
}
}
}
- } else if ( global_disallows & SLAP_DISALLOW_AUX_WO_CR ) {
+ } else if ( SLAPD_GLOBAL(disallows) & SLAP_DISALLOW_AUX_WO_CR ) {
k = -1;
} else {
k = 0;
#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,
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);
}
}
}
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 ) {
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);
}
}
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 );
/* 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 );
}
}
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 );
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 );
/* 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 );
}
}
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] );
}
res = slap_schema_load();
- schema_init_done = 1;
+ SLAPD_GLOBAL(schema_init_done) = 1;
return res;
}
#define OCDEBUG 0
-int schema_init_done = 0;
-
struct slap_internal_schema slap_schema;
static 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
return LDAP_OTHER;
}
- ++schema_init_done;
+ ++SLAPD_GLOBAL(schema_init_done);
return LDAP_SUCCESS;
}
#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);
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 );
}
/*
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;
#include "ldap_pvt.h"
#include "ldap_pvt_thread.h"
#include "ldap_queue.h"
+#include "ldap_rq.h"
LDAP_BEGIN_DECL
} 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))
} 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"
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,
free( leakfilename );
#endif
+ config_init(); /* sets frontendDB */
+
switch( tool ) {
case SLAPADD:
options = "b:cd:f:i:l:n:prtuvWw";
#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 */
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,
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";
}
/* 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;
static AttributeDescription *sync_descs[4];
-struct runqueue_s syncrepl_rq;
-
void
init_syncrepl(syncinfo_t *si)
{
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;
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 */
BerVarray syncUUIDs = NULL;
ber_tag_t si_tag;
- if ( slapd_shutdown ) {
+ if ( SLAPD_GLOBAL(shutdown) ) {
rc = -2;
goto done;
}
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;
}
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 );
* 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 ) {
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];
}
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;
}