assert( !BER_BVISNULL( &li2->li_bvuri[ 0 ] ) );
assert( BER_BVISNULL( &li2->li_bvuri[ 1 ] ) );
- /* If local DNs don't match, it is definitely not a match */
return ber_bvcmp( &li1->li_bvuri[ 0 ], &li2->li_bvuri[ 0 ] );
}
assert( !BER_BVISNULL( &li2->li_bvuri[ 0 ] ) );
assert( BER_BVISNULL( &li2->li_bvuri[ 1 ] ) );
- /* Cannot have more than one shared session with same DN */
if ( ber_bvcmp( &li1->li_bvuri[ 0 ], &li2->li_bvuri[ 0 ] ) == 0 ) {
return -1;
}
-
+
return 0;
}
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
"NAME 'olcChainDatabase' "
"DESC 'Chain remote server configuration' "
"AUXILIARY )",
- Cft_Misc, olcDatabaseDummy, chain_ldadd },
+ Cft_Misc, olcDatabaseDummy, chain_ldadd
+#ifdef SLAP_CONFIG_DELETE
+ , NULL, chain_lddel
+#endif
+ },
{ NULL, 0, NULL }
};
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 },
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
int rc = SLAP_CONF_UNKNOWN;
-
+
if ( lc->lc_common_li == NULL ) {
- void *be_private = be->be_private;
- ldap_chain_db_init_common( be );
- lc->lc_common_li = lc->lc_cfg_li = (ldapinfo_t *)be->be_private;
- be->be_private = be_private;
+ BackendDB db = *be;
+ ldap_chain_db_init_common( &db );
+ lc->lc_common_li = lc->lc_cfg_li = (ldapinfo_t *)db.be_private;
}
/* Something for the chain database? */
if ( strncasecmp( argv[ 0 ], "chain-", STRLENOF( "chain-" ) ) == 0 ) {
char *save_argv0 = argv[ 0 ];
- BackendInfo *bd_info = be->bd_info;
- void *be_private = be->be_private;
- ConfigOCs *be_cf_ocs = be->be_cf_ocs;
+ BackendDB db = *be;
static char *allowed_argv[] = {
/* special: put URI here, so in the meanwhile
* it detects whether a new URI is being provided */
}
if ( which_argv == 0 ) {
- rc = ldap_chain_db_init_one( be );
+ rc = ldap_chain_db_init_one( &db );
if ( rc != 0 ) {
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"underlying slapd-ldap initialization failed.\n.",
fname, lineno, 0 );
return 1;
}
- lc->lc_cfg_li = be->be_private;
+ lc->lc_cfg_li = db.be_private;
}
/* TODO: add checks on what other slapd-ldap(5) args
* be warned.
*/
- be->bd_info = lback;
- be->be_private = (void *)lc->lc_cfg_li;
- be->be_cf_ocs = lback->bi_cf_ocs;
+ db.bd_info = lback;
+ db.be_private = (void *)lc->lc_cfg_li;
+ db.be_cf_ocs = lback->bi_cf_ocs;
- rc = config_generic_wrapper( be, fname, lineno, argc, argv );
+ rc = config_generic_wrapper( &db, fname, lineno, argc, argv );
argv[ 0 ] = save_argv0;
- be->be_cf_ocs = be_cf_ocs;
- be->be_private = be_private;
- be->bd_info = bd_info;
if ( which_argv == 0 ) {
private_destroy:;
if ( rc != 0 ) {
- BackendDB db = *be;
-
db.bd_info = lback;
db.be_private = (void *)lc->lc_cfg_li;
ldap_chain_db_destroy_one( &db, NULL );
lc->lc_cfg_li = NULL;
-
} else {
if ( lc->lc_cfg_li->li_bvuri == NULL
|| BER_BVISNULL( &lc->lc_cfg_li->li_bvuri[ 0 ] )
}
}
}
-
+
return rc;
}