]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
syncinfo_free must be able to free multiple syncinfos
[openldap] / servers / slapd / bconfig.c
index a12e9ee457b6a68ddf4a91a8b1ed3dee9aec00af..c01ec584a51ef30757316ade1c5a0b337d663cc4 100644 (file)
@@ -3871,6 +3871,8 @@ config_rename_one( Operation *op, SlapReply *rs, Entry *e,
                op->o_callback = ≻
                op->orr_newrdn = *newrdn;
                op->orr_nnewrdn = *nnewrdn;
+               op->orr_newSup = NULL;
+               op->orr_nnewSup = NULL;
                op->orr_deleteoldrdn = 1;
                op->orr_modlist = NULL;
                slap_modrdn2mods( op, rs );
@@ -3994,6 +3996,10 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                if ( ce->ce_type == ce_type ) nsibs++;
        }
 
+       /* account for -1 frontend */
+       if ( ce_type == Cft_Database )
+               nsibs--;
+
        if ( index != nsibs ) {
                if ( gotindex ) {
                        if ( index < nsibs ) {
@@ -4003,8 +4009,9 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                                        renumber = 1;
                        }
                }
-               if ( !isfrontend && index == -1 )
+               if ( !isfrontend && index == -1 ) {
                        index = nsibs;
+               }
 
                /* just make index = nsibs */
                if ( !renumber ) {
@@ -4101,6 +4108,50 @@ cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
        return LDAP_SUCCESS;
 }
 
+static void
+schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
+       CfEntryInfo *p )
+{
+       ConfigTable *ct;
+       ConfigFile *cfo;
+       AttributeDescription *ad;
+       const char *text;
+
+       ca->valx = -1;
+       ca->line = NULL;
+       if ( cfn->c_cr_head ) {
+               struct berval bv = BER_BVC("olcDitContentRules");
+               ad = NULL;
+               slap_bv2ad( &bv, &ad, &text );
+               ct = config_find_table( colst, nocs, ad );
+               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 );
+               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 );
+               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 );
+               config_del_vals( ct, ca );
+       }
+       cfo = p->ce_private;
+       cfo->c_kids = cfn->c_sibs;
+       ch_free( cfn );
+}
+
 /* Parse an LDAP entry into config directives */
 static int
 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
@@ -4196,7 +4247,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
        }
 
        if ( rc != LDAP_SUCCESS )
-               goto done;
+               goto done_noop;
 
        /* Parse all the values and check for simple syntax errors before
         * performing any set actions.
@@ -4218,14 +4269,14 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
                rc = check_name_index( last, colst[0]->co_type, e, rs, renum,
                        &ibase );
                if ( rc ) {
-                       goto done;
+                       goto done_noop;
                }
                if ( renum && *renum && colst[0]->co_type != Cft_Database &&
                        colst[0]->co_type != Cft_Overlay ) {
                        snprintf( ca->msg, sizeof( ca->msg ),
                                "operation requires sibling renumbering" );
                        rc = LDAP_UNWILLING_TO_PERFORM;
-                       goto done;
+                       goto done_noop;
                }
        }
 
@@ -4239,7 +4290,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
                ct = config_find_table( colst, nocs, a->a_desc );
                if ( !ct ) continue;    /* user data? */
                rc = check_vals( ct, ca, a, 1 );
-               if ( rc ) goto done;
+               if ( rc ) goto done_noop;
        }
 
        /* Basic syntax checks are OK. Do the actual settings. */
@@ -4351,8 +4402,11 @@ done:
                                backend_destroy_one( ca->be, 1 );
                } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
                        overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
+               } else if ( colst[0]->co_type == Cft_Schema ) {
+                       schema_destroy_one( ca, colst, nocs, last );
                }
        }
+done_noop:
 
        ch_free( ca->argv );
        if ( colst ) ch_free( colst );
@@ -4749,7 +4803,8 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
                                        ca->valx = d->idx[i];
                                        rc = config_del_vals( ct, ca );
                                        if ( rc != LDAP_SUCCESS ) break;
-                                       s->a_flags |= SLAP_ATTR_IXDEL;
+                                       if ( s )
+                                               s->a_flags |= SLAP_ATTR_IXDEL;
                                        for (j=i+1; j < d->nidx; j++)
                                                if ( d->idx[j] >d->idx[i] )
                                                        d->idx[j]--;
@@ -4759,7 +4814,8 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
                                ca->line = NULL;
                                rc = config_del_vals( ct, ca );
                                if ( rc ) rc = LDAP_OTHER;
-                               s->a_flags |= SLAP_ATTR_IXDEL;
+                               if ( s )
+                                       s->a_flags |= SLAP_ATTR_IXDEL;
                        }
                        if ( ml->sml_values ) {
                                d = d->next;
@@ -5273,9 +5329,9 @@ config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
        ce->ce_parent = parent;
        if ( parent ) {
                pdn = parent->ce_entry->e_nname;
-               if ( parent->ce_kids && parent->ce_kids->ce_type < ce->ce_type )
+               if ( parent->ce_kids )
                        for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
-                               ceprev->ce_type < ce->ce_type;
+                               ceprev->ce_type <= ce->ce_type;
                                ceprev = ceprev->ce_sibs );
        } else {
                BER_BVZERO( &pdn );