]> git.sur5r.net Git - openldap/commitdiff
ITS#4615 fix from HEAD
authorHoward Chu <hyc@openldap.org>
Wed, 13 Dec 2006 16:39:24 +0000 (16:39 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 13 Dec 2006 16:39:24 +0000 (16:39 +0000)
servers/slapd/backglue.c
servers/slapd/backover.c
servers/slapd/slap.h

index 6487a2d2bcfc9d2344ad67014ee4ea49aee29f23..224da54b84da5e227e6d7992213f2d2d2c842ea1 100644 (file)
@@ -65,7 +65,7 @@ glue_back_select (
        glueinfo                *gi = (glueinfo *)on->on_bi.bi_private;
        int i;
 
-       for (i = 0; i<gi->gi_nodes; i++) {
+       for (i = gi->gi_nodes-1; i >= 0; i--) {
                assert( gi->gi_n[i].gn_be->be_nsuffix != NULL );
 
                if (dnIsSuffix(dn, &gi->gi_n[i].gn_be->be_nsuffix[0])) {
@@ -199,13 +199,26 @@ glue_op_func ( Operation *op, SlapReply *rs )
        if ( func[which] )
                rc = func[which]( op, rs );
        else
-               rc = SLAP_CB_CONTINUE;
+               rc = SLAP_CB_BYPASS;
 
        op->o_bd = b0;
        op->o_bd->bd_info = bi0;
        return rc;
 }
 
+static int
+glue_response ( Operation *op, SlapReply *rs )
+{
+       slap_overinst   *on = (slap_overinst *)op->o_bd->bd_info;
+       BackendDB *be = op->o_bd;
+       be = glue_back_select (op->o_bd, &op->o_req_ndn);
+
+       /* If we're on the master backend, let overlay framework handle it.
+        * Otherwise, bail out.
+        */
+       return ( op->o_bd == be ) ? SLAP_CB_CONTINUE : SLAP_CB_BYPASS;
+}
+
 static int
 glue_chk_referrals ( Operation *op, SlapReply *rs )
 {
@@ -340,7 +353,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
                b1 = op->o_bd;
 
                /*
-                * Execute in reverse order, most general first 
+                * Execute in reverse order, most specific first 
                 */
                for (i = gi->gi_nodes; i >= 0; i--) {
                        if ( i == gi->gi_nodes ) {
@@ -384,6 +397,9 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
                                        gs.err = LDAP_SUCCESS;
                                }
+                               op->ors_scope = LDAP_SCOPE_ONELEVEL;
+                               op->o_req_dn = dn;
+                               op->o_req_ndn = ndn;
 
                        } else if (scope0 == LDAP_SCOPE_SUBTREE &&
                                dn_match(&op->o_bd->be_nsuffix[0], &ndn))
@@ -1006,6 +1022,7 @@ glue_sub_init()
 
        glue.on_bi.bi_chk_referrals = glue_chk_referrals;
        glue.on_bi.bi_chk_controls = glue_chk_controls;
+       glue.on_response = glue_response;
 
        return overlay_register( &glue );
 }
index 88bd1731805410d0404dfc8a2a9eeb1856b27e03..7d4bc25d9517b76bbe65a3891528ea3e92932c60 100644 (file)
@@ -210,9 +210,11 @@ over_db_destroy(
 
        rc = over_db_func( be, db_destroy );
 
-       for (next = on->on_next; on; on=next) {
-               next = on->on_next;
-               free( on );
+       if ( on ) {
+               for (next = on->on_next; on; on=next) {
+                       next = on->on_next;
+                       free( on );
+               }
        }
        free( oi );
        return rc;
@@ -235,6 +237,11 @@ over_back_response ( Operation *op, SlapReply *rs )
                        if ( rc != SLAP_CB_CONTINUE ) break;
                }
        }
+       /* Bypass the remaining on_response layers, but allow
+        * normal execution to continue.
+        */
+       if ( rc == SLAP_CB_BYPASS )
+               rc = SLAP_CB_CONTINUE;
        op->o_bd = be;
        return rc;
 }
@@ -492,6 +499,8 @@ int overlay_op_walk(
                        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 ) {
index eace47d3b2668da67b41ef2e2390634081d79be0..a19420c5a2ac9489f684cbc5e4aae667e12a2854 100644 (file)
@@ -2260,6 +2260,7 @@ typedef struct slap_overinfo {
 
 /* Should successive callbacks in a chain be processed? */
 #define        SLAP_CB_FREEME          0x04000
+#define        SLAP_CB_BYPASS          0x08800
 #define        SLAP_CB_CONTINUE        0x08000
 
 /*