BerVarray c_dseFiles;
} ConfigFile;
-typedef struct CfOcInfo {
- struct berval *co_name;
- ConfigTable *co_table;
- ConfigType co_type;
- ObjectClass *co_oc;
-} CfOcInfo;
-
-typedef struct CfEntryInfo {
- struct CfEntryInfo *ce_parent;
- struct CfEntryInfo *ce_sibs;
- struct CfEntryInfo *ce_kids;
- Entry *ce_entry;
- ConfigType ce_type;
- BackendInfo *ce_bi;
- BackendDB *ce_be;
- void *ce_private;
-} CfEntryInfo;
-
typedef struct {
ConfigFile *cb_config;
CfEntryInfo *cb_root;
/* alphabetical ordering */
-ConfigTable config_back_cf_table[] = {
+static ConfigTable config_back_cf_table[] = {
/* This attr is read-only */
{ "", "", 0, 0, 0, ARG_MAGIC,
&config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
NULL, NULL, NULL, NULL }
};
+/* Routines to check if a child can be added to this type */
+static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
+ cfAddBackend, cfAddModule, cfAddOverlay;
+
+#define CFOC_GLOBAL cf_ocs[1]
+#define CFOC_SCHEMA cf_ocs[2]
+#define CFOC_BACKEND cf_ocs[3]
+#define CFOC_DATABASE cf_ocs[4]
+#define CFOC_OVERLAY cf_ocs[5]
+#define CFOC_INCLUDE cf_ocs[6]
+#define CFOC_MODULE cf_ocs[7]
+
static ConfigOCs cf_ocs[] = {
{ "( OLcfgGlOc:1 "
"NAME 'olcConfig' "
"SUP olcConfig STRUCTURAL "
"MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
"olcObjectClasses $ olcDitContentRules ) )",
- Cft_Schema, &cfOc_schema },
+ Cft_Schema, &cfOc_schema, NULL, cfAddSchema },
{ "( OLcfgGlOc:4 "
"NAME 'olcBackendConfig' "
"DESC 'OpenLDAP Backend-specific options' "
"SUP olcConfig STRUCTURAL "
- "MUST olcBackend )", Cft_Backend, &cfOc_backend },
+ "MUST olcBackend )", Cft_Backend, &cfOc_backend, NULL, cfAddBackend },
{ "( OLcfgGlOc:5 "
"NAME 'olcDatabaseConfig' "
"DESC 'OpenLDAP Database-specific options' "
"olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
"olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
"olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
- Cft_Database, &cfOc_database },
+ Cft_Database, &cfOc_database, NULL, cfAddDatabase },
{ "( OLcfgGlOc:6 "
"NAME 'olcOverlayConfig' "
"DESC 'OpenLDAP Overlay-specific options' "
"SUP olcConfig STRUCTURAL "
- "MUST olcOverlay )", Cft_Overlay, &cfOc_overlay },
+ "MUST olcOverlay )", Cft_Overlay, &cfOc_overlay, NULL, cfAddOverlay },
{ "( OLcfgGlOc:7 "
"NAME 'olcIncludeFile' "
"DESC 'OpenLDAP configuration include file' "
"SUP olcConfig STRUCTURAL "
"MUST olcInclude "
"MAY ( cn $ olcRootDSE ) )",
- Cft_Include, &cfOc_include },
+ Cft_Include, &cfOc_include, NULL, cfAddInclude },
#ifdef SLAPD_MODULES
{ "( OLcfgGlOc:8 "
"NAME 'olcModuleList' "
"DESC 'OpenLDAP dynamic module info' "
"SUP olcConfig STRUCTURAL "
"MUST ( olcModulePath $ olcModuleLoad ) "
- "MAY cn )", Cft_Module, &cfOc_module },
+ "MAY cn )", Cft_Module, &cfOc_module, NULL, cfAddModule },
#endif
{ NULL, 0, NULL }
};
}
cfn = cf;
ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
- rc = read_config_file(c->argv[1], c->depth + 1, c);
+ rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
c->lineno = savelineno - 1;
cfn = cfsave;
if ( rc ) {
argv[2] = NULL;
c.argv = argv;
- ct = config_find_keyword( c.be->be_cf_table, &c );
+ ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
if ( !ct )
return 1;
}
static int
-CfOcInfo_cmp( const void *c1, const void *c2 ) {
- const CfOcInfo *co1 = c1;
- const CfOcInfo *co2 = c2;
+CfOc_cmp( const void *c1, const void *c2 ) {
+ const ConfigOCs *co1 = c1;
+ const ConfigOCs *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;
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_oc = *ocs[i].oc;
- co->co_name = &co->co_oc->soc_cname;
- co->co_table = ct;
- co->co_type = ocs[i].cft;
- avl_insert( &CfOcTree, co, CfOcInfo_cmp, avl_dup_error );
+ for (i=0; ocs[i].co_def; i++) {
+ if ( ocs[i].co_oc ) {
+ ocs[i].co_name = &((*ocs[i].co_oc)->soc_cname);
+ if ( !ocs[i].co_table )
+ ocs[i].co_table = ct;
+ avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
}
}
return 0;
else
cfname = SLAPD_DEFAULT_CONFIGFILE;
- rc = read_config_file(cfname, 0, NULL);
+ rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
if ( rc == 0 )
ber_str2bv( cfname, 0, 1, &cf_prv.c_file );
}
static ConfigTable *
-config_find_table( CfOcInfo **colst, int nocs, AttributeDescription *ad )
+config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad )
{
int i, j;
* list the attributes in the desired sequence.
*/
static void
-sort_attrs( Entry *e, CfOcInfo **colst, int nocs )
+sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
{
Attribute *a, *head = NULL, *tail = NULL, **prev;
int i, j;
for (i=0; i<nocs; i++) {
- if ( colst[i]->co_oc->soc_required ) {
- AttributeType **at = colst[i]->co_oc->soc_required;
+ if ( (*colst[i]->co_oc)->soc_required ) {
+ AttributeType **at = (*colst[i]->co_oc)->soc_required;
for (j=0; at[j]; j++) {
for (a=e->e_attrs, prev=&e->e_attrs; a;
prev = &(*prev)->a_next, a=a->a_next) {
}
}
}
- if ( colst[i]->co_oc->soc_allowed ) {
- AttributeType **at = colst[i]->co_oc->soc_allowed;
+ if ( (*colst[i]->co_oc)->soc_allowed ) {
+ AttributeType **at = (*colst[i]->co_oc)->soc_allowed;
for (j=0; at[j]; j++) {
for (a=e->e_attrs, prev=&e->e_attrs; a;
prev = &(*prev)->a_next, a=a->a_next) {
return 0;
}
-static CfOcInfo **
+static ConfigOCs **
count_ocs( Attribute *oc_at, int *nocs )
{
int i, j, n;
- CfOcInfo co, *coptr, **colst;
+ ConfigOCs co, *coptr, **colst;
/* count the objectclasses */
for ( i=0; oc_at->a_nvals[i].bv_val; i++ );
n = i;
- colst = (CfOcInfo **)ch_malloc( n * sizeof(CfOcInfo *));
+ colst = (ConfigOCs **)ch_malloc( n * sizeof(ConfigOCs *));
for ( i=0, j=0; i<n; i++) {
co.co_name = &oc_at->a_nvals[i];
- coptr = avl_find( CfOcTree, &co, CfOcInfo_cmp );
+ coptr = avl_find( CfOcTree, &co, CfOc_cmp );
/* ignore non-config objectclasses. probably should be
* an error, general data doesn't belong here.
return colst;
}
+static int
+cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
+{
+ if ( p->ce_type != Cft_Global && p->ce_type != Cft_Include )
+ return LDAP_CONSTRAINT_VIOLATION;
+
+ /* If we're reading from a configdir, don't parse this entry */
+ if ( ca->lineno )
+ return LDAP_COMPARE_TRUE;
+
+ if ( p->ce_type == Cft_Global )
+ cfn = &cf_prv;
+ else
+ cfn = p->ce_private;
+ ca->private = cfn;
+ return LDAP_SUCCESS;
+}
+
+static int
+cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
+{
+ ConfigFile *cfo;
+
+ /* This entry is hardcoded, don't re-parse it */
+ if ( p->ce_type == Cft_Global ) {
+ cfn = &cf_prv;
+ ca->private = cfn;
+ return LDAP_COMPARE_TRUE;
+ }
+ if ( p->ce_type != Cft_Schema )
+ return LDAP_CONSTRAINT_VIOLATION;
+
+ cfn = ch_calloc( 1, sizeof(ConfigFile) );
+ ca->private = cfn;
+ cfo = p->ce_private;
+ cfn->c_sibs = cfo->c_kids;
+ cfo->c_kids = cfn;
+ return LDAP_SUCCESS;
+}
+
+static int
+cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
+{
+ if ( p->ce_type != Cft_Global )
+ return LDAP_CONSTRAINT_VIOLATION;
+ ca->be = frontendDB; /* just to get past check_vals */
+ return LDAP_SUCCESS;
+}
+
+static int
+cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
+{
+ if ( p->ce_type != Cft_Global )
+ return LDAP_CONSTRAINT_VIOLATION;
+ return LDAP_SUCCESS;
+}
+
+static int
+cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
+{
+ if ( p->ce_type != Cft_Global )
+ return LDAP_CONSTRAINT_VIOLATION;
+ return LDAP_SUCCESS;
+}
+
+static int
+cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
+{
+ if ( p->ce_type != Cft_Database )
+ return LDAP_CONSTRAINT_VIOLATION;
+ ca->be = p->ce_be;
+ return LDAP_SUCCESS;
+}
+
/* Parse an LDAP entry into config directives */
static int
config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs, int *renum )
{
CfEntryInfo *ce, *last;
- CfOcInfo **colst;
- Attribute *a, *oc_at, *type_attr;
- AttributeDescription *type_ad = NULL;
+ ConfigOCs **colst;
+ Attribute *a, *oc_at;
int i, j, nocs, rc = 0;
ConfigArgs ca = {0};
struct berval pdn;
- ConfigTable *ct, *type_ct = NULL;
+ ConfigTable *ct;
char *ptr;
/* Make sure parent exists and entry does not */
oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
- colst = count_ocs( oc_at, &nocs );
-
- /* Only the root can be Cft_Global, everything else must
- * have a parent. Only limited nesting arrangements are allowed.
+ /* Fake the coordinates based on whether we're part of an
+ * LDAP Add or if reading the config dir
*/
- switch( colst[0]->co_type ) {
- case Cft_Global:
- if ( last ) {
- rc = LDAP_CONSTRAINT_VIOLATION;
- goto leave;
- }
- break;
- case Cft_Schema:
- case Cft_Backend:
- case Cft_Database:
- case Cft_Include:
- if ( !last || ( last->ce_type != Cft_Global &&
- last->ce_type != colst[0]->co_type )) {
- rc = LDAP_CONSTRAINT_VIOLATION;
- goto leave;
- }
- break;
- case Cft_Overlay:
- if ( !last || ( last->ce_type != Cft_Global &&
- last->ce_type != Cft_Database &&
- last->ce_type != colst[0]->co_type )) {
- rc = LDAP_CONSTRAINT_VIOLATION;
- goto leave;
- }
- break;
-#ifdef SLAPD_MODULES
- case Cft_Module:
- if ( !last || last->ce_type != Cft_Global ) {
- rc = LDAP_CONSTRAINT_VIOLATION;
- goto leave;
- }
-#endif
- break;
+ if ( rs ) {
+ ca.fname = "slapd";
+ ca.lineno = 0;
+ } else {
+ ca.fname = cfdir.bv_val;
+ ca.lineno = 1;
}
- sort_attrs( e, colst, nocs );
+ colst = count_ocs( oc_at, &nocs );
- /* Parse all the values and check for simple syntax errors before
- * performing any set actions.
+ /* Only the root can be Cft_Global, everything else must
+ * have a parent. Only limited nesting arrangements are allowed.
*/
- switch (colst[0]->co_type) {
- case Cft_Schema:
- /* The cn=schema entry is all hardcoded, so never reparse it */
- if (last->ce_type == Cft_Global )
- goto ok;
- cfn = ch_calloc( 1, sizeof(ConfigFile) );
- ca.private = cfn;
- break;
- case Cft_Global:
+ rc = LDAP_CONSTRAINT_VIOLATION;
+ if ( colst[0]->co_type == Cft_Global && !last ) {
cfn = &cf_prv;
ca.private = cfn;
ca.be = frontendDB; /* just to get past check_vals */
- break;
+ rc = LDAP_SUCCESS;
+ }
- case Cft_Backend:
- if ( last->ce_type == Cft_Backend )
- ca.bi = last->ce_bi;
- else
- type_ad = cfAd_backend;
- break;
- case Cft_Database:
- if ( last->ce_type == Cft_Database ) {
- ca.be = last->ce_be;
- } else {
- type_ad = cfAd_database;
- /* dummy, just to get past check_vals */
- ca.be = frontendDB;
+ /* Check whether the Add is allowed by its parent, and do
+ * any necessary arg setup
+ */
+ if ( last ) {
+ for ( i=0; i<nocs; i++ ) {
+ if ( colst[i]->co_ldadd &&
+ ( rc = colst[i]->co_ldadd( last, e, &ca ))
+ != LDAP_CONSTRAINT_VIOLATION ) {
+ break;
+ }
}
- break;
-
- case Cft_Overlay:
- ca.be = last->ce_be;
- type_ad = cfAd_overlay;
- break;
+ }
- case Cft_Include:
- if ( !rs ) {
- nocs = 0; /* ignored */
- break;
- }
- if ( last->ce_type == Cft_Global )
- cfn = &cf_prv;
- else
- cfn = last->ce_private;
- type_ad = cfAd_include;
- break;
-#ifdef SLAPD_MODULES
- case Cft_Module: {
-#if 0
- ModPaths *mp;
- char *ptr;
- ptr = strchr( e->e_name.bv_val, '{' );
- if ( !ptr ) {
- rc = LDAP_NAMING_VIOLATION;
- goto leave;
- }
- j = atoi(ptr+1);
- for (i=0, mp=&modpaths; mp && i<j; mp=mp->mp_next);
- /* There is no corresponding modpath for this load? */
- if ( i != j ) {
- rc = LDAP_NAMING_VIOLATION;
- goto leave;
- }
- module_path( mp->mp_path.bv_val );
- ca.private = mp;
-#endif
- }
- break;
-#endif
+ /* Add the entry but don't parse it, we already have its contents */
+ if ( rc == LDAP_COMPARE_TRUE ) {
+ rc = LDAP_SUCCESS;
+ goto ok;
}
- /* If doing an LDAPadd, check for indexed names and any necessary
+ if ( rc != LDAP_SUCCESS )
+ goto leave;
+
+ /* Parse all the values and check for simple syntax errors before
+ * performing any set actions.
+ *
+ * If doing an LDAPadd, check for indexed names and any necessary
* renaming/renumbering. Entries that don't need indexed names are
* ignored. Entries that need an indexed name and arrive without one
* are assigned to the end. Entries that arrive with an index may
goto leave;
init_config_argv( &ca );
- if ( type_ad ) {
- type_attr = attr_find( e->e_attrs, type_ad );
- if ( !type_attr ) {
- rc = LDAP_OBJECT_CLASS_VIOLATION;
- goto leave;
- }
- type_ct = config_find_table( colst, nocs, type_ad );
- if ( !type_ct ) {
- rc = LDAP_OBJECT_CLASS_VIOLATION;
- goto leave;
- }
- rc = check_vals( type_ct, &ca, type_attr, 1);
- if ( rc ) goto leave;
- }
+
+ /* Make sure we process attrs in the required order */
+ sort_attrs( e, colst, nocs );
+
for ( a=e->e_attrs; a; a=a->a_next ) {
- if ( a == type_attr || a == oc_at ) continue;
+ if ( a == oc_at ) continue;
ct = config_find_table( colst, nocs, a->a_desc );
if ( !ct ) continue; /* user data? */
rc = check_vals( ct, &ca, a, 1 );
}
/* Basic syntax checks are OK. Do the actual settings. */
- if ( type_ct ) {
- ca.line = type_attr->a_vals[0].bv_val;
- if ( type_ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
- ptr = strchr( ca.line, '}' );
- if ( ptr ) ca.line = ptr+1;
- }
- ca.valx = 0;
- rc = config_parse_add( type_ct, &ca );
- if ( rc ) {
- rc = LDAP_OTHER;
- goto leave;
- }
- }
for ( a=e->e_attrs; a; a=a->a_next ) {
- if ( a == type_attr || a == oc_at ) continue;
+ if ( a == oc_at ) continue;
ct = config_find_table( colst, nocs, a->a_desc );
if ( !ct ) continue; /* user data? */
for (i=0; a->a_vals[i].bv_val; i++) {
Entry *e = ce->ce_entry;
Attribute *save_attrs = e->e_attrs, *oc_at;
ConfigTable *ct;
- CfOcInfo **colst;
+ ConfigOCs **colst;
int i, nocs;
char *ptr;
delrec *dels = NULL, *deltail = NULL;
ca->be = ce->ce_be;
ca->bi = ce->ce_bi;
ca->private = ce->ce_private;
+ ca->ca_entry = e;
strcpy( ca->log, "back-config" );
for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
return 0;
}
-static Entry *
-config_alloc_entry( CfEntryInfo *parent, struct berval *rdn )
+static void
+config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
+ ConfigTable *ct, ConfigArgs *c )
+{
+ int i, rc;
+
+ for (; at && *at; at++) {
+ /* Skip the naming attr */
+ if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
+ continue;
+ for (i=0;ct[i].name;i++) {
+ if (ct[i].ad == (*at)->sat_ad) {
+ rc = config_get_vals(&ct[i], c);
+ if (rc == LDAP_SUCCESS) {
+ if ( c->rvalue_nvals )
+ attr_merge(e, ct[i].ad, c->rvalue_vals,
+ c->rvalue_nvals);
+ else
+ attr_merge_normalize(e, ct[i].ad,
+ c->rvalue_vals, NULL);
+ ber_bvarray_free( c->rvalue_nvals );
+ ber_bvarray_free( c->rvalue_vals );
+ }
+ break;
+ }
+ }
+ }
+}
+
+Entry *
+config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
+ ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
{
Entry *e = ch_calloc( 1, sizeof(Entry) );
CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
+ struct berval val;
+ struct berval ad_name;
+ AttributeDescription *ad = NULL;
+ int rc;
+ char *ptr;
+ const char *text;
+ Attribute *oc_at;
struct berval pdn;
+ ObjectClass *oc;
+ CfEntryInfo *ceprev = NULL;
e->e_private = ce;
ce->ce_entry = e;
ce->ce_parent = parent;
if ( parent ) {
pdn = parent->ce_entry->e_nname;
+ if ( parent->ce_kids )
+ for ( ceprev = parent->ce_kids; ceprev->ce_sibs;
+ ceprev = ceprev->ce_sibs );
} else {
BER_BVZERO( &pdn );
}
+ ce->ce_type = main->co_type;
+ ce->ce_private = c->private;
+ ce->ce_be = c->be;
+ ce->ce_bi = c->bi;
+
build_new_dn( &e->e_name, &pdn, rdn, NULL );
ber_dupbv( &e->e_nname, &e->e_name );
- return e;
-}
-
-#define NO_TABLE 0
-#define BI_TABLE 1
-#define BE_TABLE 2
-
-static int
-config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
- struct berval *rdn, ConfigTable *ct, int table )
-{
- struct berval val;
- struct berval ad_name;
- AttributeDescription *ad = NULL;
- int rc, i;
- char *ptr;
- const char *text;
- AttributeType **at;
- Attribute *oc_at;
- val = oc->soc_cname;
- attr_merge_normalize_one(e, slap_schema.si_ad_objectClass, &val, NULL );
+ attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
+ main->co_name, NULL );
+ if ( extra )
+ attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
+ extra->co_name, NULL );
ptr = strchr(rdn->bv_val, '=');
ad_name.bv_val = rdn->bv_val;
ad_name.bv_len = ptr - rdn->bv_val;
rc = slap_bv2ad( &ad_name, &ad, &text );
if ( rc ) {
- return rc;
+ return NULL;
}
val.bv_val = ptr+1;
val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
attr_merge_normalize_one(e, ad, &val, NULL );
- for (at=oc->soc_required; at && *at; at++) {
- /* Skip the naming attr */
- if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
- continue;
- for (i=0;ct[i].name;i++) {
- if (ct[i].ad == (*at)->sat_ad) {
- rc = config_get_vals(&ct[i], c);
- if (rc == LDAP_SUCCESS) {
- if ( c->rvalue_nvals )
- attr_merge(e, ct[i].ad, c->rvalue_vals,
- c->rvalue_nvals);
- else
- attr_merge_normalize(e, ct[i].ad,
- c->rvalue_vals, NULL);
- ber_bvarray_free( c->rvalue_nvals );
- ber_bvarray_free( c->rvalue_vals );
- }
- break;
- }
- }
- }
+ oc = *main->co_oc;
+ if ( oc->soc_required )
+ config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
- for (at=oc->soc_allowed; at && *at; at++) {
- /* Skip the naming attr */
- if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
- continue;
- for (i=0;ct[i].name;i++) {
- if (ct[i].ad == (*at)->sat_ad) {
- rc = config_get_vals(&ct[i], c);
- if (rc == LDAP_SUCCESS) {
- if ( c->rvalue_nvals )
- attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
- else
- attr_merge_normalize(e, ct[i].ad, c->rvalue_vals, NULL);
- ber_bvarray_free( c->rvalue_nvals );
- ber_bvarray_free( c->rvalue_vals );
- }
- break;
- }
- }
- }
+ if ( oc->soc_allowed )
+ config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
- if ( table ) {
- if ( table == BI_TABLE )
- ct = c->bi->bi_cf_table;
- else
- ct = c->be->be_cf_table;
- for (;ct && ct->name;ct++) {
- if (!ct->ad) continue;
- rc = config_get_vals(ct, c);
- if (rc == LDAP_SUCCESS) {
- if ( c->rvalue_nvals )
- attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
- else
- attr_merge_normalize(e, ct->ad, c->rvalue_vals, NULL);
- }
- }
+ if ( extra ) {
+ oc = *extra->co_oc;
+ if ( oc->soc_required )
+ config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
+
+ if ( oc->soc_allowed )
+ config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
}
+
oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
rc = structural_class(oc_at->a_vals, &val, NULL, &text, c->msg,
sizeof(c->msg));
attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &val, NULL );
+ if ( op ) {
+ op->ora_e = e;
+ op->o_bd->be_add( op, rs );
+ }
+ if ( ceprev ) {
+ ceprev->ce_sibs = ce;
+ } else if ( parent ) {
+ parent->ce_kids = ce;
+ }
- return 0;
+ return e;
}
static void
{
Entry *e;
ConfigFile *cf = c->private;
- CfEntryInfo *ce, *ceprev;
char *ptr;
struct berval bv;
- if ( ceparent->ce_kids ) {
- for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
- ceprev = ceprev->ce_sibs );
- }
-
for (; cf; cf=cf->c_sibs, c->depth++) {
c->value_dn.bv_val = c->log;
bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
c->value_dn.bv_len += bv.bv_len;
c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
- e = config_alloc_entry( ceparent, &c->value_dn );
c->private = cf;
- config_build_entry( c, e, cfOc_schema, &c->value_dn,
- c->bi->bi_cf_table, NO_TABLE );
- ce = e->e_private;
- ce->ce_private = cf;
- ce->ce_type = Cft_Schema;
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, rs );
- }
- ce->ce_bi = c->bi;
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
- if ( cf->c_kids ) {
+ e = config_build_entry( op, rs, ceparent, c, &c->value_dn,
+ &CFOC_SCHEMA, NULL );
+ if ( e && cf->c_kids ) {
c->private = cf->c_kids;
- config_build_schema_inc( c, ceparent, op, rs );
+ config_build_schema_inc( c, e->e_private, op, rs );
}
}
}
-static CfEntryInfo *
+static void
config_build_includes( ConfigArgs *c, CfEntryInfo *ceparent,
Operation *op, SlapReply *rs )
{
Entry *e;
int i;
ConfigFile *cf = c->private;
- CfEntryInfo *ce, *ceprev;
-
- if ( ceparent->ce_kids ) {
- for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
- ceprev = ceprev->ce_sibs );
- }
for (i=0; cf; cf=cf->c_sibs, i++) {
c->value_dn.bv_val = c->log;
c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include" IFMT, i);
- e = config_alloc_entry( ceparent, &c->value_dn );
c->private = cf;
- config_build_entry( c, e, cfOc_include, &c->value_dn,
- c->bi->bi_cf_table, NO_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, rs );
- }
- ce = e->e_private;
- ce->ce_private = cf;
- ce->ce_type = Cft_Include;
- ce->ce_bi = c->bi;
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
- if ( cf->c_kids ) {
+ e = config_build_entry( op, rs, ceparent, c, &c->value_dn,
+ &CFOC_INCLUDE, NULL );
+ if ( e && cf->c_kids ) {
c->private = cf->c_kids;
- config_build_includes( c, ce, op, rs );
+ config_build_includes( c, e->e_private, op, rs );
}
}
- return ce;
}
#ifdef SLAPD_MODULES
-static CfEntryInfo *
+static void
config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
Operation *op, SlapReply *rs )
{
- Entry *e;
int i;
- CfEntryInfo *ce, *ceprev;
ModPaths *mp;
- if ( ceparent->ce_kids ) {
- for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
- ceprev = ceprev->ce_sibs );
- }
-
for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
continue;
c->value_dn.bv_val = c->log;
c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=module" IFMT, i);
- e = config_alloc_entry( ceparent, &c->value_dn );
- ce = e->e_private;
- ce->ce_type = Cft_Include;
c->private = mp;
- ce->ce_private = mp;
- config_build_entry( c, e, cfOc_module, &c->value_dn,
- c->bi->bi_cf_table, NO_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, rs );
- }
- ce->ce_bi = c->bi;
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
+ config_build_entry( op, rs, ceparent, c, &c->value_dn,
+ &CFOC_MODULE, NULL );
}
- return ce;
}
#endif
/* create root of tree */
rdn = config_rdn;
- e = config_alloc_entry( NULL, &rdn );
+ c.private = cfb->cb_config;
+ e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
ce = e->e_private;
- ce->ce_type = Cft_Global;
cfb->cb_root = ce;
- c.be = be;
- c.bi = be->bd_info;
- c.private = cfb->cb_config;
- ct = c.bi->bi_cf_table;
- ce->ce_private = c.private;
- config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, &rs );
- }
- ce->ce_bi = c.bi;
parent = e;
ceparent = ce;
* files.
*/
rdn = schema_rdn;
- e = config_alloc_entry( ceparent, &rdn );
- ce = e->e_private;
- ce->ce_type = Cft_Schema;
c.private = NULL;
- config_build_entry( &c, e, cfOc_schema, &rdn, ct, NO_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, &rs );
- }
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
+ e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
/* Create includeFile nodes and schema nodes for included schema... */
if ( cfb->cb_config->c_kids ) {
c.private = cfb->cb_config->c_kids;
config_build_schema_inc( &c, ce, op, &rs );
c.private = cfb->cb_config->c_kids;
- ceprev = config_build_includes( &c, ceparent, op, &rs );
+ config_build_includes( &c, ceparent, op, &rs );
}
#ifdef SLAPD_MODULES
/* Create Module nodes... */
if ( modpaths.mp_loads ) {
- ceprev = config_build_modules( &c, ceparent, op, &rs );
+ config_build_modules( &c, ceparent, op, &rs );
}
#endif
c.line = 0;
LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
- if (!bi->bi_cf_table) continue;
+ if (!bi->bi_cf_ocs) continue;
if (!bi->bi_private) continue;
rdn.bv_val = c.log;
rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
- e = config_alloc_entry( ceparent, &rdn );
- ce = e->e_private;
- ce->ce_type = Cft_Backend;
- ce->ce_bi = bi;
c.bi = bi;
- config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, &rs );
- }
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
+ e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
+ bi->bi_cf_ocs );
}
/* Create database nodes... */
rdn.bv_val = c.log;
rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s", cfAd_database->ad_cname.bv_val,
i, bi->bi_type);
- e = config_alloc_entry( ceparent, &rdn );
- ce = e->e_private;
c.be = bptr;
c.bi = bi;
- ce->ce_type = Cft_Database;
- ce->ce_be = c.be;
- ce->ce_bi = c.bi;
- config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
- if ( op ) {
- op->ora_e = e;
- op->o_bd->be_add( op, &rs );
- }
- if ( !ceparent->ce_kids ) {
- ceparent->ce_kids = ce;
- } else {
- ceprev->ce_sibs = ce;
- }
- ceprev = ce;
+ e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
+ be->be_cf_ocs );
+ ce = e->e_private;
/* Iterate through overlays */
if ( oi ) {
slap_overinst *on;
Entry *oe;
- CfEntryInfo *opar = ce, *oprev = NULL;
int j;
for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
rdn.bv_val = c.log;
rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s",
cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
- oe = config_alloc_entry( opar, &rdn );
- ce = oe->e_private;
c.be = bptr;
c.bi = &on->on_bi;
- ce->ce_type = Cft_Overlay;
- ce->ce_be = c.be;
- ce->ce_bi = c.bi;
- config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
- if ( op ) {
- op->ora_e = oe;
- op->o_bd->be_add( op, &rs );
- }
- if ( !opar->ce_kids ) {
- opar->ce_kids = ce;
- } else {
- oprev->ce_sibs = ce;
- }
- oprev = ce;
+ oe = config_build_entry( op, &rs, ce, &c, &rdn,
+ &CFOC_OVERLAY, c.bi->bi_cf_ocs );
}
}
}
parse_oidm( "slapd", i, 3, argv, 0, NULL );
}
- bi->bi_cf_table = ct;
+ bi->bi_cf_ocs = cf_ocs;
i = config_register_schema( ct, cf_ocs );
if ( i ) return i;