return PBLOCK_SUCCESS;
}
+static int
+pblock_be_call( Slapi_PBlock *pb, int (*bep)(Operation *) )
+{
+ BackendDB *be_orig;
+ Operation *op;
+ int rc;
+
+ PBLOCK_ASSERT_OP( pb, 0 );
+ op = pb->pb_op;
+
+ be_orig = op->o_bd;
+ op->o_bd = select_backend( &op->o_req_ndn, 0, 0 );
+ rc = (*bep)( op );
+ op->o_bd = be_orig;
+
+ return rc;
+}
+
static int
pblock_get( Slapi_PBlock *pb, int param, void **value )
{
*((char **)value) = pb->pb_op->o_req_ndn.bv_val;
break;
case SLAPI_REQUESTOR_ISROOT:
- PBLOCK_ASSERT_OP( pb, 0 );
- *((int *)value) = be_isroot( pb->pb_op );
+ *((int *)value) = pblock_be_call( pb, be_isroot );
break;
case SLAPI_IS_REPLICATED_OPERATION:
- PBLOCK_ASSERT_OP( pb, 0 );
- *((int *)value) = be_isupdate( pb->pb_op );
+ *((int *)value) = pblock_be_call( pb, be_slurp_update );
break;
case SLAPI_CONN_AUTHTYPE:
case SLAPI_CONN_AUTHMETHOD: /* XXX should return SASL mech */
break;
case SLAPI_RESULT_CODE:
case SLAPI_PLUGIN_INTOP_RESULT:
- *((int *)value) = pb->pb_rs.sr_err;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((int *)value) = pb->pb_rs->sr_err;
break;
case SLAPI_RESULT_TEXT:
- *((const char **)value) = pb->pb_rs.sr_text;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((const char **)value) = pb->pb_rs->sr_text;
break;
case SLAPI_RESULT_MATCHED:
- *((const char **)value) = pb->pb_rs.sr_matched;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((const char **)value) = pb->pb_rs->sr_matched;
break;
case SLAPI_ADD_ENTRY:
PBLOCK_ASSERT_OP( pb, 0 );
*((int *)value) = 0;
break;
case SLAPI_SEARCH_RESULT_ENTRY:
- *((Slapi_Entry **)value) = pb->pb_rs.sr_entry;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((Slapi_Entry **)value) = pb->pb_rs->sr_entry;
break;
case SLAPI_BIND_RET_SASLCREDS:
- *((struct berval **)value) = pb->pb_rs.sr_sasldata;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((struct berval **)value) = pb->pb_rs->sr_sasldata;
break;
case SLAPI_EXT_OP_REQ_OID:
*((const char **)value) = pb->pb_op->ore_reqoid.bv_val;
*((struct berval **)value) = pb->pb_op->ore_reqdata;
break;
case SLAPI_EXT_OP_RET_OID:
- *((const char **)value) = pb->pb_rs.sr_rspoid;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((const char **)value) = pb->pb_rs->sr_rspoid;
break;
case SLAPI_EXT_OP_RET_VALUE:
- *((struct berval **)value) = pb->pb_rs.sr_rspdata;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ *((struct berval **)value) = pb->pb_rs->sr_rspdata;
break;
case SLAPI_BIND_METHOD:
if ( pb->pb_op->o_tag == LDAP_REQ_BIND )
controls = (LDAPControl **)slapi_ch_realloc( (char *)controls,
( i + 2 ) * sizeof(LDAPControl *));
- controls[i] = control;
+ controls[i++] = slapi_dup_control( control );
+ controls[i] = NULL;
return pblock_set_default( pb, SLAPI_RESCONTROLS, (void *)controls );
}
LDAPControl **ctrls = NULL;
pblock_get_default( pb, param, (void **)&ctrls );
- if ( ctrls == NULL ) {
+ if ( ctrls != NULL ) {
/* free old ones first */
ldap_controls_free( ctrls );
}
break;
case SLAPI_RESULT_CODE:
case SLAPI_PLUGIN_INTOP_RESULT:
- pb->pb_rs.sr_err = *((int *)value);
+ PBLOCK_ASSERT_OP( pb, 0 );
+ pb->pb_rs->sr_err = *((int *)value);
break;
case SLAPI_RESULT_TEXT:
+ PBLOCK_ASSERT_OP( pb, 0 );
snprintf( pb->pb_textbuf, sizeof( pb->pb_textbuf ), "%s", (char *)value );
- pb->pb_rs.sr_text = pb->pb_textbuf;
+ pb->pb_rs->sr_text = pb->pb_textbuf;
break;
case SLAPI_RESULT_MATCHED:
- pb->pb_rs.sr_matched = (char *)value; /* XXX should dup? */
+ PBLOCK_ASSERT_OP( pb, 0 );
+ pb->pb_rs->sr_matched = (char *)value; /* XXX should dup? */
break;
case SLAPI_ADD_ENTRY:
PBLOCK_ASSERT_OP( pb, 0 );
}
if ( *mlp != NULL ) {
- if ( pb->pb_intop )
- slapi_int_mods_free( *mlp ); /* caller owns values */
- else
- slap_mods_free( *mlp ); /* we own values */
+ slapi_int_mods_free( *mlp );
*mlp = NULL;
}
*mlp = slapi_int_ldapmods2modifications( (LDAPMod **)value, NULL );
PBLOCK_VALIDATE_IS_INTOP( pb );
if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN ) {
rc = pblock_set_dn( value, &pb->pb_op->orr_newrdn, &pb->pb_op->orr_nnewrdn, pb->pb_op->o_tmpmemctx );
- if ( rc == LDAP_SUCCESS ) rc = rdn_validate( &pb->pb_op->orr_nnewrdn );
+ if ( rc == LDAP_SUCCESS )
+ rc = rdn_validate( &pb->pb_op->orr_nnewrdn );
} else {
rc = PBLOCK_ERROR;
}
an[i].an_oc_exclude = 0;
an[i].an_name.bv_val = attrs[i];
an[i].an_name.bv_len = strlen( attrs[i] );
- slap_bv2ad( &an[i].an_name, &an[i].an_desc, &pb->pb_rs.sr_text );
+ slap_bv2ad( &an[i].an_name, &an[i].an_desc, &pb->pb_rs->sr_text );
}
an[i].an_name.bv_val = NULL;
an[i].an_name.bv_len = 0;
break;
case SLAPI_SEARCH_RESULT_ENTRY:
PBLOCK_ASSERT_OP( pb, 0 );
- pb->pb_rs.sr_entry = (Slapi_Entry *)value;
+ pb->pb_rs->sr_entry = (Slapi_Entry *)value;
break;
case SLAPI_BIND_RET_SASLCREDS:
- pb->pb_rs.sr_sasldata = (struct berval *)value;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ pb->pb_rs->sr_sasldata = (struct berval *)value;
break;
case SLAPI_EXT_OP_REQ_OID:
PBLOCK_ASSERT_OP( pb, 0 );
rc = PBLOCK_ERROR;
break;
case SLAPI_EXT_OP_RET_OID:
- pb->pb_rs.sr_rspoid = (char *)value;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ pb->pb_rs->sr_rspoid = (char *)value;
break;
case SLAPI_EXT_OP_RET_VALUE:
- pb->pb_rs.sr_rspdata = (struct berval *)value;
+ PBLOCK_ASSERT_OP( pb, 0 );
+ pb->pb_rs->sr_rspdata = (struct berval *)value;
break;
case SLAPI_BIND_METHOD:
PBLOCK_ASSERT_OP( pb, 0 );
pb->pb_nParams = 1;
pb->pb_conn = NULL;
pb->pb_op = NULL;
+ pb->pb_rs = NULL;
pb->pb_intop = 0;
}
return pb;
slapi_int_connection_done_pb( pb );
} else {
pblock_get_default( pb, SLAPI_MODIFY_MODS, (void **)&mods );
- if ( mods != NULL )
- slapi_int_free_ldapmods( mods );
+ slapi_int_free_ldapmods( mods );
pblock_get_default( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
if ( attrs != NULL )