mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-29 11:09:34 -05:00
ITS#6758 Rewrite code for contrib:wrap_slap_ops.
Tweak slapd code so wrap_slap_ops can process it: Use pointers BackendInfo *bi instead of array "func" = &bi->bi_op_bind. In slapo-chain, keep a slap_operation_t instead of a function ptr.
This commit is contained in:
parent
7bb8b706c5
commit
5415e1e6de
6 changed files with 37 additions and 45 deletions
|
|
@ -118,7 +118,7 @@ static int ldap_chain_db_open_one( BackendDB *be );
|
|||
typedef struct ldap_chain_cb_t {
|
||||
ldap_chain_status_t lb_status;
|
||||
ldap_chain_t *lb_lc;
|
||||
BI_op_func *lb_op_f;
|
||||
slap_operation_t lb_op_type;
|
||||
int lb_depth;
|
||||
} ldap_chain_cb_t;
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ static int
|
|||
ldap_chain_op(
|
||||
Operation *op,
|
||||
SlapReply *rs,
|
||||
BI_op_func *op_f,
|
||||
slap_operation_t op_type,
|
||||
BerVarray ref,
|
||||
int depth );
|
||||
|
||||
|
|
@ -316,7 +316,8 @@ ldap_chain_cb_search_response( Operation *op, SlapReply *rs )
|
|||
&& lb->lb_depth < lb->lb_lc->lc_max_depth
|
||||
&& rs->sr_ref != NULL )
|
||||
{
|
||||
rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_f, rs->sr_ref, lb->lb_depth );
|
||||
rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_type,
|
||||
rs->sr_ref, lb->lb_depth );
|
||||
}
|
||||
|
||||
/* back-ldap tried to send result */
|
||||
|
|
@ -356,7 +357,8 @@ retry:;
|
|||
|
||||
case LDAP_REFERRAL:
|
||||
if ( lb->lb_depth < lb->lb_lc->lc_max_depth && rs->sr_ref != NULL ) {
|
||||
rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_f, rs->sr_ref, lb->lb_depth );
|
||||
rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_type,
|
||||
rs->sr_ref, lb->lb_depth );
|
||||
goto retry;
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +393,7 @@ static int
|
|||
ldap_chain_op(
|
||||
Operation *op,
|
||||
SlapReply *rs,
|
||||
BI_op_func *op_f,
|
||||
slap_operation_t op_type,
|
||||
BerVarray ref,
|
||||
int depth )
|
||||
{
|
||||
|
|
@ -602,10 +604,10 @@ Document: RFC 4511
|
|||
op->o_log_prefix, ref->bv_val, temporary ? "temporary" : "caching" );
|
||||
}
|
||||
|
||||
lb->lb_op_f = op_f;
|
||||
lb->lb_op_type = op_type;
|
||||
lb->lb_depth = depth + 1;
|
||||
|
||||
rc = op_f( op, &rs2 );
|
||||
rc = (&lback->bi_op_bind)[ op_type ]( op, &rs2 );
|
||||
|
||||
/* note the first error */
|
||||
if ( first_rc == -1 ) {
|
||||
|
|
@ -873,7 +875,7 @@ ldap_chain_search(
|
|||
op->o_log_prefix, ref->bv_val, temporary ? "temporary" : "caching" );
|
||||
}
|
||||
|
||||
lb->lb_op_f = lback->bi_op_search;
|
||||
lb->lb_op_type = op_search;
|
||||
lb->lb_depth = depth + 1;
|
||||
|
||||
/* FIXME: should we also copy filter and scope?
|
||||
|
|
@ -1041,30 +1043,30 @@ ldap_chain_response( Operation *op, SlapReply *rs )
|
|||
/* FIXME: can we really get a referral for binds? */
|
||||
op->o_req_ndn = slap_empty_bv;
|
||||
op->o_conn = NULL;
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_bind, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_bind, ref, 0 );
|
||||
op->o_req_ndn = rndn;
|
||||
op->o_conn = conn;
|
||||
}
|
||||
break;
|
||||
|
||||
case LDAP_REQ_ADD:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_add, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_add, ref, 0 );
|
||||
break;
|
||||
|
||||
case LDAP_REQ_DELETE:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_delete, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_delete, ref, 0 );
|
||||
break;
|
||||
|
||||
case LDAP_REQ_MODRDN:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_modrdn, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_modrdn, ref, 0 );
|
||||
break;
|
||||
|
||||
case LDAP_REQ_MODIFY:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_modify, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_modify, ref, 0 );
|
||||
break;
|
||||
|
||||
case LDAP_REQ_COMPARE:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_compare, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_compare, ref, 0 );
|
||||
if ( rs->sr_err == LDAP_COMPARE_TRUE || rs->sr_err == LDAP_COMPARE_FALSE ) {
|
||||
rc = LDAP_SUCCESS;
|
||||
}
|
||||
|
|
@ -1081,8 +1083,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
|
|||
* to check limits, to make sure safe defaults
|
||||
* are in place */
|
||||
if ( op->ors_limit != NULL || limits_check( op, rs ) == 0 ) {
|
||||
rc = ldap_chain_op( op, rs, lback->bi_op_search, ref, 0 );
|
||||
|
||||
rc = ldap_chain_op( op, rs, op_search, ref, 0 );
|
||||
} else {
|
||||
rc = SLAP_CB_CONTINUE;
|
||||
}
|
||||
|
|
@ -1090,7 +1091,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
|
|||
break;
|
||||
|
||||
case LDAP_REQ_EXTENDED:
|
||||
rc = ldap_chain_op( op, rs, lback->bi_extended, ref, 0 );
|
||||
rc = ldap_chain_op( op, rs, op_extended, ref, 0 );
|
||||
/* FIXME: ldap_back_extended() by design
|
||||
* doesn't send result; frontend is expected
|
||||
* to send it... */
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ static int
|
|||
relay_back_op( Operation *op, SlapReply *rs, int which )
|
||||
{
|
||||
BackendDB *bd;
|
||||
BI_op_bind *func;
|
||||
BackendInfo *bi;
|
||||
slap_mask_t fail_mode = relay_fail_modes[which].rf_op;
|
||||
int rc = ( fail_mode & RB_ERR_MASK );
|
||||
|
||||
|
|
@ -203,12 +203,12 @@ relay_back_op( Operation *op, SlapReply *rs, int which )
|
|||
if ( fail_mode & RB_BDERR )
|
||||
return rs->sr_err; /* sr_err was set above */
|
||||
|
||||
} else if ( (func = (&bd->be_bind)[which]) != 0 ) {
|
||||
} else if ( (&( bi = bd->bd_info )->bi_op_bind)[which] ) {
|
||||
relay_callback rcb;
|
||||
|
||||
relay_back_add_cb( &rcb, op );
|
||||
RELAY_WRAP_OP( op, bd, which, {
|
||||
rc = func( op, rs );
|
||||
rc = (&bi->bi_op_bind)[which]( op, rs );
|
||||
});
|
||||
relay_back_remove_cb( &rcb, op );
|
||||
|
||||
|
|
|
|||
|
|
@ -225,8 +225,7 @@ glue_op_func ( Operation *op, SlapReply *rs )
|
|||
{
|
||||
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
|
||||
BackendDB *b0 = op->o_bd;
|
||||
BackendInfo *bi0 = op->o_bd->bd_info;
|
||||
BI_op_modify **func;
|
||||
BackendInfo *bi0 = op->o_bd->bd_info, *bi1;
|
||||
slap_operation_t which = op_bind;
|
||||
int rc;
|
||||
|
||||
|
|
@ -247,11 +246,9 @@ glue_op_func ( Operation *op, SlapReply *rs )
|
|||
default: assert( 0 ); break;
|
||||
}
|
||||
|
||||
func = &op->o_bd->bd_info->bi_op_bind;
|
||||
if ( func[which] )
|
||||
rc = func[which]( op, rs );
|
||||
else
|
||||
rc = SLAP_CB_BYPASS;
|
||||
bi1 = op->o_bd->bd_info;
|
||||
rc = (&bi1->bi_op_bind)[ which ] ?
|
||||
(&bi1->bi_op_bind)[ which ]( op, rs ) : SLAP_CB_BYPASS;
|
||||
|
||||
op->o_bd = b0;
|
||||
op->o_bd->bd_info = bi0;
|
||||
|
|
|
|||
|
|
@ -669,26 +669,26 @@ int overlay_op_walk(
|
|||
slap_overinst *on
|
||||
)
|
||||
{
|
||||
BI_op_bind **func;
|
||||
BackendInfo *bi;
|
||||
int rc = SLAP_CB_CONTINUE;
|
||||
|
||||
for (; on; on=on->on_next ) {
|
||||
if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
|
||||
continue;
|
||||
func = &on->on_bi.bi_op_bind;
|
||||
if ( func[which] ) {
|
||||
bi = &on->on_bi;
|
||||
if ( (&bi->bi_op_bind)[ which ] ) {
|
||||
op->o_bd->bd_info = (BackendInfo *)on;
|
||||
rc = func[which]( op, rs );
|
||||
rc = (&bi->bi_op_bind)[ which ]( op, rs );
|
||||
if ( rc != SLAP_CB_CONTINUE ) break;
|
||||
}
|
||||
}
|
||||
if ( rc == SLAP_CB_BYPASS )
|
||||
rc = SLAP_CB_CONTINUE;
|
||||
|
||||
func = &oi->oi_orig->bi_op_bind;
|
||||
if ( func[which] && rc == SLAP_CB_CONTINUE ) {
|
||||
op->o_bd->bd_info = oi->oi_orig;
|
||||
rc = func[which]( op, rs );
|
||||
bi = oi->oi_orig;
|
||||
if ( (&bi->bi_op_bind)[ which ] && rc == SLAP_CB_CONTINUE ) {
|
||||
op->o_bd->bd_info = bi;
|
||||
rc = (&bi->bi_op_bind)[ which ]( op, rs );
|
||||
}
|
||||
/* should not fall thru this far without anything happening... */
|
||||
if ( rc == SLAP_CB_CONTINUE ) {
|
||||
|
|
@ -1451,4 +1451,3 @@ overlay_config( BackendDB *be, const char *ov, int idx, BackendInfo **res, Confi
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2792,17 +2792,16 @@ pcache_op_privdb(
|
|||
/* map tag to operation */
|
||||
type = slap_req2op( op->o_tag );
|
||||
if ( type != SLAP_OP_LAST ) {
|
||||
BI_op_func **func;
|
||||
BackendInfo *bi = cm->db.bd_info;
|
||||
int rc;
|
||||
|
||||
/* execute, if possible */
|
||||
func = &cm->db.be_bind;
|
||||
if ( func[ type ] != NULL ) {
|
||||
if ( (&bi->bi_op_bind)[ type ] ) {
|
||||
Operation op2 = *op;
|
||||
|
||||
op2.o_bd = &cm->db;
|
||||
|
||||
rc = func[ type ]( &op2, rs );
|
||||
rc = (&bi->bi_op_bind)[ type ]( &op2, rs );
|
||||
if ( type == SLAP_OP_BIND && rc == LDAP_SUCCESS ) {
|
||||
op->o_conn->c_authz_cookie = cm->db.be_private;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@ slapi_int_connection_done_pb( Slapi_PBlock *pb )
|
|||
static int
|
||||
slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
|
||||
{
|
||||
BI_op_bind **func;
|
||||
SlapReply *rs = pb->pb_rs;
|
||||
int rc;
|
||||
|
||||
|
|
@ -397,9 +396,7 @@ slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
|
|||
}
|
||||
|
||||
pb->pb_op->o_bd = frontendDB;
|
||||
func = &frontendDB->be_bind;
|
||||
|
||||
return func[which]( pb->pb_op, pb->pb_rs );
|
||||
return (&frontendDB->be_bind)[which]( pb->pb_op, pb->pb_rs );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -953,4 +950,3 @@ slapi_delete_internal(
|
|||
}
|
||||
|
||||
#endif /* LDAP_SLAPI */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue