/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2003-2012 The OpenLDAP Foundation.
+ * Copyright 2003-2015 The OpenLDAP Foundation.
* Portions Copyright 2003 Howard Chu.
* All rights reserved.
*
* added by the chain overlay, so it's the only one we explicitly
* free */
if ( op->o_ctrls != oldctrls ) {
- assert( op->o_ctrls != NULL );
- assert( op->o_ctrls[ 0 ] != NULL );
+ if ( op->o_ctrls != NULL ) {
+ assert( op->o_ctrls[ 0 ] != NULL );
- free( op->o_ctrls );
+ free( op->o_ctrls );
- op->o_chaining = 0;
+ op->o_chaining = 0;
+ }
op->o_ctrls = oldctrls;
}
/* back-ldap tried to send result */
lb->lb_status = LDAP_CH_RES;
+ /* don't let other callbacks run, this isn't
+ * the real result for this op.
+ */
+ op->o_callback->sc_next = NULL;
}
return 0;
}
further_cleanup:;
+ if ( op->o_req_dn.bv_val == pdn.bv_val ) {
+ op->o_req_dn = odn;
+ op->o_req_ndn = ondn;
+ }
+
if ( free_dn ) {
op->o_tmpfree( pdn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
rc = rs2.sr_err;
}
- op->o_req_dn = odn;
- op->o_req_ndn = ondn;
-
#ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
(void)chaining_control_remove( op, &ctrls );
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
}
further_cleanup:;
+ if ( op->o_req_dn.bv_val == pdn.bv_val ) {
+ op->o_req_dn = odn;
+ op->o_req_ndn = ondn;
+ }
+
if ( free_dn ) {
op->o_tmpfree( pdn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
}
- op->o_req_dn = odn;
- op->o_req_ndn = ondn;
-
if ( tmp_oq_search.rs_filter != NULL ) {
filter_free_x( op, tmp_oq_search.rs_filter, 1 );
}
(void)chaining_control_remove( op, &ctrls );
#endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
- op->o_req_dn = odn;
- op->o_req_ndn = ondn;
rs->sr_type = REP_SEARCHREF;
rs->sr_entry = save_entry;
rs->sr_flags = save_flags;
if ( lc->lc_common_li == NULL ) {
rc = ldap_chain_db_init_common( ca->be );
+ if ( rc != 0 )
+ goto fail;
+ li = ca->be->be_private;
+ lc->lc_common_li = lc->lc_cfg_li = li;
- } else {
- rc = ldap_chain_db_init_one( ca->be );
}
+ rc = ldap_chain_db_init_one( ca->be );
if ( rc != 0 ) {
+fail:
Debug( LDAP_DEBUG_ANY, "slapd-chain: "
"unable to init %sunderlying database \"%s\".\n",
lc->lc_common_li == NULL ? "common " : "", e->e_name.bv_val, 0 );
li = ca->be->be_private;
- if ( lc->lc_common_li == NULL ) {
- lc->lc_common_li = li;
-
- } else {
+ if ( at ) {
li->li_uri = ch_strdup( at->a_vals[ 0 ].bv_val );
value_add_one( &li->li_bvuri, &at->a_vals[ 0 ] );
if ( avl_insert( &lc->lc_lai.lai_tree, (caddr_t)li,