]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
Fix q[-1] ref in prev commit
[openldap] / servers / slapd / bconfig.c
index 911472d92af2e525b87821cad60beca48a68de6a..2cd2750bf33fb4451c86801bfce1c0b88531e982 100644 (file)
@@ -344,8 +344,7 @@ static ConfigTable config_back_cf_table[] = {
                &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
        { "include", "file", 2, 2, 0, ARG_MAGIC,
-               &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
-                       "SUP labeledURI )", NULL, NULL },
+               &config_include, NULL, NULL, NULL },
        { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
                &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
                        "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
@@ -646,7 +645,7 @@ static ConfigTable config_back_cf_table[] = {
 };
 
 /* Routines to check if a child can be added to this type */
-static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
+static ConfigLDAPadd cfAddSchema, cfAddDatabase,
        cfAddBackend, cfAddModule, cfAddOverlay;
 
 /* NOTE: be careful when defining array members
@@ -656,10 +655,9 @@ static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
 #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_FRONTEND  cf_ocs[7]
+#define CFOC_FRONTEND  cf_ocs[6]
 #ifdef SLAPD_MODULES
-#define CFOC_MODULE    cf_ocs[8]
+#define CFOC_MODULE    cf_ocs[7]
 #endif /* SLAPD_MODULES */
 
 static ConfigOCs cf_ocs[] = {
@@ -724,13 +722,6 @@ static ConfigOCs cf_ocs[] = {
                "DESC 'OpenLDAP Overlay-specific options' "
                "SUP olcConfig STRUCTURAL "
                "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
-       { "( OLcfgGlOc:6 "
-               "NAME 'olcIncludeFile' "
-               "DESC 'OpenLDAP configuration include file' "
-               "SUP olcConfig STRUCTURAL "
-               "MUST olcInclude "
-               "MAY ( cn $ olcRootDSE ) )",
-               Cft_Include, NULL, cfAddInclude },
        /* This should be STRUCTURAL like all the other database classes, but
         * that would mean inheriting all of the olcDatabaseConfig attributes,
         * which causes them to be merged twice in config_build_entry.
@@ -3019,15 +3010,8 @@ config_include(ConfigArgs *c) {
        ConfigFile *cf;
        ConfigFile *cfsave = cfn;
        ConfigFile *cf2 = NULL;
-       if (c->op == SLAP_CONFIG_EMIT) {
-               if (c->private) {
-                       ConfigFile *cf = c->private;
-                       value_add_one( &c->rvalue_vals, &cf->c_file );
-                       return 0;
-               }
-               return 1;
-       } else if ( c->op == LDAP_MOD_DELETE ) {
-       }
+
+       /* No dynamic config for include files */
        cf = ch_calloc( 1, sizeof(ConfigFile));
        if ( cfn->c_kids ) {
                for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
@@ -3702,7 +3686,7 @@ config_rename_one( Operation *op, SlapReply *rs, Entry *e,
        if ( use_ldif ) {
                CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
                BackendDB *be = op->o_bd;
-               slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
+               slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
                struct berval dn, ndn, xdn, xndn;
 
                op->o_bd = &cfb->cb_db;
@@ -3717,7 +3701,7 @@ config_rename_one( Operation *op, SlapReply *rs, Entry *e,
                op->o_req_dn = odn;
                op->o_req_ndn = ondn;
 
-               sc.sc_next = op->o_callback;
+               scp = op->o_callback;
                op->o_callback = ≻
                op->orr_newrdn = *newrdn;
                op->orr_nnewrdn = *nnewrdn;
@@ -3729,7 +3713,7 @@ config_rename_one( Operation *op, SlapReply *rs, Entry *e,
                slap_mods_free( op->orr_modlist, 1 );
 
                op->o_bd = be;
-               op->o_callback = sc.sc_next;
+               op->o_callback = scp;
                op->o_dn = dn;
                op->o_ndn = ndn;
                op->o_req_dn = xdn;
@@ -3811,7 +3795,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
        if ( ce_type == Cft_Global ) return 0;
        if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
 
-       if ( ce_type == Cft_Include || ce_type == Cft_Module )
+       if ( ce_type == Cft_Module )
                tailindex = 1;
 
        /* See if the rdn has an index already */
@@ -3839,9 +3823,6 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                }
        }
 
-       if ( !isfrontend && index == -1 )
-               index = 0;
-
        /* count related kids */
        for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
                if ( ce->ce_type == ce_type ) nsibs++;
@@ -3856,6 +3837,9 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                                        renumber = 1;
                        }
                }
+               if ( !isfrontend && index == -1 )
+                       index = nsibs;
+
                /* just make index = nsibs */
                if ( !renumber ) {
                        rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
@@ -3895,21 +3879,6 @@ count_ocs( Attribute *oc_at, int *nocs )
        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;
-
-       cfn = p->ce_private;
-       ca->private = cfn;
-       return LDAP_SUCCESS;
-}
-
 static int
 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
 {
@@ -3986,7 +3955,8 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
        ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
        if ( ce ) {
                if (( op && op->o_managedsait ) ||
-                       ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay ))
+                       ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
+                         ce->ce_type != Cft_Module ))
                return LDAP_ALREADY_EXISTS;
        }
 
@@ -4025,6 +3995,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
                ca->fname = cfdir.bv_val;
                ca->lineno = 1;
        }
+       ca->ca_op = op;
 
        colst = count_ocs( oc_at, &nocs );
 
@@ -4314,6 +4285,10 @@ config_back_add( Operation *op, SlapReply *rs )
        {
                char textbuf[SLAP_TEXT_BUFLEN];
                size_t textlen = sizeof textbuf;
+               rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1,
+                       &rs->sr_text, textbuf, sizeof( textbuf ) );
+               if ( rs->sr_err != LDAP_SUCCESS )
+                       goto out;
                rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE,
@@ -4352,7 +4327,7 @@ config_back_add( Operation *op, SlapReply *rs )
 
        if ( cfb->cb_use_ldif ) {
                BackendDB *be = op->o_bd;
-               slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
+               slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
                struct berval dn, ndn;
 
                op->o_bd = &cfb->cb_db;
@@ -4363,11 +4338,11 @@ config_back_add( Operation *op, SlapReply *rs )
                op->o_dn = op->o_bd->be_rootdn;
                op->o_ndn = op->o_bd->be_rootndn;
 
-               sc.sc_next = op->o_callback;
+               scp = op->o_callback;
                op->o_callback = ≻
                op->o_bd->be_add( op, rs );
                op->o_bd = be;
-               op->o_callback = sc.sc_next;
+               op->o_callback = scp;
                op->o_dn = dn;
                op->o_ndn = ndn;
        }
@@ -4377,6 +4352,7 @@ out2:;
 
 out:;
        send_ldap_result( op, rs );
+       slap_graduate_commit_csn( op );
        return rs->sr_err;
 }
 
