X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldap%2Fchain.c;h=8f37efb236c30ac0f6a80f2ba4f0756f5855fef0;hb=473e2c997f6b1f226d35da186db8033c922001f3;hp=2b98668d3f8eb2e433467a1c141cae2876c222cd;hpb=0ef6a3cc51a0cbdc870c7ff4390863177b935597;p=openldap diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index 2b98668d3f..8f37efb236 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -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 @@ -1267,8 +1270,12 @@ static ConfigOCs chainocs[] = { { "( OLcfgOvOc:3.2 " "NAME 'olcChainDatabase' " "DESC 'Chain remote server configuration' " - "SUP olcLDAPConfig )", - Cft_Misc, olcDatabaseDummy, chain_ldadd }, + "AUXILIARY )", + Cft_Misc, olcDatabaseDummy, chain_ldadd +#ifdef SLAP_CONFIG_DELETE + , NULL, chain_lddel +#endif + }, { NULL, 0, NULL } }; @@ -1432,6 +1439,45 @@ 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 ( 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; + + 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 },