/* config.c - configuration file handling routines */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
slap_mask_t global_requires = 0;
slap_ssf_set_t global_ssf_set;
char *replogfile;
-int global_lastmod = ON;
int global_idletimeout = 0;
char *global_host = NULL;
char *global_realm = NULL;
char *default_passwd_hash;
struct berval default_search_base = { 0, NULL };
struct berval default_search_nbase = { 0, NULL };
-int num_subs = 0;
+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;
char *cargv[MAXARGS+1];
int lineno, i;
int rc;
- struct berval *vals[2];
- struct berval val;
+ struct berval vals[2];
+ static int lastmod = 1;
static BackendInfo *bi = NULL;
static BackendDB *be = NULL;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
if ( (fp = fopen( fname, "r" )) == NULL ) {
ldap_syslog = 1;
if ( cargc < 2 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
+ "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY,
- "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
+ "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
fname, lineno, 0 );
#endif
if ( load_ucdata( NULL ) < 0 ) return 1;
{
- struct berval dn, *pdn, *ndn;
+ struct berval dn;
dn.bv_val = cargv[1];
dn.bv_len = strlen( dn.bv_val );
- rc = dnPretty( NULL, &dn, &pdn );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: defaultSearchBase DN is invalid.\n",
- fname, lineno ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: defaultSearchBase DN is invalid\n",
- fname, lineno, 0 );
-#endif
- return( 1 );
- }
+ rc = dnPrettyNormal( NULL, &dn,
+ &default_search_base,
+ &default_search_nbase );
- rc = dnNormalize( NULL, &dn, &ndn );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
"%s: line %d: defaultSearchBase DN is invalid\n",
fname, lineno, 0 );
#endif
- ber_bvfree( ndn );
return( 1 );
}
-
- default_search_base = *pdn;
- default_search_nbase = *ndn;
-
- free( pdn );
- free( ndn );
}
/* set maximum threads in thread pool */
fname, lineno, 0 );
#endif
} else {
- be->be_glueflags |= SLAP_GLUE_SUBORDINATE;
- num_subs++;
+ be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
+ num_subordinates++;
}
/* set database suffix */
dn.bv_val = cargv[1];
dn.bv_len = strlen( cargv[1] );
+ pdn = ch_malloc( sizeof( struct berval ));
+ ndn = ch_malloc( sizeof( struct berval ));
- rc = dnPretty( NULL, &dn, &pdn );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: suffix DN is invalid.\n",
- fname, lineno ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: suffix DN is invalid\n",
- fname, lineno, 0 );
-#endif
- return( 1 );
- }
-
- rc = dnNormalize( NULL, &dn, &ndn );
+ rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
"%s: line %d: suffix DN is invalid\n",
fname, lineno, 0 );
#endif
- ber_bvfree( ndn );
return( 1 );
}
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: suffix already served by a preceding "
"backend \"%s\"\n", fname, lineno,
- tmp_be->be_suffix[0] ));
+ tmp_be->be_suffix[0]->bv_val ));
#else
Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
"already served by a preceeding backend \"%s\"\n",
- fname, lineno, tmp_be->be_suffix[0] );
+ fname, lineno, tmp_be->be_suffix[0]->bv_val );
#endif
ber_bvfree( pdn );
ber_bvfree( ndn );
#endif
}
- charray_add( &be->be_suffix, pdn->bv_val );
+ ber_bvecadd( &be->be_suffix, pdn );
ber_bvecadd( &be->be_nsuffix, ndn );
/* set database suffixAlias */
} else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
Backend *tmp_be;
- struct berval alias, *palias, *nalias;
- struct berval aliased, *paliased, *naliased;
+ struct berval alias, *palias, nalias;
+ struct berval aliased, *paliased, naliased;
if ( cargc < 2 ) {
#ifdef NEW_LOGGING
alias.bv_val = cargv[1];
alias.bv_len = strlen( cargv[1] );
+ palias = ch_malloc(sizeof(struct berval));
- rc = dnPretty( NULL, &alias, &palias );
+ rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
return( 1 );
}
- rc = dnNormalize( NULL, &alias, &nalias );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: alias DN is invalid.\n",
- fname, lineno ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: alias DN is invalid\n",
- fname, lineno, 0 );
-#endif
- ber_bvfree( palias );
- return( 1 );
- }
-
- tmp_be = select_backend( nalias, 0, 0 );
- ber_bvfree( nalias );
- if ( tmp_be != be ) {
+ tmp_be = select_backend( &nalias, 0, 0 );
+ free( nalias.bv_val );
+ if ( tmp_be && tmp_be != be ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: suffixAlias served by a preceeding "
"backend \"%s\"\n",
- fname, lineno, tmp_be->be_suffix[0] ));
+ fname, lineno, tmp_be->be_suffix[0]->bv_val ));
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: suffixAlias served by"
" a preceeding backend \"%s\"\n",
- fname, lineno, tmp_be->be_suffix[0] );
+ fname, lineno, tmp_be->be_suffix[0]->bv_val );
#endif
ber_bvfree( palias );
return -1;
aliased.bv_val = cargv[2];
aliased.bv_len = strlen( cargv[2] );
+ paliased = ch_malloc(sizeof(struct berval));
- rc = dnPretty( NULL, &aliased, &paliased );
+ rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
return( 1 );
}
- rc = dnNormalize( NULL, &aliased, &naliased );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: aliased DN is invalid.\n",
- fname, lineno ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: aliased DN is invalid\n",
- fname, lineno, 0 );
-#endif
- ber_bvfree( palias );
- ber_bvfree( paliased );
- return( 1 );
- }
-
- tmp_be = select_backend( naliased, 0, 0 );
- ber_bvfree( naliased );
- if ( tmp_be != be ) {
+ tmp_be = select_backend( &naliased, 0, 0 );
+ free( naliased.bv_val );
+ if ( tmp_be && tmp_be != be ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_INFO,
"%s: line %d: suffixAlias derefs to a different backend "
- "a preceeding backend \"%s\" (ignored)\n",
- fname, lineno, tmp_be->be_suffix[0] ));
+ "a preceeding backend \"%s\"\n",
+ fname, lineno, tmp_be->be_suffix[0]->bv_val ));
#else
Debug( LDAP_DEBUG_ANY,
"%s: line %d: suffixAlias derefs to differnet backend"
- " a preceeding backend \"%s\" (ignored)\n",
- fname, lineno, tmp_be->be_suffix[0] );
+ " a preceeding backend \"%s\"\n",
+ fname, lineno, tmp_be->be_suffix[0]->bv_val );
#endif
ber_bvfree( palias );
ber_bvfree( paliased );
#endif
} else {
- struct berval dn, *pdn = NULL, *ndn = NULL;
+ struct berval dn;
if ( load_ucdata( NULL ) < 0 ) return 1;
dn.bv_val = cargv[1];
dn.bv_len = strlen( cargv[1] );
- rc = dnPretty( NULL, &dn, &pdn );
- if( rc != LDAP_SUCCESS ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
- "%s: line %d: rootdn DN is invalid.\n",
- fname, lineno ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: rootdn DN is invalid\n",
- fname, lineno, 0 );
-#endif
- return( 1 );
- }
+ rc = dnPrettyNormal( NULL, &dn,
+ &be->be_rootdn,
+ &be->be_rootndn );
- rc = dnNormalize( NULL, &dn, &ndn );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
"%s: line %d: rootdn DN is invalid\n",
fname, lineno, 0 );
#endif
- ber_bvfree( ndn );
return( 1 );
}
-
- be->be_rootdn = *pdn;
- be->be_rootndn = *ndn;
-
- free( pdn );
- free( ndn );
}
/* set super-secret magic database password */
return 1;
}
- vals[0]->bv_val = cargv[1];
- vals[0]->bv_len = strlen( vals[0]->bv_val );
+ vals[0].bv_val = cargv[1];
+ vals[0].bv_len = strlen( vals[0].bv_val );
value_add( &default_referral, vals );
#ifdef NEW_LOGGING
return( 1 );
}
if ( strcasecmp( cargv[1], "off" ) == 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
+ "%s: line %d: schema checking disabled! your mileage may vary!\n",
+ fname, lineno ));
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: schema checking disabled! your mileage may vary!\n",
+ fname, lineno, 0 );
+#endif
global_schemacheck = 0;
} else {
global_schemacheck = 1;
#endif
} else {
- struct berval dn, *ndn = NULL;
+ struct berval dn;
if ( load_ucdata( NULL ) < 0 ) return 1;
dn.bv_val = cargv[1];
dn.bv_len = strlen( cargv[1] );
- rc = dnNormalize( NULL, &dn, &ndn );
+ rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
#endif
return 1;
}
-
- be->be_update_ndn = *ndn;
- free( ndn );
}
} else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
return 1;
}
- vals[0]->bv_val = cargv[1];
- vals[0]->bv_len = strlen( vals[0]->bv_val );
+ vals[0].bv_val = cargv[1];
+ vals[0].bv_len = strlen( vals[0].bv_val );
value_add( &be->be_update_refs, vals );
/* replication log file to which changes are appended */
if ( cargc < 2 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
- "missing filename in \"rootDSEfile <filename>\" line.\n",
+ "missing filename in \"rootDSE <filename>\" line.\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "missing filename in \"rootDSEfile <filename>\" line.\n",
+ "missing filename in \"rootDSE <filename>\" line.\n",
fname, lineno, 0 );
#endif
return 1;
if( read_root_dse_file( cargv[1] ) ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
- "could not read \"rootDSEfile <filename>\" line.\n",
+ "could not read \"rootDSE <filename>\" line.\n",
fname, lineno ));
#else
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
- "could not read \"rootDSEfile <filename>\" line\n",
+ "could not read \"rootDSE <filename>\" line\n",
fname, lineno, 0 );
#endif
return 1;
return( 1 );
}
if ( strcasecmp( cargv[1], "on" ) == 0 ) {
- if ( be )
- be->be_lastmod = ON;
- else
- global_lastmod = ON;
+ if ( be ) {
+ be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
+ } else {
+ lastmod = 1;
+ }
} else {
- if ( be )
- be->be_lastmod = OFF;
- else
- global_lastmod = OFF;
+ if ( be ) {
+ be->be_flags |= SLAP_BFLAG_NOLASTMOD;
+ } else {
+ lastmod = 0;
+ }
}
/* set idle timeout value */