]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bconfig.c
fix typo
[openldap] / servers / slapd / bconfig.c
index de01d5b3c82a59db36e5fedf112d3cfc00739ab8..60dd39362dccd71156d3950dd7a0d7b8463afa0a 100644 (file)
@@ -254,6 +254,7 @@ static OidRec OidMacros[] = {
  * OLcfgOv{Oc|At}:17                   -> dyngroup
  * OLcfgOv{Oc|At}:18                   -> memberof
  * OLcfgOv{Oc|At}:19                   -> collect
+ * OLcfgOv{Oc|At}:20                   -> retcode
  */
 
 /* alphabetical ordering */
@@ -3881,7 +3882,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                if ( isconfig && index == -1 ) {
                        index = 0;
                }
-               if ( !isfrontend && index == -1 ) {
+               if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
                        index = nsibs;
                }
 
@@ -3992,6 +3993,11 @@ cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
        if ( p->ce_type != Cft_Global ) {
                return LDAP_CONSTRAINT_VIOLATION;
        }
+       /* config must be {0}, nothing else allowed */
+       if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
+               strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
+               return LDAP_CONSTRAINT_VIOLATION;
+       }
        ca->be = frontendDB;    /* just to get past check_vals */
        return LDAP_SUCCESS;
 }
@@ -5231,8 +5237,6 @@ config_back_delete( Operation *op, SlapReply *rs )
        CfBackInfo *cfb;
        CfEntryInfo *ce, *last, *ce2;
 
-       slap_mask_t mask;
-
        cfb = (CfBackInfo *)op->o_bd->be_private;
 
        ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
@@ -5240,15 +5244,28 @@ config_back_delete( Operation *op, SlapReply *rs )
                if ( last )
                        rs->sr_matched = last->ce_entry->e_name.bv_val;
                rs->sr_err = LDAP_NO_SUCH_OBJECT;
-       } if ( ce->ce_kids ) {
+       } else if ( ce->ce_kids ) {
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
-       } else if ( ce->ce_type == Cft_Overlay ){
+       } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
                char *iptr;
-               int count, ixold, rc;
+               int count, ixold;
 
                ldap_pvt_thread_pool_pause( &connection_pool );
-               
-               overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
+
+               if ( ce->ce_type == Cft_Overlay ){
+                       overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
+               } else { /* Cft_Database*/
+                       if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
+                               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                               rs->sr_text = "Cannot delete config or frontend database";
+                               ldap_pvt_thread_pool_resume( &connection_pool );
+                               goto out;
+                       } 
+                       if ( ce->ce_be->bd_info->bi_db_close ) {
+                               ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
+                       }
+                       backend_destroy_one( ce->ce_be, 1);
+               }
 
                /* remove CfEntryInfo from the siblings list */
                if ( ce->ce_parent->ce_kids == ce ) {
@@ -5310,6 +5327,7 @@ config_back_delete( Operation *op, SlapReply *rs )
 #else
        rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
 #endif /* SLAP_CONFIG_DELETE */
+out:
        send_ldap_result( op, rs );
        return rs->sr_err;
 }