]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backglue.c
__should__ fix ITS#4262; please review
[openldap] / servers / slapd / backglue.c
index 9a320205219dc2586cb19e2be92186cf8d06ed91..1031e7e23285af677cd1dbcb0fb1d494f0f9bfbf 100644 (file)
@@ -79,7 +79,6 @@ glue_back_select (
 
 typedef struct glue_state {
        int err;
-       int slimit;
        int matchlen;
        char *matched;
        int nrefs;
@@ -93,13 +92,6 @@ glue_op_response ( Operation *op, SlapReply *rs )
 
        switch(rs->sr_type) {
        case REP_SEARCH:
-               if ( gs->slimit != SLAP_NO_LIMIT
-                               && rs->sr_nentries >= gs->slimit )
-               {
-                       rs->sr_err = gs->err = LDAP_SIZELIMIT_EXCEEDED;
-                       return -1;
-               }
-               /* fallthru */
        case REP_SEARCHREF:
                return SLAP_CB_CONTINUE;
 
@@ -157,7 +149,7 @@ glue_op_func ( Operation *op, SlapReply *rs )
        BackendDB *b0 = op->o_bd;
        BackendInfo *bi0 = op->o_bd->bd_info;
        BI_op_modify **func;
-       slap_operation_t which;
+       slap_operation_t which = op_bind;
        int rc;
 
        op->o_bd = glue_back_select (b0, &op->o_req_ndn);
@@ -168,6 +160,7 @@ glue_op_func ( Operation *op, SlapReply *rs )
        case LDAP_REQ_DELETE: which = op_delete; break;
        case LDAP_REQ_MODIFY: which = op_modify; break;
        case LDAP_REQ_MODRDN: which = op_modrdn; break;
+       default: assert( 0 ); break;
        }
 
        func = &op->o_bd->bd_info->bi_op_bind;
@@ -241,9 +234,9 @@ glue_op_search ( Operation *op, SlapReply *rs )
        BackendInfo *bi0 = op->o_bd->bd_info;
        int i;
        long stoptime = 0;
-       glue_state gs = {0, 0, 0, NULL, 0, NULL};
+       glue_state gs = {0, 0, NULL, 0, NULL};
        slap_callback cb = { NULL, glue_op_response, NULL, NULL };
-       int scope0, slimit0, tlimit0;
+       int scope0, tlimit0;
        struct berval dn, ndn, *pdn;
 
        cb.sc_private = &gs;
@@ -265,9 +258,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
 
        case LDAP_SCOPE_ONELEVEL:
        case LDAP_SCOPE_SUBTREE:
-#ifdef LDAP_SCOPE_SUBORDINATE
        case LDAP_SCOPE_SUBORDINATE: /* FIXME */
-#endif
 
 #if 0
                if ( op->o_sync ) {
@@ -284,7 +275,6 @@ glue_op_search ( Operation *op, SlapReply *rs )
                op->o_callback = &cb;
                rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
                scope0 = op->ors_scope;
-               slimit0 = gs.slimit = op->ors_slimit;
                tlimit0 = op->ors_tlimit;
                dn = op->o_req_dn;
                ndn = op->o_req_ndn;
@@ -312,13 +302,6 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                        break;
                                }
                        }
-                       if (slimit0 != SLAP_NO_LIMIT) {
-                               op->ors_slimit = slimit0 - rs->sr_nentries;
-                               if (op->ors_slimit < 0) {
-                                       rs->sr_err = gs.err = LDAP_SIZELIMIT_EXCEEDED;
-                                       break;
-                               }
-                       }
                        rs->sr_err = 0;
                        /*
                         * check for abandon 
@@ -338,6 +321,9 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                op->o_req_dn = op->o_bd->be_suffix[0];
                                op->o_req_ndn = op->o_bd->be_nsuffix[0];
                                rs->sr_err = op->o_bd->be_search(op, rs);
+                               if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
+                                       gs.err = LDAP_SUCCESS;
+                               }
 
                        } else if (scope0 == LDAP_SCOPE_SUBTREE &&
                                dn_match(&op->o_bd->be_nsuffix[0], &ndn))
@@ -353,6 +339,8 @@ glue_op_search ( Operation *op, SlapReply *rs )
                                if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) {
                                        gs.err = LDAP_SUCCESS;
                                }
+                               op->o_req_dn = dn;
+                               op->o_req_ndn = ndn;
 
                        } else if (dnIsSuffix(&ndn, &op->o_bd->be_nsuffix[0])) {
                                rs->sr_err = op->o_bd->be_search( op, rs );
@@ -369,7 +357,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
                        case LDAP_ADMINLIMIT_EXCEEDED:
                        case LDAP_NO_SUCH_OBJECT:
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
-                       case LDAP_CANNOT_CHAIN:
+                       case LDAP_X_CANNOT_CHAIN:
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
                                goto end_of_loop;
                        
@@ -379,7 +367,6 @@ glue_op_search ( Operation *op, SlapReply *rs )
                }
 end_of_loop:;
                op->ors_scope = scope0;
-               op->ors_slimit = slimit0;
                op->ors_tlimit = tlimit0;
                op->o_req_dn = dn;
                op->o_req_ndn = ndn;
@@ -716,6 +703,7 @@ glue_db_init(
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        slap_overinfo   *oi = on->on_info;
+       BackendInfo     *bi = oi->oi_orig;
        glueinfo *gi;
 
        gi = ch_calloc( 1, sizeof(glueinfo));
@@ -730,14 +718,23 @@ glue_db_init(
 
        oi->oi_bi.bi_entry_release_rw = glue_entry_release_rw;
 
-       oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
-       oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
-       oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
-       oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
-       oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
-       oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
-       oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
-       oi->oi_bi.bi_tool_sync = glue_tool_sync;
+       /* Only advertise these if the root DB supports them */
+       if ( bi->bi_tool_entry_open )
+               oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
+       if ( bi->bi_tool_entry_close )
+               oi->oi_bi.bi_tool_entry_close = glue_tool_entry_close;
+       if ( bi->bi_tool_entry_first )
+               oi->oi_bi.bi_tool_entry_first = glue_tool_entry_first;
+       if ( bi->bi_tool_entry_next )
+               oi->oi_bi.bi_tool_entry_next = glue_tool_entry_next;
+       if ( bi->bi_tool_entry_get )
+               oi->oi_bi.bi_tool_entry_get = glue_tool_entry_get;
+       if ( bi->bi_tool_entry_put )
+               oi->oi_bi.bi_tool_entry_put = glue_tool_entry_put;
+       if ( bi->bi_tool_entry_reindex )
+               oi->oi_bi.bi_tool_entry_reindex = glue_tool_entry_reindex;
+       if ( bi->bi_tool_sync )
+               oi->oi_bi.bi_tool_sync = glue_tool_sync;
 
        /*FIXME : need to add support */
        oi->oi_bi.bi_tool_dn2id_get = 0;
@@ -827,7 +824,7 @@ typedef struct glue_Addrec {
 static glue_Addrec *ga_list;
 
 /* Attach all the subordinate backends to their superior */
-static int
+int
 glue_sub_attach()
 {
        glue_Addrec *ga, *gnext = NULL;
@@ -899,16 +896,9 @@ glue_sub_add( BackendDB *be, int advert, int online )
                SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;
 
        ga = ch_malloc( sizeof( glue_Addrec ));
-       ga->ga_next = NULL;
+       ga->ga_next = ga_list;
        ga->ga_be = be;
-       if ( ga_list ) {
-               glue_Addrec *g2 = ga_list;
-
-               for ( ; g2 && g2->ga_next; g2=g2->ga_next );
-               g2->ga_next = ga;
-       } else {
-               ga_list = ga;
-       }
+       ga_list = ga;
 
        if ( online )
                rc = glue_sub_attach();
@@ -919,8 +909,6 @@ glue_sub_add( BackendDB *be, int advert, int online )
 int
 glue_sub_init()
 {
-       int rc;
-
        glue.on_bi.bi_type = "glue";
 
        glue.on_bi.bi_db_init = glue_db_init;
@@ -936,8 +924,5 @@ glue_sub_init()
        glue.on_bi.bi_chk_referrals = glue_chk_referrals;
        glue.on_bi.bi_chk_controls = glue_chk_controls;
 
-       rc = overlay_register( &glue );
-       if ( rc ) return rc;
-
-       return glue_sub_attach();
+       return overlay_register( &glue );
 }