From 38f10e1f63e6ccb4ef64f00f9a24912fdffa162c Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Wed, 27 Jul 2005 10:09:44 +0000 Subject: [PATCH] PBlock SlapReply needs to be a pointer into that supplied by caller for overlay ops --- servers/slapd/slapi/proto-slapi.h | 1 + servers/slapd/slapi/slapi.h | 2 +- servers/slapd/slapi/slapi_ops.c | 16 ++++++----- servers/slapd/slapi/slapi_overlay.c | 25 ++++++++-------- servers/slapd/slapi/slapi_pblock.c | 44 +++++++++++++++++++---------- servers/slapd/slapi/slapi_utils.c | 4 +-- 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 612ab9f89e..4a7d6b0dde 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -54,6 +54,7 @@ LDAP_SLAPI_F (int) slapi_int_pblock_get_next LDAP_P(( Slapi_PBlock **pb )); #define PBLOCK_ASSERT_OP( _pb, _tag ) do { \ PBLOCK_ASSERT_CONN( _pb ); \ assert( (_pb)->pb_op != NULL ); \ + assert( (_pb)->pb_rs != NULL ); \ if ( _tag != 0 ) \ assert( (_pb)->pb_op->o_tag == (_tag)); \ } while (0) diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index 3f577026f3..ee3619d8ea 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -121,7 +121,7 @@ struct slapi_pblock { /* native types */ Connection *pb_conn; Operation *pb_op; - SlapReply pb_rs; + SlapReply *pb_rs; int pb_intop; char pb_textbuf[ SLAP_TEXT_BUFLEN ]; }; diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index 48403ea872..7ad05b1c49 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -167,7 +167,7 @@ slapi_int_get_ctrls( Slapi_PBlock *pb ) if ( pb->pb_op->o_ctrls != NULL ) { for ( c = pb->pb_op->o_ctrls; *c != NULL; c++ ) { - rc = slap_parse_ctrl( pb->pb_op, &pb->pb_rs, *c, &pb->pb_rs.sr_text ); + rc = slap_parse_ctrl( pb->pb_op, pb->pb_rs, *c, &pb->pb_rs->sr_text ); if ( rc != LDAP_SUCCESS ) break; } @@ -280,6 +280,7 @@ slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag ) slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op ); slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION, conn ); + pb->pb_rs = (SlapReply *)slapi_ch_calloc( 1, sizeof(SlapReply) ); pb->pb_op = op; pb->pb_conn = conn; pb->pb_intop = 1; @@ -372,13 +373,14 @@ slapi_int_connection_done_pb( Slapi_PBlock *pb ) slapi_ch_free( (void **)&pb->pb_op->o_callback ); slapi_ch_free( (void **)&pb->pb_op ); slapi_ch_free( (void **)&pb->pb_conn ); + slapi_ch_free( (void **)&pb->pb_rs ); } static int slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which ) { BI_op_bind **func; - SlapReply *rs = &pb->pb_rs; + SlapReply *rs = pb->pb_rs; int rc; PBLOCK_ASSERT_INTOP( pb, 0 ); @@ -391,7 +393,7 @@ slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which ) func = &pb->pb_op->o_bd->be_bind; - return func[which]( pb->pb_op, &pb->pb_rs ); + return func[which]( pb->pb_op, pb->pb_rs ); } int @@ -421,7 +423,7 @@ slapi_add_internal_pb( Slapi_PBlock *pb ) PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD ); - rs = &pb->pb_rs; + rs = pb->pb_rs; entry_orig = pb->pb_op->ora_e; pb->pb_op->ora_e = NULL; @@ -506,7 +508,7 @@ slapi_modrdn_internal_pb( Slapi_PBlock *pb ) PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN ); if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) { - pb->pb_rs.sr_err = LDAP_UNWILLING_TO_PERFORM; + pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM; goto cleanup; } @@ -529,7 +531,7 @@ slapi_modify_internal_pb( Slapi_PBlock *pb ) PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY ); - rs = &pb->pb_rs; + rs = pb->pb_rs; if ( pb->pb_op->orm_modlist == NULL ) { rs->sr_err = LDAP_PARAM_ERROR; @@ -624,7 +626,7 @@ slapi_search_internal_callback_pb( Slapi_PBlock *pb, PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH ); - rs = &pb->pb_rs; + rs = pb->pb_rs; /* search callback and arguments */ slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc ); diff --git a/servers/slapd/slapi/slapi_overlay.c b/servers/slapd/slapi/slapi_overlay.c index a898892891..c5528a40b1 100644 --- a/servers/slapd/slapi/slapi_overlay.c +++ b/servers/slapd/slapi/slapi_overlay.c @@ -36,13 +36,14 @@ static int slapi_over_response( Operation *op, SlapReply *rs ); static int slapi_over_cleanup( Operation *op, SlapReply *rs ); static Slapi_PBlock * -slapi_over_pblock_new( Operation *op ) +slapi_over_pblock_new( Operation *op, SlapReply *rs ) { Slapi_PBlock *pb; pb = slapi_pblock_new(); pb->pb_op = op; pb->pb_conn = op->o_conn; + pb->pb_rs = rs; pb->pb_intop = 0; PBLOCK_ASSERT_OP( pb, op->o_tag ); @@ -51,7 +52,7 @@ slapi_over_pblock_new( Operation *op ) } static int -slapi_op_internal_p( Operation *op, slap_callback *cb ) +slapi_op_internal_p( Operation *op, SlapReply *rs, slap_callback *cb ) { int internal_op = 0; Slapi_PBlock *pb = NULL; @@ -73,7 +74,7 @@ slapi_op_internal_p( Operation *op, slap_callback *cb ) if ( cb != NULL ) { if ( pb == NULL ) { - pb = slapi_over_pblock_new( op ); + pb = slapi_over_pblock_new( op, rs ); } cb->sc_response = slapi_over_response; @@ -141,11 +142,11 @@ slapi_over_aux_operational( Operation *op, SlapReply *rs ) computed_attr_context ctx; AttributeName *anp; - if ( slapi_op_internal_p( op, NULL ) ) { + if ( slapi_op_internal_p( op, rs, NULL ) ) { return SLAP_CB_CONTINUE; } - ctx.cac_pb = slapi_over_pblock_new( op ); + ctx.cac_pb = slapi_over_pblock_new( op, rs ); ctx.cac_op = op; ctx.cac_private = rs; @@ -184,7 +185,7 @@ slapi_over_search( Operation *op, SlapReply *rs, int type ) assert( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF ); /* create a new pblock to not trample on result controls */ - pb = slapi_over_pblock_new( op ); + pb = slapi_over_pblock_new( op, rs ); rc = slapi_int_call_plugins( op->o_bd, type, pb ); if ( rc >= 0 ) /* 1 means no plugins called */ @@ -551,7 +552,7 @@ slapi_op_func( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } - internal_op = slapi_op_internal_p( op, &cb ); + internal_op = slapi_op_internal_p( op, rs, &cb ); if ( internal_op ) { preop_type = opinfo->soi_internal_preop; @@ -637,7 +638,7 @@ slapi_over_extended( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } - internal_op = slapi_op_internal_p( op, &cb ); + internal_op = slapi_op_internal_p( op, rs, &cb ); if ( internal_op ) { return SLAP_CB_CONTINUE; } @@ -683,8 +684,9 @@ slapi_over_access_allowed( Slapi_PBlock *pb; slap_callback cb; int internal_op; + SlapReply rs = { REP_RESULT }; - internal_op = slapi_op_internal_p( op, &cb ); + internal_op = slapi_op_internal_p( op, &rs, &cb ); cb.sc_response = NULL; cb.sc_cleanup = NULL; @@ -718,6 +720,7 @@ slapi_over_acl_group( Slapi_PBlock *pb; BackendDB *be = op->o_bd; GroupAssertion *g; + SlapReply rs = { REP_RESULT }; op->o_bd = select_backend( gr_ndn, 0, 0 ); @@ -746,7 +749,7 @@ slapi_over_acl_group( int internal_op; slap_callback cb; - internal_op = slapi_op_internal_p( op, &cb ); + internal_op = slapi_op_internal_p( op, &rs, &cb ); cb.sc_response = NULL; cb.sc_cleanup = NULL; @@ -762,7 +765,7 @@ slapi_over_acl_group( if ( rc >= 0 ) /* 1 means no plugins called */ rc = SLAP_CB_CONTINUE; else - rc = pb->pb_rs.sr_err; + rc = pb->pb_rs->sr_err; slapi_pblock_delete_param( pb, SLAPI_X_GROUP_ENTRY ); slapi_pblock_delete_param( pb, SLAPI_X_GROUP_OPERATION_DN ); diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 1d6b4c06c2..8342e82aba 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -549,13 +549,16 @@ pblock_get( Slapi_PBlock *pb, int param, void **value ) 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 ); @@ -665,10 +668,12 @@ pblock_get( Slapi_PBlock *pb, int param, void **value ) *((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; @@ -677,10 +682,12 @@ pblock_get( Slapi_PBlock *pb, int param, void **value ) *((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 ) @@ -851,14 +858,17 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) 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 ); @@ -1039,7 +1049,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) 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; @@ -1058,10 +1068,11 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) 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 ); @@ -1084,10 +1095,12 @@ pblock_set( Slapi_PBlock *pb, int param, void *value ) 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 ); @@ -1210,6 +1223,7 @@ slapi_pblock_new(void) pb->pb_nParams = 1; pb->pb_conn = NULL; pb->pb_op = NULL; + pb->pb_rs = NULL; pb->pb_intop = 0; } return pb; diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index a12dc57d84..ba87ff7b59 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1297,9 +1297,9 @@ slapi_send_ldap_result( { SlapReply *rs; - assert( pb->pb_op != NULL ); + PBLOCK_ASSERT_OP( pb, 0 ); - rs = &pb->pb_rs; + rs = pb->pb_rs; rs->sr_err = err; rs->sr_matched = matched; -- 2.39.5