struct berval default_search_base = { 0, NULL };
struct berval default_search_nbase = { 0, NULL };
unsigned num_subordinates = 0;
+#ifdef SLAPD_SCHEMA_DN
+struct berval global_schemadn = { 0, NULL };
+struct berval global_schemandn = { 0, NULL };
+#endif
ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
static int load_ucdata(char *path);
int
-read_config( const char *fname )
+read_config( const char *fname, int depth )
{
FILE *fp;
char *line, *savefname, *saveline;
vals[1].bv_val = NULL;
- cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
- cargv_size = ARGS_STEP + 1;
+ if ( depth == 0 ) {
+ cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
+ cargv_size = ARGS_STEP + 1;
+ }
if ( (fp = fopen( fname, "r" )) == NULL ) {
ldap_syslog = 1;
return 1;
#endif /* HAVE_CYRUS_SASL */
+#ifdef SLAPD_SCHEMA_DN
+ } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
+ struct berval dn;
+ if ( cargc < 2 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( CONFIG, CRIT,
+ "%s: line %d: missing dn in "
+ "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
+ fname, lineno, 0 );
+#endif
+ return 1 ;
+ }
+ ber_str2bv( cargv[1], 0, 0, &dn );
+ if ( be ) {
+ rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
+ &be->be_schemandn );
+ } else {
+ rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
+ &global_schemandn );
+ }
+ if ( rc != LDAP_SUCCESS ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( CONFIG, CRIT,
+ "%s: line %d: schemadn DN is invalid.\n",
+ fname, lineno , 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: schemadn DN is invalid\n",
+ fname, lineno, 0 );
+#endif
+ return 1;
+ }
+#endif /* SLAPD_SCHEMA_DN */
/* set UCDATA path */
} else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
int err;
savefname = ch_strdup( cargv[1] );
savelineno = lineno;
- if ( read_config( savefname ) != 0 ) {
+ if ( read_config( savefname, depth+1 ) != 0 ) {
return( 1 );
}
}
fclose( fp );
+ if ( depth == 0 ) ch_free( cargv );
+
+#ifdef SLAPD_SCHEMA_DN
+ if ( !global_schemadn.bv_val ) {
+ ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
+ &global_schemadn );
+ dnNormalize2( NULL, &global_schemadn, &global_schemandn );
+ }
+#endif
+
if ( load_ucdata( NULL ) < 0 ) return 1;
return( 0 );
}
token = strtok_quote( line, " \t" );
logline = line;
- if ( token &&
- (strcasecmp( token, "rootpw" ) == 0 ||
- strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
- strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
- strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
- strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
- sprintf( logline = logbuf, "%s ***", token );
- if ( strtok_quote_ptr )
+
+ if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
+ strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
+ strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
+ strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
+ strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
+ {
+ snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
+ }
+
+ if ( strtok_quote_ptr ) {
*strtok_quote_ptr = ' ';
+ }
+
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
#else
Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
#endif
- if ( strtok_quote_ptr )
+
+ if ( strtok_quote_ptr ) {
*strtok_quote_ptr = '\0';
+ }
for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
if ( cargc == cargv_size - 1 ) {
static char buf[BUFSIZ];
static char *line;
-static int lmax, lcur;
-
-#define CATLINE( buf ) { \
- int len; \
- len = strlen( buf ); \
- while ( lcur + len + 1 > lmax ) { \
- lmax += BUFSIZ; \
- line = (char *) ch_realloc( line, lmax ); \
- } \
- strcpy( line + lcur, buf ); \
- lcur += len; \
-}
+static size_t lmax, lcur;
+
+#define CATLINE( buf ) \
+ do { \
+ size_t len = strlen( buf ); \
+ while ( lcur + len + 1 > lmax ) { \
+ lmax += BUFSIZ; \
+ line = (char *) ch_realloc( line, lmax ); \
+ } \
+ strcpy( line + lcur, buf ); \
+ lcur += len; \
+ } while( 0 )
static char *
fp_getline( FILE *fp, int *lineno )
config_destroy( )
{
ucdata_unload( UCDATA_ALL );
+#ifdef SLAPD_SCHEMA_DN
+ free( global_schemandn.bv_val );
+ free( global_schemadn.bv_val );
+#endif
free( line );
if ( slapd_args_file )
free ( slapd_args_file );