1 /* slapi_overlay.c - SLAPI overlay */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Luke Howard for inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
33 static slap_overinst slapi;
35 static int slapi_over_response( Operation *op, SlapReply *rs );
36 static int slapi_over_cleanup( Operation *op, SlapReply *rs );
39 slapi_over_pblock_new ( Operation *op )
43 pb = slapi_pblock_new();
48 slapi_int_pblock_set_operation( pb, op );
54 slapi_op_internal_p( Operation *op, slap_callback *cb )
57 Slapi_PBlock *pb = NULL;
60 /* Abstraction violating check for SLAPI internal operations */
61 /* allows pblock to remain consistent when invoking internal op plugins */
62 for ( pcb = op->o_callback; pcb != NULL; pcb = pcb->sc_next ) {
63 if ( pcb->sc_response == slapi_int_response ) {
64 pb = (Slapi_PBlock *)pcb->sc_private;
72 cb->sc_response = slapi_over_response;
73 cb->sc_cleanup = slapi_over_cleanup;
75 cb->sc_response = NULL;
76 cb->sc_cleanup = NULL;
80 pb = slapi_over_pblock_new( op );
84 cb->sc_next = op->o_callback;
92 slapi_over_compute_output(
93 computed_attr_context *c,
94 Slapi_Attr *attribute,
99 AttributeDescription *desc;
100 SlapReply *rs = (SlapReply *)c->cac_private;
102 if ( c == NULL || attribute == NULL || entry == NULL ) {
106 assert( rs->sr_entry == entry );
108 desc = attribute->a_desc;
110 if ( rs->sr_attrs == NULL ) {
111 /* All attrs request, skip operational attributes */
112 if ( is_at_operational( desc->ad_type ) ) {
116 /* Specific attributes requested */
117 if ( is_at_operational( desc->ad_type ) ) {
118 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
119 !ad_inlist( desc, rs->sr_attrs ) ) {
123 if ( !SLAP_USERATTRS( rs->sr_attr_flags ) &&
124 !ad_inlist( desc, rs->sr_attrs ) ) {
130 /* XXX perhaps we should check for existing attributes and merge */
131 for ( a = &rs->sr_operational_attrs; *a != NULL; a = &(*a)->a_next )
134 *a = attr_dup( attribute );
140 slapi_over_aux_operational( Operation *op, SlapReply *rs )
142 /* Support for computed attribute plugins */
143 computed_attr_context ctx;
146 if ( slapi_op_internal_p( op, NULL ) ) {
147 return SLAP_CB_CONTINUE;
150 ctx.cac_pb = slapi_over_pblock_new( op );
152 ctx.cac_private = rs;
154 if ( rs->sr_entry != NULL ) {
156 * For each client requested attribute, call the plugins.
158 if ( rs->sr_attrs != NULL ) {
159 for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
160 if ( compute_evaluator( &ctx, anp->an_name.bv_val,
161 rs->sr_entry, slapi_over_compute_output ) == 1 ) {
167 * Technically we shouldn't be returning operational attributes
168 * when the user requested only user attributes. We'll let the
169 * plugin decide whether to be naughty or not.
171 compute_evaluator( &ctx, "*", rs->sr_entry, slapi_over_compute_output );
175 slapi_pblock_destroy( ctx.cac_pb );
177 return SLAP_CB_CONTINUE;
181 slapi_over_search( Operation *op, SlapReply *rs, int type )
186 assert( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF );
188 /* create a new pblock to not trample on result controls */
189 pb = slapi_over_pblock_new( op );
191 slapi_pblock_set( pb, SLAPI_RESCONTROLS, (void *)rs->sr_ctrls );
192 slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, (void *)rs->sr_entry );
194 rc = slapi_int_call_plugins( op->o_bd, type, pb );
195 if ( rc >= 0 ) /* 1 means no plugins called */
196 rc = SLAP_CB_CONTINUE;
198 rc = LDAP_SUCCESS; /* confusing: don't abort, but don't send */
200 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
201 slapi_pblock_destroy(pb);
207 slapi_over_count_controls( LDAPControl **controls )
211 if ( controls == NULL )
214 for ( i = 0; controls[i] != NULL; i++ )
221 slapi_over_merge_controls( Operation *op, SlapReply *rs )
223 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
224 LDAPControl **slapiControls = NULL, **mergedControls;
225 int nSlapiControls = 0;
226 int nResControls = 0;
229 slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapiControls );
230 nSlapiControls = slapi_over_count_controls( slapiControls );
232 if ( nSlapiControls == 0 ) {
237 nResControls = slapi_over_count_controls( rs->sr_ctrls );
239 /* XXX this is a bit tricky, rs->sr_ctrls may have been allocated on stack */
240 mergedControls = (LDAPControl **)op->o_tmpalloc( ( nResControls + nSlapiControls + 1 ) *
241 sizeof( LDAPControl *), op->o_tmpmemctx );
242 if ( mergedControls == NULL ) {
243 return LDAP_NO_MEMORY;
246 if ( rs->sr_ctrls != NULL ) {
247 for ( i = 0; i < nResControls; i++ )
248 mergedControls[i] = rs->sr_ctrls[i];
250 if ( slapiControls != NULL ) {
251 for ( i = 0; i < nSlapiControls; i++ )
252 mergedControls[nResControls + i] = slapiControls[i];
254 mergedControls[nResControls + nSlapiControls] = NULL;
256 if ( slapiControls != NULL ) {
257 slapi_ch_free( (void **)&slapiControls );
258 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
261 rs->sr_ctrls = mergedControls;
267 * Call pre- and post-result plugins
270 slapi_over_result( Operation *op, SlapReply *rs, int type )
273 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
275 assert( rs->sr_type == REP_RESULT );
277 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
278 slapi_pblock_set( pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
279 slapi_pblock_set( pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
281 rc = slapi_int_call_plugins( op->o_bd, type, pb );
283 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
284 slapi_pblock_get( pb, SLAPI_RESULT_TEXT, (void **)&rs->sr_text );
285 slapi_pblock_get( pb, SLAPI_RESULT_MATCHED, (void **)&rs->sr_matched );
287 if ( type == SLAPI_PLUGIN_PRE_RESULT_FN ) {
288 rc = slapi_over_merge_controls( op, rs );
291 return SLAP_CB_CONTINUE;
295 slapi_op_add_init( Operation *op, SlapReply *rs )
297 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
299 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)op->ora_e );
305 slapi_op_bind_preop_init( Operation *op, SlapReply *rs )
307 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
309 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val );
310 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
311 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
312 slapi_pblock_set( pb, SLAPI_CONN_DN, NULL );
318 slapi_op_bind_postop_init( Operation *op, SlapReply *rs )
320 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
322 if ( rs->sr_err == LDAP_SUCCESS ) {
323 /* fix for ITS#2971 */
324 slapi_pblock_set( pb, SLAPI_CONN_DN, op->o_conn->c_authz.sai_dn.bv_val );
331 slapi_op_bind_callback( Operation *op, SlapReply *rs )
333 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
337 case SLAPI_BIND_SUCCESS:
338 /* Continue with backend processing */
340 case SLAPI_BIND_FAIL:
341 /* Failure, frontend (that's us) sends result */
342 rs->sr_err = LDAP_INVALID_CREDENTIALS;
343 send_ldap_result( op, rs );
346 case SLAPI_BIND_ANONYMOUS: /* undocumented */
347 default: /* plugin sent result or no plugins called */
348 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err ) != 0 ) {
349 rs->sr_err = LDAP_OTHER;
352 BER_BVZERO( &op->orb_edn );
354 if ( rs->sr_err == LDAP_SUCCESS ) {
355 slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
356 if ( BER_BVISNULL( &op->orb_edn ) ) {
358 /* No plugins were called; continue processing */
362 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
364 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
365 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
367 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
368 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
369 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
370 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
371 BER_BVZERO( &op->o_req_dn );
372 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
373 BER_BVZERO( &op->o_req_ndn );
374 if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) {
375 ber_len_t max = sockbuf_max_incoming_auth;
376 ber_sockbuf_ctrl( op->o_conn->c_sb,
377 LBER_SB_OPT_SET_MAX_INCOMING, &max );
380 /* log authorization identity */
381 Statslog( LDAP_DEBUG_STATS,
382 "%s BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
384 BER_BVISNULL( &op->o_conn->c_dn )
385 ? "<empty>" : op->o_conn->c_dn.bv_val,
386 op->orb_tmp_mech.bv_val, 0, 0 );
388 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
398 slapi_op_compare_init( Operation *op, SlapReply *rs )
400 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
402 slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)op->orc_ava->aa_desc->ad_cname.bv_val );
403 slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&op->orc_ava->aa_value );
409 slapi_op_modify_init( Operation *op, SlapReply *rs )
411 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
412 LDAPMod **modv = NULL;
414 modv = slapi_int_modifications2ldapmods( &op->orm_modlist );
415 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
421 slapi_op_modify_callback( Operation *op, SlapReply *rs )
423 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
424 LDAPMod **modv = NULL;
426 /* check preoperation result code */
427 if ( rs->sr_err < 0 ) {
428 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
433 * NB: it is valid for the plugin to return no modifications
434 * (for example, a plugin might store some attributes elsewhere
435 * and remove them from the modification list; if only those
436 * attribute types were included in the modification request,
437 * then slapi_int_ldapmods2modifications() above will return
440 * However, the post-operation plugin should still be
444 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
445 op->orm_modlist = slapi_int_ldapmods2modifications( modv );
451 slapi_op_modify_cleanup( Operation *op, SlapReply *rs )
453 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
454 LDAPMod **modv = NULL;
456 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
459 slapi_int_free_ldapmods( modv );
465 slapi_op_modrdn_init( Operation *op, SlapReply *rs )
467 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
469 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)op->orr_newrdn.bv_val );
470 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)op->orr_newSup->bv_val );
471 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)op->orr_deleteoldrdn );
477 slapi_op_search_init( Operation *op, SlapReply *rs )
479 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
482 attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx );
484 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
485 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
486 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
487 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
488 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
489 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
490 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
491 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
497 slapi_op_search_callback( Operation *op, SlapReply *rs )
499 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
501 /* check preoperation result code */
502 if ( rs->sr_err < 0 ) {
503 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
507 if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) != 0 ) {
512 * The plugin can set the SLAPI_SEARCH_FILTER.
513 * SLAPI_SEARCH_STRFILER is not normative.
515 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
516 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
517 filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
519 slapi_pblock_get( pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val );
520 op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val );
522 if( !BER_BVISNULL( &op->o_req_ndn ) ) {
523 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
525 rs->sr_err = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn,
527 if ( rs->sr_err != LDAP_SUCCESS ) {
528 send_ldap_result( op, rs );
532 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope );
533 slapi_pblock_get( pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref );
539 slapi_op_search_cleanup( Operation *op, SlapReply *rs )
541 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
544 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void *)&attrs );
547 op->o_tmpfree( attrs, op->o_tmpmemctx );
552 struct slapi_op_info {
553 int soi_preop; /* preoperation plugin parameter */
554 int soi_postop; /* postoperation plugin parameter */
555 int soi_internal_preop; /* internal preoperation plugin parameter */
556 int soi_internal_postop; /* internal postoperation plugin parameter */
557 slap_response *soi_preop_init; /* preoperation pblock init function */
558 slap_response *soi_callback; /* preoperation result handler */
559 slap_response *soi_postop_init; /* postoperation pblock init function */
560 slap_response *soi_cleanup; /* cleanup function (not for internal ops) */
561 } slapi_op_dispatch_table[] = {
563 SLAPI_PLUGIN_PRE_BIND_FN,
564 SLAPI_PLUGIN_POST_BIND_FN,
567 slapi_op_bind_preop_init,
568 slapi_op_bind_callback,
569 slapi_op_bind_postop_init,
573 SLAPI_PLUGIN_PRE_UNBIND_FN,
574 SLAPI_PLUGIN_POST_UNBIND_FN,
583 SLAPI_PLUGIN_PRE_SEARCH_FN,
584 SLAPI_PLUGIN_POST_SEARCH_FN,
587 slapi_op_search_init,
588 slapi_op_search_callback,
590 slapi_op_search_cleanup
593 SLAPI_PLUGIN_PRE_COMPARE_FN,
594 SLAPI_PLUGIN_POST_COMPARE_FN,
597 slapi_op_compare_init,
603 SLAPI_PLUGIN_PRE_MODIFY_FN,
604 SLAPI_PLUGIN_POST_MODIFY_FN,
605 SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN,
606 SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
607 slapi_op_modify_init,
608 slapi_op_modify_callback,
610 slapi_op_modify_cleanup
613 SLAPI_PLUGIN_PRE_MODRDN_FN,
614 SLAPI_PLUGIN_POST_MODRDN_FN,
615 SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN,
616 SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
617 slapi_op_modrdn_init,
623 SLAPI_PLUGIN_PRE_ADD_FN,
624 SLAPI_PLUGIN_POST_ADD_FN,
625 SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN,
626 SLAPI_PLUGIN_INTERNAL_POST_ADD_FN,
633 SLAPI_PLUGIN_PRE_DELETE_FN,
634 SLAPI_PLUGIN_POST_DELETE_FN,
635 SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN,
636 SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
643 SLAPI_PLUGIN_PRE_ABANDON_FN,
644 SLAPI_PLUGIN_POST_ABANDON_FN,
665 slapi_tag2op( ber_tag_t tag )
676 case LDAP_REQ_DELETE:
679 case LDAP_REQ_MODRDN:
682 case LDAP_REQ_MODIFY:
685 case LDAP_REQ_COMPARE:
688 case LDAP_REQ_SEARCH:
691 case LDAP_REQ_UNBIND:
703 slapi_over_response( Operation *op, SlapReply *rs )
707 switch ( rs->sr_type ) {
709 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_PRE_RESULT_FN );
712 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_ENTRY_FN );
715 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_REFERRAL_FN );
718 rc = SLAP_CB_CONTINUE;
726 slapi_over_cleanup( Operation *op, SlapReply *rs )
730 switch ( rs->sr_type ) {
732 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_POST_RESULT_FN );
735 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_ENTRY_FN );
738 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_REFERRAL_FN );
741 rc = SLAP_CB_CONTINUE;
749 slapi_op_func( Operation *op, SlapReply *rs )
752 slap_operation_t which;
753 struct slapi_op_info *opinfo;
759 int preop_type, postop_type;
761 if ( !slapi_plugins_used )
762 return SLAP_CB_CONTINUE;
765 * Find the SLAPI operation information for this LDAP
766 * operation; this will contain the preop and postop
767 * plugin types, as well as optional callbacks for
768 * setting up the SLAPI environment.
770 which = slapi_tag2op( op->o_tag );
771 if ( which >= op_last ) {
772 /* invalid operation, but let someone else deal with it */
773 return SLAP_CB_CONTINUE;
776 opinfo = &slapi_op_dispatch_table[which];
777 if ( opinfo == NULL ) {
778 /* no SLAPI plugin types for this operation */
779 return SLAP_CB_CONTINUE;
782 internal_op = slapi_op_internal_p( op, &cb );
785 preop_type = opinfo->soi_internal_preop;
786 postop_type = opinfo->soi_internal_postop;
788 preop_type = opinfo->soi_preop;
789 postop_type = opinfo->soi_postop;
792 if ( preop_type == 0 ) {
793 /* no SLAPI plugin types for this operation */
794 rs->sr_err = SLAP_CB_CONTINUE;
798 pb = SLAPI_OPERATION_PBLOCK( op );
800 slapi_pblock_set( pb, SLAPI_TARGET_ADDRESS, NULL );
801 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, NULL );
802 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)op->o_req_dn.bv_val );
805 * Call preoperation plugins
807 if ( opinfo->soi_preop_init != NULL ) {
808 rs->sr_err = (opinfo->soi_preop_init)( op, rs );
809 if ( rs->sr_err != LDAP_SUCCESS )
813 rs->sr_err = slapi_int_call_plugins( op->o_bd, preop_type, pb );
816 * soi_callback is responsible for examining the result code
817 * of the preoperation plugin and determining whether to
818 * abort. This is needed because of special SLAPI behaviour
819 * with bind preoperation plugins.
821 * The soi_callback function is also used to reset any values
822 * returned from the preoperation plugin before calling the
823 * backend (for the success case).
825 if ( opinfo->soi_callback == NULL ) {
826 /* default behaviour is preop plugin can abort operation */
827 if ( rs->sr_err < 0 ) {
828 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
831 rs->sr_err = LDAP_SUCCESS;
834 rc = (opinfo->soi_callback)( op, rs );
840 * Call actual backend (or next overlay in stack). We need to
841 * do this rather than returning SLAP_CB_CONTINUE and calling
842 * postoperation plugins in a response handler to match the
843 * behaviour of SLAPI in OpenLDAP 2.2, where postoperation
844 * plugins are called after the backend has completely
845 * finished processing the operation.
847 on = (slap_overinst *)op->o_bd->bd_info;
850 rs->sr_err = overlay_op_walk( op, rs, which, oi, on->on_next );
853 * Call postoperation plugins
855 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
857 if ( opinfo->soi_postop_init != NULL ) {
858 (opinfo->soi_postop_init)( op, rs );
861 slapi_int_call_plugins( op->o_bd, postop_type, pb );
864 if ( !internal_op ) {
865 if ( opinfo->soi_cleanup != NULL ) {
866 (opinfo->soi_cleanup)( op, rs );
868 slapi_pblock_destroy(pb);
869 cb.sc_private = NULL;
872 op->o_callback = cb.sc_next;
878 slapi_over_extended( Operation *op, SlapReply *rs )
883 struct berval reqdata = BER_BVNULL;
887 slapi_int_get_extop_plugin( &op->ore_reqoid, &callback );
888 if ( callback == NULL ) {
889 return SLAP_CB_CONTINUE;
892 internal_op = slapi_op_internal_p( op, &cb );
894 return SLAP_CB_CONTINUE;
897 pb = SLAPI_OPERATION_PBLOCK( op );
899 if ( op->ore_reqdata != NULL ) {
900 reqdata = *op->ore_reqdata;
903 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, (void *)op->ore_reqoid.bv_val);
904 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_VALUE, (void *)&reqdata);
906 rc = (*callback)( pb );
907 if ( rc == SLAPI_PLUGIN_EXTENDED_SENT_RESULT ) {
908 slapi_pblock_destroy( pb );
910 } else if ( rc == SLAPI_PLUGIN_EXTENDED_NOT_HANDLED ) {
911 slapi_pblock_destroy( pb );
912 return SLAP_CB_CONTINUE;
915 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, (void **)&rs->sr_rspoid );
916 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, (void **)&rs->sr_rspdata );
919 send_ldap_extended( op, rs );
921 slapi_ch_free_string( (char **)&rs->sr_rspoid );
923 if ( rs->sr_rspdata != NULL )
924 ber_bvfree( rs->sr_rspdata );
926 slapi_pblock_destroy( pb );
932 slapi_over_access_allowed(
935 AttributeDescription *desc,
937 slap_access_t access,
938 AccessControlState *state,
946 internal_op = slapi_op_internal_p( op, &cb );
948 cb.sc_response = NULL;
949 cb.sc_cleanup = NULL;
951 pb = SLAPI_OPERATION_PBLOCK( op );
953 rc = slapi_int_access_allowed( op, e, desc, val, access, state );
955 rc = SLAP_CB_CONTINUE;
958 op->o_callback = cb.sc_next;
961 slapi_pblock_destroy( pb );
967 slapi_over_acl_group(
970 struct berval *gr_ndn,
971 struct berval *op_ndn,
972 ObjectClass *group_oc,
973 AttributeDescription *group_at )
978 BackendDB *be = op->o_bd;
981 op->o_bd = select_backend( gr_ndn, 0, 0 );
983 for ( g = op->o_groups; g; g = g->ga_next ) {
984 if ( g->ga_be != op->o_bd || g->ga_oc != group_oc ||
985 g->ga_at != group_at || g->ga_len != gr_ndn->bv_len )
989 if ( strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0 ) {
998 if ( target != NULL && dn_match( &target->e_nname, gr_ndn ) ) {
1002 rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e );
1008 internal_op = slapi_op_internal_p( op, &cb );
1010 cb.sc_response = NULL;
1011 cb.sc_cleanup = NULL;
1013 pb = SLAPI_OPERATION_PBLOCK( op );
1015 slapi_pblock_set( pb, SLAPI_X_GROUP_ENTRY, (void *)e );
1016 slapi_pblock_set( pb, SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val );
1017 slapi_pblock_set( pb, SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val );
1018 slapi_pblock_set( pb, SLAPI_X_GROUP_TARGET_ENTRY, (void *)target );
1020 rc = slapi_int_call_plugins( op->o_bd, SLAPI_X_PLUGIN_PRE_GROUP_FN, pb );
1021 if ( rc >= 0 ) /* 1 means no plugins called */
1022 rc = SLAP_CB_CONTINUE;
1024 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rc );
1027 slapi_pblock_destroy( pb );
1029 if ( e != target ) {
1030 be_entry_release_r( op, e );
1033 rc = LDAP_NO_SUCH_OBJECT; /* return SLAP_CB_CONTINUE for correctness? */
1036 if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache &&
1037 rc != SLAP_CB_CONTINUE ) {
1038 g = op->o_tmpalloc( sizeof( GroupAssertion ) + gr_ndn->bv_len,
1040 g->ga_be = op->o_bd;
1041 g->ga_oc = group_oc;
1042 g->ga_at = group_at;
1044 g->ga_len = gr_ndn->bv_len;
1045 strcpy( g->ga_ndn, gr_ndn->bv_val );
1046 g->ga_next = op->o_groups;
1050 * XXX don't call POST_GROUP_FN, I have no idea what the point of
1051 * that plugin function was anyway
1059 slapi_int_overlay_init()
1061 memset( &slapi, 0, sizeof(slapi) );
1063 slapi.on_bi.bi_type = SLAPI_OVERLAY_NAME;
1065 slapi.on_bi.bi_op_bind = slapi_op_func;
1066 slapi.on_bi.bi_op_unbind = slapi_op_func;
1067 slapi.on_bi.bi_op_search = slapi_op_func;
1068 slapi.on_bi.bi_op_compare = slapi_op_func;
1069 slapi.on_bi.bi_op_modify = slapi_op_func;
1070 slapi.on_bi.bi_op_modrdn = slapi_op_func;
1071 slapi.on_bi.bi_op_add = slapi_op_func;
1072 slapi.on_bi.bi_op_delete = slapi_op_func;
1073 slapi.on_bi.bi_op_abandon = slapi_op_func;
1074 slapi.on_bi.bi_op_cancel = slapi_op_func;
1076 slapi.on_bi.bi_extended = slapi_over_extended;
1077 slapi.on_bi.bi_access_allowed = slapi_over_access_allowed;
1078 slapi.on_bi.bi_operational = slapi_over_aux_operational;
1079 slapi.on_bi.bi_acl_group = slapi_over_acl_group;
1081 return overlay_register( &slapi );
1084 #endif /* LDAP_SLAPI */