@@ -4413,6 +4389,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
        ca->private = ce->ce_private;
        ca->ca_entry = e;
        ca->fname = "slapd";
+       ca->ca_op = op;
        strcpy( ca->log, "back-config" );
 
        for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
@@ -4707,7 +4684,7 @@ config_back_modify( Operation *op, SlapReply *rs )
                rs->sr_text = ca.msg;
        } else if ( cfb->cb_use_ldif ) {
                BackendDB *be = op->o_bd;
-               slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
+               slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
                struct berval dn, ndn;
 
                op->o_bd = &cfb->cb_db;
@@ -4717,11 +4694,11 @@ config_back_modify( Operation *op, SlapReply *rs )
                op->o_dn = op->o_bd->be_rootdn;
                op->o_ndn = op->o_bd->be_rootndn;
 
-               sc.sc_next = op->o_callback;
+               scp = op->o_callback;
                op->o_callback = ≻
                op->o_bd->be_modify( op, rs );
                op->o_bd = be;
-               op->o_callback = sc.sc_next;
+               op->o_callback = scp;
                op->o_dn = dn;
                op->o_ndn = ndn;
        }
@@ -4730,6 +4707,7 @@ config_back_modify( Operation *op, SlapReply *rs )
                ldap_pvt_thread_pool_resume( &connection_pool );
 out:
        send_ldap_result( op, rs );
+       slap_graduate_commit_csn( op );
        return rs->sr_err;
 }
 
@@ -5090,6 +5068,7 @@ config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
        attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
        if ( op && !op->o_noop ) {
                op->ora_e = e;
+               op->ora_modlist = NULL;
                op->o_bd->be_add( op, rs );
                if ( ( rs->sr_err != LDAP_SUCCESS ) 
                                && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
@@ -5151,34 +5130,6 @@ config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
        return 0;
 }
 
-static int
-config_build_includes( ConfigArgs *c, CfEntryInfo *ceparent,
-       Operation *op, SlapReply *rs )
-{
-       Entry *e;
-       int i;
-       ConfigFile *cf = c->private;
-
-       for (i=0; cf; cf=cf->c_sibs, i++) {
-               c->value_dn.bv_val = c->log;
-               c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=include" SLAP_X_ORDERED_FMT, i);
-               if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
-                       /* FIXME: how can indicate error? */
-                       return -1;
-               }
-               c->private = cf;
-               e = config_build_entry( op, rs, ceparent, c, &c->value_dn,
-                       &CFOC_INCLUDE, NULL );
-               if ( ! e ) {
-                       return -1;
-               } else if ( e && cf->c_kids ) {
-                       c->private = cf->c_kids;
-                       config_build_includes( c, e->e_private, op, rs );
-               }
-       }
-       return 0;
-}
-
 #ifdef SLAPD_MODULES
 
 static int
@@ -5349,15 +5300,6 @@ config_back_db_open( BackendDB *be )
        parent = e;
        ceparent = ce;
 
-       /* Create includeFile nodes */
-       if ( cfb->cb_config->c_kids ) {
-               c.depth = 0;
-               c.private = cfb->cb_config->c_kids;
-               if ( config_build_includes( &c, ceparent, op, &rs ) ) {
-                       return -1;
-               }
-       }
-
 #ifdef SLAPD_MODULES
        /* Create Module nodes... */
        if ( modpaths.mp_loads ) {