#include "config.h"
static struct berval config_rdn = BER_BVC("cn=config");
-static struct berval access_rdn = BER_BVC("cn=access");
#ifdef SLAPD_MODULES
typedef struct modpath_s {
BerVarray c_dseFiles;
} ConfigFile;
+typedef struct CfOcInfo {
+ struct berval *co_name;
+ ConfigTable *co_table;
+} CfOcInfo;
+
+typedef enum {
+ Cf_Global = 1,
+ Cf_Include,
+ Cf_Backend,
+ Cf_Database,
+ Cf_Overlay
+} CfEtypes;
+
typedef struct CfEntryInfo {
struct CfEntryInfo *ce_sibs;
struct CfEntryInfo *ce_kids;
Entry *ce_entry;
+ CfEtypes ce_type;
BackendInfo *ce_bi;
BackendDB *ce_be;
} CfEntryInfo;
static struct berval cfdir;
+/* Private state */
static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
*cfAd_include;
static ObjectClass *cfOc_global, *cfOc_backend, *cfOc_database,
- *cfOc_include, *cfOc_overlay, *cfOc_access;
+ *cfOc_include, *cfOc_overlay;
static ConfigFile cf_prv, *cfn = &cf_prv;
+static Avlnode *CfOcTree;
+
static int add_syncrepl LDAP_P(( Backend *, char **, int ));
static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
static void syncrepl_unparse LDAP_P (( syncinfo_t *, struct berval *));
"DESC 'OpenLDAP Overlay-specific options' "
"SUP olcConfig STRUCTURAL "
"MAY ( olcOverlay ) )", &cfOc_overlay },
- { "( OLcfgOc:8 "
- "NAME 'olcACL' "
- "DESC 'OpenLDAP Access Control List' "
- "SUP olcConfig STRUCTURAL "
- "MUST ( olcAccess ) )", &cfOc_access },
{ NULL, NULL }
};
return 0;
}
+static int
+CfOcInfo_cmp( const void *c1, const void *c2 ) {
+ const CfOcInfo *co1 = c1;
+ const CfOcInfo *co2 = c2;
+
+ return ber_bvcmp( co1->co_name, co2->co_name );
+}
+
+int
+config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
+ int i;
+ CfOcInfo *co;
+
+ i = init_config_attrs( ct );
+ if ( i ) return i;
+
+ /* set up the objectclasses */
+ i = init_config_ocs( ocs );
+ if ( i ) return i;
+
+ for (i=0; ocs[i].def; i++) {
+ if ( ocs[i].oc ) {
+ co = ch_malloc( sizeof(CfOcInfo) );
+ co->co_name = &(*ocs[i].oc)->soc_cname;
+ co->co_table = ct;
+ avl_insert( &CfOcTree, co, CfOcInfo_cmp, avl_dup_error );
+ }
+ }
+ return 0;
+}
+
int
read_config(const char *fname, const char *dir) {
BackendDB *be;
op->ora_e = e;
op->o_bd->be_add( op, rs );
ce = e->e_private;
+ ce->ce_type = Cf_Include;
+ ce->ce_bi = c->bi;
if ( !ceparent->ce_kids ) {
ceparent->ce_kids = ce;
} else {
config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
op->ora_e = e;
op->o_bd->be_add( op, &rs );
+ ce->ce_type = Cf_Global;
+ ce->ce_bi = c.bi;
parent = e;
ceparent = ce;
rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
e = config_alloc_entry( &parent->e_nname, &rdn );
ce = e->e_private;
+ ce->ce_type = Cf_Backend;
ce->ce_bi = bi;
c.bi = bi;
config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
ce = e->e_private;
c.be = bptr;
c.bi = bi;
+ ce->ce_type = Cf_Database;
ce->ce_be = c.be;
ce->ce_bi = c.bi;
config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
ce = oe->e_private;
c.be = bptr;
c.bi = &on->on_bi;
+ ce->ce_type = Cf_Overlay;
ce->ce_be = c.be;
ce->ce_bi = c.bi;
config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
parse_oidm( "slapd", i, 3, argv );
}
- i = init_config_attrs( ct );
+ bi->bi_cf_table = ct;
+
+ i = config_register_schema( ct, cf_ocs );
if ( i ) return i;
/* set up the notable AttributeDescriptions */
ads[3].sub = slap_schema.si_ad_ditContentRules;
ads[5].sub = slap_schema.si_ad_objectClasses;
- bi->bi_cf_table = ct;
-
i = 0;
for (;ct->name;ct++) {
if (strcmp(ct->name, ads[i].name)) continue;
if (!ads[i].name) break;
}
- /* set up the objectclasses */
- i = init_config_ocs( cf_ocs );
-
- return i;
+ return 0;
}
char *slapd_pid_file = NULL;
char *slapd_args_file = NULL;
-char *strtok_quote_ptr;
-
int use_reverse_lookup = 0;
#ifdef LDAP_SLAPI
static void fp_getline_init(ConfigArgs *c);
static int fp_parse_line(ConfigArgs *c);
-static char *strtok_quote(char *line, char *sep);
+static char *strtok_quote(char *line, char *sep, char **quote_ptr);
int read_config_file(const char *fname, int depth, ConfigArgs *cf);
snprintf( c->log, sizeof( c->log ), "%s: line %lu",
c->fname, c->lineno );
+ c->argc = 0;
if ( fp_parse_line( c ) ) {
goto badline;
}
static char *
-strtok_quote( char *line, char *sep )
+strtok_quote( char *line, char *sep, char **quote_ptr )
{
int inquote;
char *tmp;
static char *next;
- strtok_quote_ptr = NULL;
+ *quote_ptr = NULL;
if ( line != NULL ) {
next = line;
}
default:
if ( ! inquote ) {
if ( strchr( sep, *next ) != NULL ) {
- strtok_quote_ptr = next;
+ *quote_ptr = next;
*next++ = '\0';
return( tmp );
}
char *token;
char *tline = ch_strdup(c->line);
char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
+ char *quote_ptr;
int i;
- c->argc = 0;
- token = strtok_quote(tline, " \t");
+ token = strtok_quote(tline, " \t", "e_ptr);
if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
- if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
- Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
- if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
+ if(quote_ptr) *quote_ptr = ' ';
+ Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno,
+ hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
+ if(quote_ptr) *quote_ptr = '\0';
- for(; token; token = strtok_quote(NULL, " \t")) {
+ for(; token; token = strtok_quote(NULL, " \t", "e_ptr)) {
if(c->argc == c->argv_size - 1) {
char **tmp;
tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));