]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/slapi_overlay.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_5
[openldap] / servers / slapd / slapi / slapi_overlay.c
index 0fb616118fd5fc6adc2a2932e7fa28e2aeae7e48..11d0098ae511185793b67de3b3a0c6d6d064b460 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2006 The OpenLDAP Foundation.
+ * Copyright 2001-2014 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,6 +27,7 @@
 
 #include "slap.h"
 #include "slapi.h"
+#include "config.h"
 
 #ifdef LDAP_SLAPI
 
@@ -97,12 +98,14 @@ slapi_over_compute_output(
 {
        Attribute               **a;
        AttributeDescription    *desc;
-       SlapReply               *rs = (SlapReply *)c->cac_private;
+       SlapReply               *rs;
 
        if ( c == NULL || attribute == NULL || entry == NULL ) {
                return 0;
        }
 
+       rs = (SlapReply *)c->cac_private;
+
        assert( rs->sr_entry == entry );
 
        desc = attribute->a_desc;
@@ -278,8 +281,8 @@ slapi_op_bind_callback( Operation *op, SlapReply *rs, int prc )
                                op->o_log_prefix,
                                BER_BVISNULL( &op->o_conn->c_dn )
                                        ? "<empty>" : op->o_conn->c_dn.bv_val,
-                               BER_BVISNULL( &op->orb_tmp_mech )
-                                       ? "<empty>" : op->orb_tmp_mech.bv_val, 0, 0 );
+                               BER_BVISNULL( &op->orb_mech )
+                                       ? "<empty>" : op->orb_mech.bv_val, 0, 0 );
 
                        return -1;
                }
@@ -293,6 +296,7 @@ static int
 slapi_op_search_callback( Operation *op, SlapReply *rs, int prc )
 {
        Slapi_PBlock            *pb = SLAPI_OPERATION_PBLOCK( op );
+       Filter *f = op->ors_filter;
 
        /* check preoperation result code */
        if ( prc < 0 ) {
@@ -301,13 +305,16 @@ slapi_op_search_callback( Operation *op, SlapReply *rs, int prc )
 
        rs->sr_err = LDAP_SUCCESS;
 
-       if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) == 0 ) {
+       if ( pb->pb_intop == 0 && 
+            slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) == 0 ) {
                /*
                 * The plugin can set the SLAPI_SEARCH_FILTER.
                 * SLAPI_SEARCH_STRFILER is not normative.
                 */
-               op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
-               filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
+               if (f != op->ors_filter) {
+                       op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+                       filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
+               }
        }
 
        return LDAP_SUCCESS;
@@ -323,29 +330,29 @@ struct slapi_op_info {
        {
                SLAPI_PLUGIN_PRE_BIND_FN,
                SLAPI_PLUGIN_POST_BIND_FN,
-               0,
-               0,
+               SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN,
+               SLAPI_PLUGIN_INTERNAL_POST_BIND_FN,
                slapi_op_bind_callback
        },
        {
                SLAPI_PLUGIN_PRE_UNBIND_FN,
                SLAPI_PLUGIN_POST_UNBIND_FN,
-               0,
-               0,
+               SLAPI_PLUGIN_INTERNAL_PRE_UNBIND_FN,
+               SLAPI_PLUGIN_INTERNAL_POST_UNBIND_FN,
                NULL
        },
        {
                SLAPI_PLUGIN_PRE_SEARCH_FN,
                SLAPI_PLUGIN_POST_SEARCH_FN,
-               0,
-               0,
+               SLAPI_PLUGIN_INTERNAL_PRE_SEARCH_FN,
+               SLAPI_PLUGIN_INTERNAL_POST_SEARCH_FN,
                slapi_op_search_callback
        },
        {
                SLAPI_PLUGIN_PRE_COMPARE_FN,
                SLAPI_PLUGIN_POST_COMPARE_FN,
-               0,
-               0,
+               SLAPI_PLUGIN_INTERNAL_PRE_COMPARE_FN,
+               SLAPI_PLUGIN_INTERNAL_POST_COMPARE_FN,
                NULL
        },
        {
@@ -379,8 +386,8 @@ struct slapi_op_info {
        {
                SLAPI_PLUGIN_PRE_ABANDON_FN,
                SLAPI_PLUGIN_POST_ABANDON_FN,
-               0,
-               0,
+               SLAPI_PLUGIN_INTERNAL_PRE_ABANDON_FN,
+               SLAPI_PLUGIN_INTERNAL_POST_ABANDON_FN,
                NULL
        },
        {
@@ -447,11 +454,11 @@ slapi_over_merge_controls( Operation *op, SlapReply *rs )
        n_slapi_ctrls = slapi_int_count_controls( slapi_ctrls );
        n_rs_ctrls = slapi_int_count_controls( rs->sr_ctrls );
 
-       slapi_pblock_set( pb, SLAPI_X_OLD_RESCONTROLS, (void *)rs->sr_ctrls );
-
        if ( n_slapi_ctrls == 0 )
                return LDAP_SUCCESS; /* no SLAPI controls */
 
+       slapi_pblock_set( pb, SLAPI_X_OLD_RESCONTROLS, (void *)rs->sr_ctrls );
+
        ctrls = (LDAPControl **) op->o_tmpalloc(
                ( n_slapi_ctrls + n_rs_ctrls + 1 ) * sizeof(LDAPControl *),
                op->o_tmpmemctx );
@@ -760,7 +767,7 @@ slapi_over_acl_group(
        GroupAssertion          *g;
        SlapReply               rs = { REP_RESULT };
 
-       op->o_bd = select_backend( gr_ndn, 0, 0 );
+       op->o_bd = select_backend( gr_ndn, 0 );
 
        for ( g = op->o_groups; g; g = g->ga_next ) {
                if ( g->ga_be != op->o_bd || g->ga_oc != group_oc ||
@@ -845,7 +852,9 @@ done:
 }
 
 static int
-slapi_over_db_open( BackendDB *be )
+slapi_over_db_open(
+       BackendDB       *be,
+       ConfigReply     *cr )
 {
        Slapi_PBlock            *pb;
        int                     rc;
@@ -860,7 +869,9 @@ slapi_over_db_open( BackendDB *be )
 }
 
 static int
-slapi_over_db_close( BackendDB *be )
+slapi_over_db_close(
+       BackendDB       *be,
+       ConfigReply     *cr )
 {
        Slapi_PBlock            *pb;
        int                     rc;
@@ -908,7 +919,7 @@ int slapi_over_is_inst( BackendDB *be )
        return overlay_is_inst( be, SLAPI_OVERLAY_NAME );
 }
 
-int slapi_over_config( BackendDB *be )
+int slapi_over_config( BackendDB *be, ConfigReply *cr )
 {
        if ( slapi_over_initialized == 0 ) {
                int rc;
@@ -932,7 +943,7 @@ int slapi_over_config( BackendDB *be )
                slapi_over_initialized = 1;
        }
 
-       return overlay_config( be, SLAPI_OVERLAY_NAME );
+       return overlay_config( be, SLAPI_OVERLAY_NAME, -1, NULL, cr );
 }
 
 #endif /* LDAP_SLAPI */