]> git.sur5r.net Git - openldap/commitdiff
ITS#4848 better config context tracking
authorHoward Chu <hyc@openldap.org>
Sat, 24 Feb 2007 17:24:48 +0000 (17:24 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 24 Feb 2007 17:24:48 +0000 (17:24 +0000)
servers/slapd/backover.c
servers/slapd/bconfig.c
servers/slapd/config.c
servers/slapd/config.h

index eccc395fedbca24b2bfd12a6a09b8e8dba2e52f8..c9324f33100d521b0c7be522628a22f15e4c1dac 100644 (file)
@@ -147,6 +147,7 @@ over_db_config(
                        ca.bi = &on->on_bi;
                        ct = config_find_keyword( on->on_bi.bi_cf_ocs->co_table, &ca );
                        if ( ct ) {
+                               ca.table = on->on_bi.bi_cf_ocs->co_type;
                                rc = config_add_vals( ct, &ca );
                                if ( rc != SLAP_CONF_UNKNOWN )
                                        break;
index baa42e446c57c2e55e07e7b6744432815ab185fb..6385306f1aa5e5338320a2c0d1de7f9e0b216e2c 100644 (file)
@@ -3431,6 +3431,7 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
        argv[1] = (char *)dir;
        argv[2] = NULL;
        c.argv = argv;
+       c.table = Cft_Database;
 
        ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
        if ( !ct )
@@ -3667,14 +3668,17 @@ config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
 }
 
 static ConfigTable *
-config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad )
+config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
+       ConfigArgs *ca )
 {
        int i, j;
 
        for (j=0; j<nocs; j++) {
                for (i=0; colst[j]->co_table[i].name; i++)
-                       if ( colst[j]->co_table[i].ad == ad )
+                       if ( colst[j]->co_table[i].ad == ad ) {
+                               ca->table = colst[j]->co_type;
                                return &colst[j]->co_table[i];
+                       }
        }
        return NULL;
 }
@@ -4123,28 +4127,28 @@ schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
                struct berval bv = BER_BVC("olcDitContentRules");
                ad = NULL;
                slap_bv2ad( &bv, &ad, &text );
-               ct = config_find_table( colst, nocs, ad );
+               ct = config_find_table( colst, nocs, ad, ca );
                config_del_vals( ct, ca );
        }
        if ( cfn->c_oc_head ) {
                struct berval bv = BER_BVC("olcObjectClasses");
                ad = NULL;
                slap_bv2ad( &bv, &ad, &text );
-               ct = config_find_table( colst, nocs, ad );
+               ct = config_find_table( colst, nocs, ad, ca );
                config_del_vals( ct, ca );
        }
        if ( cfn->c_at_head ) {
                struct berval bv = BER_BVC("olcAttributeTypes");
                ad = NULL;
                slap_bv2ad( &bv, &ad, &text );
-               ct = config_find_table( colst, nocs, ad );
+               ct = config_find_table( colst, nocs, ad, ca );
                config_del_vals( ct, ca );
        }
        if ( cfn->c_om_head ) {
                struct berval bv = BER_BVC("olcObjectIdentifier");
                ad = NULL;
                slap_bv2ad( &bv, &ad, &text );
-               ct = config_find_table( colst, nocs, ad );
+               ct = config_find_table( colst, nocs, ad, ca );
                config_del_vals( ct, ca );
        }
        cfo = p->ce_private;
