]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/chain.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / servers / slapd / back-ldap / chain.c
index 6d06ffef57c269b11944f70a55ffd1d886964653..33239e2ab4215c28261e3d8d579b01e4f6c2779d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2011 The OpenLDAP Foundation.
+ * Copyright 2003-2013 The OpenLDAP Foundation.
  * Portions Copyright 2003 Howard Chu.
  * All rights reserved.
  *
@@ -1270,7 +1270,7 @@ static ConfigOCs chainocs[] = {
        { "( OLcfgOvOc:3.2 "
                "NAME 'olcChainDatabase' "
                "DESC 'Chain remote server configuration' "
-               "SUP olcLDAPConfig )",
+               "AUXILIARY )",
                Cft_Misc, olcDatabaseDummy, chain_ldadd
 #ifdef SLAP_CONFIG_DELETE
                , NULL, chain_lddel
@@ -1448,10 +1448,18 @@ chain_lddel( CfEntryInfo *ce, Operation *op )
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
        ldapinfo_t      *li = (ldapinfo_t *) ce->ce_be->be_private;
 
-       if (! avl_delete( &lc->lc_lai.lai_tree, li, ldap_chain_uri_cmp ) ) {
-               Debug( LDAP_DEBUG_ANY, "slapd-chain: avl_delete failed. "
-                       "\"%s\" not found.\n", li->li_uri, 0, 0 );
+       if ( li != lc->lc_common_li ) {
+               if (! avl_delete( &lc->lc_lai.lai_tree, li, ldap_chain_uri_cmp ) ) {
+                       Debug( LDAP_DEBUG_ANY, "slapd-chain: avl_delete failed. "
+                               "\"%s\" not found.\n", li->li_uri, 0, 0 );
+                       return -1;
+               }
+       } else if ( lc->lc_lai.lai_tree ) {
+               Debug( LDAP_DEBUG_ANY, "slapd-chain: cannot delete first underlying "
+                       "LDAP database when other databases are still present.\n", 0, 0, 0 );
                return -1;
+       } else {
+               lc->lc_common_li = NULL;
        }
 
        ce->ce_be->bd_info = lback;
@@ -1971,6 +1979,11 @@ ldap_chain_db_close(
        BackendDB       *be,
        ConfigReply     *cr )
 {
+#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
+#ifdef SLAP_CONFIG_DELETE
+       overlay_unregister_control( be, LDAP_CONTROL_X_CHAINING_BEHAVIOR );
+#endif /* SLAP_CONFIG_DELETE */
+#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
        return ldap_chain_db_func( be, db_close );
 }
 
@@ -2073,18 +2086,28 @@ ldap_chain_db_open_one(
 
                if ( li->li_uri == NULL ) {
                        ber_str2bv( "cn=Common Connections", 0, 1,
-                               &li->li_monitor_info.lmi_rdn );
+                               &li->li_monitor_info.lmi_conn_rdn );
+                       ber_str2bv( "cn=Operations on Common Connections", 0, 1,
+                               &li->li_monitor_info.lmi_conn_rdn );
 
                } else {
                        char            *ptr;
 
-                       li->li_monitor_info.lmi_rdn.bv_len
+                       li->li_monitor_info.lmi_conn_rdn.bv_len
                                = STRLENOF( "cn=" ) + strlen( li->li_uri );
-                       ptr = li->li_monitor_info.lmi_rdn.bv_val
-                               = ch_malloc( li->li_monitor_info.lmi_rdn.bv_len + 1 );
+                       ptr = li->li_monitor_info.lmi_conn_rdn.bv_val
+                               = ch_malloc( li->li_monitor_info.lmi_conn_rdn.bv_len + 1 );
                        ptr = lutil_strcopy( ptr, "cn=" );
                        ptr = lutil_strcopy( ptr, li->li_uri );
                        ptr[ 0 ] = '\0';
+
+                       li->li_monitor_info.lmi_ops_rdn.bv_len
+                               = STRLENOF( "cn=Operations on " ) + strlen( li->li_uri );
+                       ptr = li->li_monitor_info.lmi_ops_rdn.bv_val
+                               = ch_malloc( li->li_monitor_info.lmi_ops_rdn.bv_len + 1 );
+                       ptr = lutil_strcopy( ptr, "cn=Operations on " );
+                       ptr = lutil_strcopy( ptr, li->li_uri );
+                       ptr[ 0 ] = '\0';
                }
        }