X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fconfig.c;h=8e8558c053b72ea06e576859d2f3cc1757409e48;hb=46cb141185d5a04c43d3707baff0df0b8358f50b;hp=649be367e77b29839880bb4c93d0854fae406546;hpb=acbb5cf689a4336af05c9f259d909d8141055bac;p=openldap diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 649be367e7..8e8558c053 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -488,7 +488,7 @@ init_config_attrs(ConfigTable *ct) { } } code = slap_str2ad( at->at_names[0], &ct[i].ad, &err ); - if ( freeit ) { + if ( freeit || code ) { ldap_attributetype_free( at ); } else { ldap_memfree( at ); @@ -523,10 +523,14 @@ init_config_ocs( ConfigOCs *ocs ) { if ( code && code != SLAP_SCHERR_CLASS_DUP ) { fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n", ocs[i].co_def, scherr2str(code), err ); + ldap_objectclass_free(oc); return code; } ocs[i].co_oc = oc_find(oc->oc_names[0]); - ldap_memfree(oc); + if ( code ) + ldap_objectclass_free(oc); + else + ldap_memfree(oc); } return 0; } @@ -692,6 +696,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) Debug(LDAP_DEBUG_ANY, "could not stat config file \"%s\": %s (%d)\n", fname, strerror(errno), errno); + ch_free( c ); return(1); } @@ -700,6 +705,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) Debug(LDAP_DEBUG_ANY, "regular file expected, got \"%s\"\n", fname, 0, 0 ); + ch_free( c ); return(1); } @@ -709,6 +715,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) Debug(LDAP_DEBUG_ANY, "could not open config file \"%s\": %s (%d)\n", fname, strerror(errno), errno); + ch_free( c ); return(1); } @@ -735,15 +742,10 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) } if ( c->argc < 1 ) { - Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: bad config line" - SLAPD_CONF_UNKNOWN_IGNORED ".\n", + Debug( LDAP_DEBUG_ANY, "%s: bad config line.\n", c->log, 0, 0); -#ifdef SLAPD_CONF_UNKNOWN_BAILOUT rc = 1; goto done; -#else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ - continue; -#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ } c->op = SLAP_CONFIG_ADD; @@ -780,13 +782,9 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) if ( rc ) { switch(rc) { case SLAP_CONF_UNKNOWN: - Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: " - "unknown directive <%s> inside backend info definition" - SLAPD_CONF_UNKNOWN_IGNORED ".\n", + Debug( LDAP_DEBUG_ANY, "%s: unknown directive " + "<%s> inside backend info definition.\n", c->log, *c->argv, 0); -#ifndef SLAPD_CONF_UNKNOWN_BAILOUT - continue; -#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ default: rc = 1; goto done; @@ -805,11 +803,13 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv); } - if ( rc == SLAP_CONF_UNKNOWN && SLAP_ISGLOBALOVERLAY( frontendDB ) ) { + if ( rc == SLAP_CONF_UNKNOWN && SLAP_ISGLOBALOVERLAY( frontendDB ) ) + { /* global overlays may need * definitions inside other databases... */ - rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv); + rc = (*frontendDB->be_config)( frontendDB, + c->fname, (int)c->lineno, c->argc, c->argv ); } switch ( rc ) { @@ -817,13 +817,9 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) break; case SLAP_CONF_UNKNOWN: - Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: " - "unknown directive <%s> inside backend database " - "definition" SLAPD_CONF_UNKNOWN_IGNORED ".\n", + Debug( LDAP_DEBUG_ANY, "%s: unknown directive " + "<%s> inside backend database definition.\n", c->log, *c->argv, 0); -#ifndef SLAPD_CONF_UNKNOWN_BAILOUT - break; -#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ default: rc = 1; @@ -831,17 +827,14 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) } } else if ( frontendDB->be_config ) { - rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv); + rc = (*frontendDB->be_config)( frontendDB, + c->fname, (int)c->lineno, c->argc, c->argv); if ( rc ) { switch(rc) { case SLAP_CONF_UNKNOWN: - Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: " - "unknown directive <%s> inside global database definition" - SLAPD_CONF_UNKNOWN_IGNORED ".\n", + Debug( LDAP_DEBUG_ANY, "%s: unknown directive " + "<%s> inside global database definition.\n", c->log, *c->argv, 0); -#ifndef SLAPD_CONF_UNKNOWN_BAILOUT - break; -#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ default: rc = 1; @@ -850,16 +843,11 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft) } } else { - Debug( SLAPD_DEBUG_CONFIG_ERROR, "%s: " - "unknown directive <%s> outside backend info and database definitions" - SLAPD_CONF_UNKNOWN_IGNORED ".\n", + Debug( LDAP_DEBUG_ANY, "%s: unknown directive " + "<%s> outside backend info and database definitions.\n", c->log, *c->argv, 0); -#ifdef SLAPD_CONF_UNKNOWN_BAILOUT rc = 1; goto done; -#else /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ - continue; -#endif /* ! SLAPD_CONF_UNKNOWN_BAILOUT */ } } @@ -878,9 +866,9 @@ done: int verb_to_mask(const char *word, slap_verbmasks *v) { int i; - for(i = 0; !BER_BVISNULL(&v[i].word); i++) - if(!strcasecmp(word, v[i].word.bv_val)) - break; + for(i = 0; !BER_BVISNULL(&v[i].word); i++) { + if(!strcasecmp(word, v[i].word.bv_val)) break; + } return(i); } @@ -924,8 +912,7 @@ slap_verbmasks_init( slap_verbmasks **vp, slap_verbmasks *v ) assert( *vp == NULL ); - for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) - ; + for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) /* EMPTY */; *vp = ch_calloc( i + 1, sizeof( slap_verbmasks ) ); @@ -1507,6 +1494,8 @@ int config_generic_wrapper( Backend *be, const char *fname, int lineno, c.argc = argc; c.argv = argv; c.valx = -1; + c.line = line; + c.op = SLAP_CONFIG_ADD; snprintf( c.log, sizeof( c.log ), "%s: line %d", fname, lineno ); rc = SLAP_CONF_UNKNOWN;