]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
Listener commit broke test048, skip listener check on Hidden DBs
[openldap] / servers / slapd / bconfig.c
index a08e10e954fdeddf0dd3d8ff1e9df549b4f3bd5a..408f513f0c300faf717b8ab2875d2436fe070251 100644 (file)
@@ -2959,9 +2959,6 @@ config_shadow( ConfigArgs *c, int flag )
 
        } else if ( SLAP_MONITOR(c->be) ) {
                notallowed = "monitor";
-
-       } else if ( SLAP_CONFIG(c->be) ) {
-               notallowed = "config";
        }
 
        if ( notallowed != NULL ) {
@@ -2996,7 +2993,7 @@ config_updateref(ConfigArgs *c) {
                }
                return 0;
        }
-       if(!SLAP_SHADOW(c->be)) {
+       if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
                snprintf( c->msg, sizeof( c->msg ), "<%s> must appear after syncrepl or updatedn",
                        c->argv[0] );
                Debug(LDAP_DEBUG_ANY, "%s: %s\n",
@@ -3705,7 +3702,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;
@@ -3720,18 +3717,19 @@ 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 = &sc;
                op->orr_newrdn = *newrdn;
                op->orr_nnewrdn = *nnewrdn;
                op->orr_deleteoldrdn = 1;
                op->orr_modlist = NULL;
                slap_modrdn2mods( op, rs );
+               slap_mods_opattrs( op, &op->orr_modlist, 1 );
                rc = op->o_bd->be_modrdn( op, rs );
                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;
@@ -3803,7 +3801,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
 {
        CfEntryInfo *ce;
        int index = -1, gotindex = 0, nsibs, rc = 0;
-       int renumber = 0, tailindex = 0;
+       int renumber = 0, tailindex = 0, isfrontend = 0;
        char *ptr1, *ptr2 = NULL;
        struct berval rdn;
 
@@ -3818,6 +3816,9 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
 
        /* See if the rdn has an index already */
        dnRdn( &e->e_name, &rdn );
+       if ( ce_type == Cft_Database && !strncmp( rdn.bv_val + rdn.bv_len -
+               STRLENOF("frontend"), "frontend", STRLENOF("frontend") ))
+               isfrontend = 1;
        ptr1 = ber_bvchr( &e->e_name, '{' );
        if ( ptr1 && ptr1 - e->e_name.bv_val < rdn.bv_len ) {
                char    *next;
@@ -3833,9 +3834,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                }
                if ( index < 0 ) {
                        /* Special case, we allow -1 for the frontendDB */
-                       if ( index != -1 || ce_type != Cft_Database ||
-                               strncmp( ptr2+1, "frontend,", STRLENOF("frontend,") ))
-
+                       if ( index != -1 || !isfrontend )
                                return LDAP_NAMING_VIOLATION;
                }
        }
@@ -3850,9 +3849,13 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                        if ( index < nsibs ) {
                                if ( tailindex ) return LDAP_NAMING_VIOLATION;
                                /* Siblings need to be renumbered */
-                               renumber = 1;
+                               if ( index != -1 || !isfrontend )
+                                       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 );
@@ -3977,12 +3980,16 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
        char *ptr;
 
        /* Make sure parent exists and entry does not. But allow
-        * Databases and Overlays to be inserted.
+        * Databases and Overlays to be inserted. Don't do any
+        * auto-renumbering if manageDSAit control is present.
         */
        ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
-       if ( ce && ce->ce_type != Cft_Database &&
-               ce->ce_type != Cft_Overlay )
+       if ( ce ) {
+               if (( op && op->o_managedsait ) ||
+                       ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
+                         ce->ce_type != Cft_Module ))
                return LDAP_ALREADY_EXISTS;
+       }
 
        dnParent( &e->e_nname, &pdn );
 
@@ -4170,7 +4177,7 @@ ok:
 
                /* Advance to first of this type */
                cprev = &last->ce_kids;
-               for ( c2 = *cprev; c2 && c2->ce_type != ce->ce_type; ) {
+               for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
                        cprev = &c2->ce_sibs;
                        c2 = c2->ce_sibs;
                }
@@ -4304,6 +4311,23 @@ config_back_add( Operation *op, SlapReply *rs )
 
        cfb = (CfBackInfo *)op->o_bd->be_private;
 
+       /* add opattrs for syncprov */
+       {
+               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,
+                               LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
+                               "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
+                       goto out;
+               }
+       }
+
        ldap_pvt_thread_pool_pause( &connection_pool );
 
        /* Strategy:
@@ -4333,7 +4357,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;
@@ -4344,11 +4368,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 = &sc;
                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;
        }
@@ -4358,6 +4382,7 @@ out2:;
 
 out:;
        send_ldap_result( op, rs );
+       slap_graduate_commit_csn( op );
        return rs->sr_err;
 }
 
@@ -4672,7 +4697,10 @@ config_back_modify( Operation *op, SlapReply *rs )
                }
        }
 
-       ldap_pvt_thread_pool_pause( &connection_pool );
+       slap_mods_opattrs( op, &op->orm_modlist, 1 );
+
+       if ( !slapd_shutdown )
+               ldap_pvt_thread_pool_pause( &connection_pool );
 
        /* Strategy:
         * 1) perform the Modify on the cached Entry.
@@ -4685,7 +4713,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;
@@ -4695,18 +4723,20 @@ 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 = &sc;
                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;
        }
 
-       ldap_pvt_thread_pool_resume( &connection_pool );
+       if ( !slapd_shutdown )
+               ldap_pvt_thread_pool_resume( &connection_pool );
 out:
        send_ldap_result( op, rs );
+       slap_graduate_commit_csn( op );
        return rs->sr_err;
 }
 
@@ -4907,6 +4937,13 @@ out:
        return rs->sr_err;
 }
 
+static int
+config_back_delete( Operation *op, SlapReply *rs )
+{
+       send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, NULL );
+       return rs->sr_err;
+}
+
 static int
 config_back_search( Operation *op, SlapReply *rs )
 {
@@ -5003,17 +5040,18 @@ config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
        Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
        e->e_private = ce;
        ce->ce_entry = e;
+       ce->ce_type = main->co_type;
        ce->ce_parent = parent;
        if ( parent ) {
                pdn = parent->ce_entry->e_nname;
-               if ( parent->ce_kids )
-                       for ( ceprev = parent->ce_kids; ceprev->ce_sibs;
+               if ( parent->ce_kids && parent->ce_kids->ce_type < ce->ce_type )
+                       for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
+                               ceprev->ce_type < ce->ce_type;
                                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;
@@ -5066,8 +5104,10 @@ config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
                }
        }
        if ( ceprev ) {
+               ce->ce_sibs = ceprev->ce_sibs;
                ceprev->ce_sibs = ce;
        } else if ( parent ) {
+               ce->ce_sibs = parent->ce_kids;
                parent->ce_kids = ce;
        }
 
@@ -5724,7 +5764,7 @@ config_back_initialize( BackendInfo *bi )
        bi->bi_op_modify = config_back_modify;
        bi->bi_op_modrdn = config_back_modrdn;
        bi->bi_op_add = config_back_add;
-       bi->bi_op_delete = 0;
+       bi->bi_op_delete = config_back_delete;
        bi->bi_op_abandon = 0;
 
        bi->bi_extended = 0;