X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fresult.c;h=07b8d2d904e85903dcf497ac7bcc51e908ee5efb;hb=49b0985c88ea6836a24c314aea2cb2dd0d129544;hp=3beff2f438b98456e69d391222fa9f33bcce505b;hpb=767cf365eaf15fc8c81981fbf32ef6a71ce70f5d;p=openldap diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 3beff2f438..07b8d2d904 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -1,8 +1,27 @@ /* result.c - routines to send ldap results, errors, and referrals */ /* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2003 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* Portions Copyright (c) 1995 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. */ #include "portable.h" @@ -22,6 +41,11 @@ #include "slapi.h" #endif +int slap_null_cb( Operation *op, SlapReply *rs ) +{ + return 0; +} + static char *v2ref( BerVarray ref, const char *text ) { size_t len = 0, i = 0; @@ -371,9 +395,11 @@ send_ldap_response( } #ifdef LDAP_SLAPI - slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text ); + if ( op->o_pb ) { + slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err ); + slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched ); + slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text ); + } #endif /* LDAP_SLAPI */ ldap_pvt_thread_mutex_lock( &num_sent_mutex ); @@ -493,12 +519,14 @@ slap_send_ldap_result( Operation *op, SlapReply *rs ) * should just set SLAPI_RESULT_CODE rather than sending a * result if they wish to change the result. */ - slapi_x_pblock_set_operation( op->o_pb, op ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text ); - slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched ); + if ( op->o_pb ) { + slapi_x_pblock_set_operation( op->o_pb, op ); + slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err ); + slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text ); + slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched ); - (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb ); + (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb ); + } #endif /* LDAP_SLAPI */ if ( op->o_protocol < LDAP_VERSION3 ) { @@ -1069,38 +1097,40 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) * First, setup the computed attribute context that is * passed to all plugins. */ - ctx.cac_pb = op->o_pb; - ctx.cac_attrs = rs->sr_attrs; - ctx.cac_attrsonly = op->ors_attrsonly; - ctx.cac_userattrs = userattrs; - ctx.cac_opattrs = opattrs; - ctx.cac_acl_state = acl_state; - ctx.cac_private = (void *)ber; + if ( op->o_pb ) { + ctx.cac_pb = op->o_pb; + ctx.cac_attrs = rs->sr_attrs; + ctx.cac_attrsonly = op->ors_attrsonly; + ctx.cac_userattrs = userattrs; + ctx.cac_opattrs = opattrs; + ctx.cac_acl_state = acl_state; + ctx.cac_private = (void *)ber; - /* - * For each client requested attribute, call the plugins. - */ - if ( rs->sr_attrs != NULL ) { - for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) { - rc = compute_evaluator( &ctx, anp->an_name.bv_val, - rs->sr_entry, slapi_x_compute_output_ber ); - if ( rc == 1 ) { - break; - } - } - } else { /* - * Technically we shouldn't be returning operational attributes - * when the user requested only user attributes. We'll let the - * plugin decide whether to be naughty or not. + * For each client requested attribute, call the plugins. */ - rc = compute_evaluator( &ctx, "*", - rs->sr_entry, slapi_x_compute_output_ber ); - } - if ( rc == 1 ) { - if ( op->o_res_ber == NULL ) ber_free_buf( ber ); - send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" ); - goto error_return; + if ( rs->sr_attrs != NULL ) { + for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) { + rc = compute_evaluator( &ctx, anp->an_name.bv_val, + rs->sr_entry, slapi_x_compute_output_ber ); + if ( rc == 1 ) { + break; + } + } + } else { + /* + * Technically we shouldn't be returning operational attributes + * when the user requested only user attributes. We'll let the + * plugin decide whether to be naughty or not. + */ + rc = compute_evaluator( &ctx, "*", + rs->sr_entry, slapi_x_compute_output_ber ); + } + if ( rc == 1 ) { + if ( op->o_res_ber == NULL ) ber_free_buf( ber ); + send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" ); + goto error_return; + } } #endif /* LDAP_SLAPI */