/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
static int check = CHECK_NONE;
static int version = 0;
+void *slap_tls_ctx;
+
static int
slapd_opt_slp( const char *val, void *arg )
{
#ifdef HAVE_SLP
/* NULL is default */
if ( val == NULL || strcasecmp( val, "on" ) == 0 ) {
- SLAPD_GLOBAL(register_slp) = 1;
+ slapd_register_slp = 1;
} else if ( strcasecmp( val, "off" ) == 0 ) {
- SLAPD_GLOBAL(register_slp) = 0;
+ slapd_register_slp = 0;
/* NOTE: add support for URL specification? */
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, &SLAPD_GLOBAL(sync_cookie), sc_next ) {
+ LDAP_STAILQ_FOREACH( scp_entry, &slap_sync_cookie, sc_next ) {
if ( scp->rid == scp_entry->rid ) {
Debug( LDAP_DEBUG_ANY,
"main: duplicated replica id in cookies\n",
goto destroy;
}
}
- LDAP_STAILQ_INSERT_TAIL( &SLAPD_GLOBAL(sync_cookie), scp, sc_next );
+ LDAP_STAILQ_INSERT_TAIL( &slap_sync_cookie, scp, sc_next );
break;
case 'd': /* set debug level and 'do not detach' flag */
(void) ldap_pvt_thread_initialize();
- lutil_set_debug_level( "slapd", slap_debug );
ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
ldif_debug = slap_debug;
goto destroy;
}
+#ifdef SLAP_DYNACL
+ if ( acl_init() ) {
+ goto destroy;
+ }
+#endif /* SLAP_DYNACL */
+
if ( read_config( configfile, 0 ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
}
}
- if ( glue_sub_init( ) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "subordinate config error\n",
- 0, 0, 0 );
- goto destroy;
- }
-
if ( slap_schema_check( ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"schema prep error\n",
goto destroy;
}
/* Retrieve slapd's own ctx */
- ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &SLAPD_GLOBAL(tls_ctx) );
+ ldap_pvt_tls_get_option( NULL, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
/* Restore previous ctx */
ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_CTX, def_ctx );
}
#endif
(void) SIGNAL( SIGINT, slap_sig_shutdown );
(void) SIGNAL( SIGTERM, slap_sig_shutdown );
+#ifdef SIGTRAP
+ (void) SIGNAL( SIGTRAP, slap_sig_shutdown );
+#endif
#ifdef LDAP_SIGCHLD
(void) SIGNAL( LDAP_SIGCHLD, wait4child );
#endif
* FIXME: moved here from slapd_daemon_task()
* because back-monitor db_open() needs it
*/
- time( &SLAPD_GLOBAL(starttime) );
+ time( &starttime );
if ( slap_startup( NULL ) != 0 ) {
rc = 1;
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
- if ( SLAPD_GLOBAL(pid_file) != NULL ) {
- FILE *fp = fopen( SLAPD_GLOBAL(pid_file), "w" );
+ if ( slapd_pid_file != NULL ) {
+ FILE *fp = fopen( slapd_pid_file, "w" );
if( fp != NULL ) {
fprintf( fp, "%d\n", (int) getpid() );
fclose( fp );
} else {
- free(SLAPD_GLOBAL(pid_file));
- SLAPD_GLOBAL(pid_file) = NULL;
+ free(slapd_pid_file);
+ slapd_pid_file = NULL;
}
}
- if ( SLAPD_GLOBAL(args_file) != NULL ) {
- FILE *fp = fopen( SLAPD_GLOBAL(args_file), "w" );
+ if ( slapd_args_file != NULL ) {
+ FILE *fp = fopen( slapd_args_file, "w" );
if( fp != NULL ) {
for ( i = 0; i < g_argc; i++ ) {
fprintf( fp, "\n" );
fclose( fp );
} else {
- free(SLAPD_GLOBAL(args_file));
- SLAPD_GLOBAL(args_file) = NULL;
+ free(slapd_args_file);
+ slapd_args_file = NULL;
}
}
/* remember an error during destroy */
rc |= slap_destroy();
- while ( !LDAP_STAILQ_EMPTY( &SLAPD_GLOBAL(sync_cookie) )) {
- scp = LDAP_STAILQ_FIRST( &SLAPD_GLOBAL(sync_cookie) );
- LDAP_STAILQ_REMOVE_HEAD( &SLAPD_GLOBAL(sync_cookie), sc_next );
+ while ( !LDAP_STAILQ_EMPTY( &slap_sync_cookie )) {
+ scp = LDAP_STAILQ_FIRST( &slap_sync_cookie );
+ LDAP_STAILQ_REMOVE_HEAD( &slap_sync_cookie, sc_next );
ch_free( scp );
}
ldap_pvt_tls_destroy();
#endif
- if ( SLAPD_GLOBAL(pid_file) != NULL ) {
- unlink( SLAPD_GLOBAL(pid_file) );
+ if ( slapd_pid_file != NULL ) {
+ unlink( slapd_pid_file );
}
- if ( SLAPD_GLOBAL(args_file) != NULL ) {
- unlink( SLAPD_GLOBAL(args_file) );
+ if ( slapd_args_file != NULL ) {
+ unlink( slapd_args_file );
}
config_destroy();