@@ -4287,7 +4291,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
 
        for ( a=e->e_attrs; a; a=a->a_next ) {
                if ( a == oc_at ) continue;
-               ct = config_find_table( colst, nocs, a->a_desc );
+               ct = config_find_table( colst, nocs, a->a_desc, ca );
                if ( !ct ) continue;    /* user data? */
                rc = check_vals( ct, ca, a, 1 );
                if ( rc ) goto done_noop;
@@ -4296,7 +4300,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
        /* Basic syntax checks are OK. Do the actual settings. */
        for ( a=e->e_attrs; a; a=a->a_next ) {
                if ( a == oc_at ) continue;
-               ct = config_find_table( colst, nocs, a->a_desc );
+               ct = config_find_table( colst, nocs, a->a_desc, ca );
                if ( !ct ) continue;    /* user data? */
                for (i=0; a->a_vals[i].bv_val; i++) {
                        char *iptr = NULL;
@@ -4645,7 +4649,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
        strcpy( ca->log, "back-config" );
 
        for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
-               ct = config_find_table( colst, nocs, ml->sml_desc );
+               ct = config_find_table( colst, nocs, ml->sml_desc, ca );
                switch (ml->sml_op) {
                case LDAP_MOD_DELETE:
                case LDAP_MOD_REPLACE: {
@@ -4758,7 +4762,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
        }
        /* Basic syntax checks are OK. Do the actual settings. */
        for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
-               ct = config_find_table( colst, nocs, ml->sml_desc );
+               ct = config_find_table( colst, nocs, ml->sml_desc, ca );
                if ( !ct ) continue;
 
                s = attr_find( save_attrs, ml->sml_desc );
@@ -4850,7 +4854,7 @@ out:
                for ( s = save_attrs; s; s = s->a_next ) {
                        if ( s->a_flags & SLAP_ATTR_IXDEL ) {
                                s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
-                               ct = config_find_table( colst, nocs, s->a_desc );
+                               ct = config_find_table( colst, nocs, s->a_desc, ca );
                                a = attr_find( e->e_attrs, s->a_desc );
                                if ( a ) {
                                        /* clear the flag so the add check below will skip it */
@@ -4868,7 +4872,7 @@ out:
                }
                for ( a = e->e_attrs; a; a = a->a_next ) {
                        if ( a->a_flags & SLAP_ATTR_IXADD ) {
-                               ct = config_find_table( colst, nocs, a->a_desc );
+                               ct = config_find_table( colst, nocs, a->a_desc, ca );
                                ca->valx = -1;
                                ca->line = NULL;
                                config_del_vals( ct, ca );
index 54dcf2d571eb86deeb9a8709c9d3cb26dff9ebde..e5ea23bbb5dd7e1eccb638ba8b7a518dbfec568c 100644 (file)
@@ -318,8 +318,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
                return(0);
        }
        if(arg_type & ARG_OFFSET) {
-               if (c->be && (!overlay_is_over(c->be) || 
-                       ((slap_overinfo *)c->be->bd_info)->oi_orig == c->bi))
+               if (c->be && c->table == Cft_Database)
                        ptr = c->be->be_private;
                else if (c->bi)
                        ptr = c->bi->bi_private;
@@ -410,8 +409,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
                if ( rc ) return rc;
        } else {
                if ( cf->arg_type & ARG_OFFSET ) {
-                       if (c->be && (!overlay_is_over(c->be) || 
-                               ((slap_overinfo *)c->be->bd_info)->oi_orig == c->bi))
+                       if (c->be && c->table == Cft_Database)
                                ptr = c->be->be_private;
                        else if ( c->bi )
                                ptr = c->bi->bi_private;
@@ -728,6 +726,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
 
                ct = config_find_keyword( cft, c );
                if ( ct ) {
+                       c->table = Cft_Global;
                        rc = config_add_vals( ct, c );
                        if ( !rc ) continue;
 
@@ -748,6 +747,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                        if ( c->bi->bi_cf_ocs ) {
                                ct = config_find_keyword( c->bi->bi_cf_ocs->co_table, c );
                                if ( ct ) {
+                                       c->table = c->bi->bi_cf_ocs->co_type;
                                        rc = config_add_vals( ct, c );
                                }
                        }
@@ -772,6 +772,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                        if ( c->be->be_cf_ocs ) {
                                ct = config_find_keyword( c->be->be_cf_ocs->co_table, c );
                                if ( ct ) {
+                                       c->table = c->be->be_cf_ocs->co_type;
                                        rc = config_add_vals( ct, c );
                                }
                        }
@@ -1914,7 +1915,9 @@ int config_generic_wrapper( Backend *be, const char *fname, int lineno,
 
        rc = SLAP_CONF_UNKNOWN;
        ct = config_find_keyword( be->be_cf_ocs->co_table, &c );
-       if ( ct )
+       if ( ct ) {
+               c.table = be->be_cf_ocs->co_type;
                rc = config_add_vals( ct, &c );
+       }
        return rc;
 }
index eac44942e9ecb44175b9a36f80547ecfb5184168..1115d5884d137bb5d9b666faa9330b7933aa7ca3 100644 (file)
@@ -142,6 +142,7 @@ typedef struct config_args_s {
        Entry *ca_entry;        /* entry being modified */
        void *private;  /* anything */
        ConfigDriver *cleanup;
+       ConfigType table;       /* which config table did we come from */
 } ConfigArgs;
 
 /* If lineno is zero, we have an actual LDAP Add request from a client.