]> git.sur5r.net Git - openldap/commitdiff
Allow deletion of chain overlay's back-ldap databases
authorRalf Haferkamp <ralf@openldap.org>
Tue, 22 Mar 2011 15:37:11 +0000 (15:37 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Tue, 22 Mar 2011 15:37:11 +0000 (15:37 +0000)
servers/slapd/back-ldap/chain.c

index 2b98668d3f8eb2e433467a1c141cae2876c222cd..e23aea022f4c1193dd3a7928412217dde145eba1 100644 (file)
@@ -1221,6 +1221,9 @@ enum {
 static ConfigDriver chain_cf_gen;
 static ConfigCfAdd chain_cfadd;
 static ConfigLDAPadd chain_ldadd;
+#ifdef SLAP_CONFIG_DELETE
+static ConfigLDAPdel chain_lddel;
+#endif
 
 static ConfigTable chaincfg[] = {
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
@@ -1268,7 +1271,11 @@ static ConfigOCs chainocs[] = {
                "NAME 'olcChainDatabase' "
                "DESC 'Chain remote server configuration' "
                "SUP olcLDAPConfig )",
-               Cft_Misc, olcDatabaseDummy, chain_ldadd },
+               Cft_Misc, olcDatabaseDummy, chain_ldadd
+#ifdef SLAP_CONFIG_DELETE
+               , NULL, chain_lddel
+#endif
+       },
        { NULL, 0, NULL }
 };
 
@@ -1432,6 +1439,37 @@ chain_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *ca )
        return 0;
 }
 
+#ifdef SLAP_CONFIG_DELETE
+static int
+chain_lddel( CfEntryInfo *ce, Operation *op )
+{
+       CfEntryInfo     *pe = ce->ce_parent;
+       slap_overinst   *on = (slap_overinst *)pe->ce_bi;
+       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 );
+               return -1;
+       }
+
+       ce->ce_be->bd_info = lback;
+
+       if ( ce->ce_be->bd_info->bi_db_close ) {
+               ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
+       }
+       if ( ce->ce_be->bd_info->bi_db_destroy ) {
+               ce->ce_be->bd_info->bi_db_destroy( ce->ce_be, NULL );
+       }
+
+       ch_free(ce->ce_be);
+       ce->ce_be = NULL;
+
+       return LDAP_SUCCESS;
+}
+#endif /* SLAP_CONFIG_DELETE */
+
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
 static slap_verbmasks chaining_mode[] = {
        { BER_BVC("referralsRequired"),         LDAP_REFERRALS_REQUIRED },