]> git.sur5r.net Git - openldap/commitdiff
"ultimate" fix of glued databases controls checking; other minor fixes
authorPierangelo Masarati <ando@openldap.org>
Sun, 30 Jan 2005 22:02:37 +0000 (22:02 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 30 Jan 2005 22:02:37 +0000 (22:02 +0000)
servers/slapd/backend.c
servers/slapd/backover.c
servers/slapd/controls.c
servers/slapd/overlays/glue.c
servers/slapd/proto-slap.h

index 0698243ed421a21fcc83f1ab9460777d995d9528..546b74984d3eab2b7d8e42c829a199137a97a02a 100644 (file)
@@ -205,27 +205,29 @@ backend_set_controls( BackendDB *be )
                        AC_MEMCPY( be->be_ctrls, bi->bi_ctrls,
                                        sizeof( be->be_ctrls ) );
                        be->be_ctrls[ SLAP_MAX_CIDS ] = 1;
-
+                       
                } else {
                        int     i;
-
+                       
                        for ( i = 0; i < SLAP_MAX_CIDS; i++ ) {
                                if ( bi->bi_ctrls[ i ] ) {
                                        be->be_ctrls[ i ] = bi->bi_ctrls[ i ];
                                }
                        }
                }
+
        }
 
        return 0;
 }
 
-
 /* startup a specific backend database */
 int backend_startup_one(Backend *be)
 {
        int             rc = 0;
 
+       assert( be );
+
        be->be_pending_csn_list = (struct be_pcl *)
                ch_calloc( 1, sizeof( struct be_pcl ));
 
@@ -235,7 +237,10 @@ int backend_startup_one(Backend *be)
                "backend_startup_one: starting \"%s\"\n",
                be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
                0, 0 );
+
+       /* set database controls */
        (void)backend_set_controls( be );
+
        if ( be->bd_info->bi_db_open ) {
                rc = be->bd_info->bi_db_open( be );
                if ( rc == 0 ) {
@@ -859,7 +864,7 @@ backend_connection_destroy(
        return 0;
 }
 
-static int
+int
 backend_check_controls(
        Operation *op,
        SlapReply *rs )
@@ -906,7 +911,7 @@ backend_check_controls(
 
                        default:
                                /* unreachable */
-                               rs->sr_err = "unable to check control";
+                               rs->sr_text = "unable to check control";
                                rs->sr_err = LDAP_OTHER;
                                goto done;
                        }
index 9c77024a213c85068adb5dab84bb66b10533e2d1..f7e572071ce4f7e143b8cdf2d4f03fbcd39b9810 100644 (file)
@@ -235,7 +235,7 @@ static int op_rc[] = {
        LDAP_UNWILLING_TO_PERFORM,      /* bind */
        LDAP_UNWILLING_TO_PERFORM,      /* unbind */
        LDAP_UNWILLING_TO_PERFORM,      /* search */
-       LDAP_UNWILLING_TO_PERFORM,      /* compare */
+       SLAP_CB_CONTINUE,               /* compare; pass to frontend */
        LDAP_UNWILLING_TO_PERFORM,      /* modify */
        LDAP_UNWILLING_TO_PERFORM,      /* modrdn */
        LDAP_UNWILLING_TO_PERFORM,      /* add */
@@ -245,7 +245,7 @@ static int op_rc[] = {
        LDAP_UNWILLING_TO_PERFORM,      /* extended */
        LDAP_SUCCESS,                   /* aux_operational */
        LDAP_SUCCESS,                   /* aux_chk_referrals */
-       LDAP_SUCCESS                    /* aux_chk_controls */
+       SLAP_CB_CONTINUE                /* aux_chk_controls; pass to frontend */
 };
 
 static int
@@ -385,6 +385,50 @@ over_aux_chk_controls( Operation *op, SlapReply *rs )
        return over_op_func( op, rs, op_aux_chk_controls );
 }
 
+static int
+over_connection_destroy(
+       BackendDB       *bd,
+       Connection      *conn
+)
+{
+       slap_overinfo *oi;
+       slap_overinst *on;
+       BackendDB db;
+       int rc = SLAP_CB_CONTINUE;
+
+       /* FIXME: used to happen for instance during abandon
+        * when global overlays are used... */
+       assert( bd != NULL );
+
+       oi = bd->bd_info->bi_private;
+       on = oi->oi_list;
+
+       if ( !SLAP_ISOVERLAY( bd )) {
+               db = *bd;
+               db.be_flags |= SLAP_DBFLAG_OVERLAY;
+               bd = &db;
+       }
+
+       for (; on; on=on->on_next ) {
+               if ( on->on_bi.bi_connection_destroy ) {
+                       bd->bd_info = (BackendInfo *)on;
+                       rc = on->on_bi.bi_connection_destroy( bd, conn );
+                       if ( rc != SLAP_CB_CONTINUE ) break;
+               }
+       }
+
+       if ( oi->oi_orig->bi_connection_destroy && rc == SLAP_CB_CONTINUE ) {
+               bd->bd_info = oi->oi_orig;
+               rc = oi->oi_orig->bi_connection_destroy( bd, conn );
+       }
+       /* should not fall thru this far without anything happening... */
+       if ( rc == SLAP_CB_CONTINUE ) {
+               rc = LDAP_UNWILLING_TO_PERFORM;
+       }
+
+       return rc;
+}
+
 int
 overlay_register(
        slap_overinst *on
@@ -498,12 +542,14 @@ overlay_register_control( BackendDB *be, const char *oid )
                        }
 
                        bd->be_ctrls[ cid ] = 1;
+                       bd->be_ctrls[ SLAP_MAX_CIDS ] = 1;
                }
 
        }
        
        if ( rc == 0 && !gotit ) {
                be->be_ctrls[ cid ] = 1;
+               be->be_ctrls[ SLAP_MAX_CIDS ] = 1;
        }
 
        return rc;
@@ -573,6 +619,8 @@ overlay_config( BackendDB *be, const char *ov )
                bi->bi_operational = over_aux_operational;
                bi->bi_chk_referrals = over_aux_chk_referrals;
                bi->bi_chk_controls = over_aux_chk_controls;
+               
+               bi->bi_connection_destroy = over_connection_destroy;
 
                be->bd_info = bi;
 
index f6696c35adabe406ec7cb57e51d6bcc7fb05e11c..f67c7e8f81448aed7499a05ff036d4a0be5c7eaa 100644 (file)
@@ -106,7 +106,7 @@ static struct slap_control control_defs[] = {
                parsePostRead, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_VALUESRETURNFILTER,
                (int)offsetof(struct slap_control_ids, sc_valuesReturnFilter),
-               SLAP_CTRL_SEARCH, NULL,
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_SEARCH, NULL,
                parseValuesReturnFilter, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_PAGEDRESULTS,
                (int)offsetof(struct slap_control_ids, sc_pagedResults),
@@ -395,17 +395,17 @@ slap_global_control( Operation *op, const char *oid, int *cid )
 
        if ( cid ) *cid = ctrl->sc_cid;
 
-       if ( ctrl->sc_mask & SLAP_CTRL_GLOBAL ) return LDAP_COMPARE_TRUE;
-
-       if (( op->o_tag & LDAP_REQ_SEARCH ) &&
-               ( ctrl->sc_mask & SLAP_CTRL_GLOBAL_SEARCH ))
+       if ( ( ctrl->sc_mask & SLAP_CTRL_GLOBAL ) ||
+                       ( ( op->o_tag & LDAP_REQ_SEARCH ) &&
+                       ( ctrl->sc_mask & SLAP_CTRL_GLOBAL_SEARCH ) ) )
        {
                return LDAP_COMPARE_TRUE;
        }
 
-       Debug( LDAP_DEBUG_ANY,
+       Debug( LDAP_DEBUG_TRACE,
                "slap_global_control: unavailable control: %s\n",      
                oid, 0, 0 );
+
        return LDAP_COMPARE_FALSE;
 }
 
index ad922655181a92f0cfe336c041fada42bcf25752..03c7a306c61a27045909cd02f370897f269e88b3 100644 (file)
@@ -222,15 +222,23 @@ glue_chk_controls ( Operation *op, SlapReply *rs )
        glueinfo                *gi = (glueinfo *)on->on_bi.bi_private;
        BackendDB *b0 = op->o_bd;
        BackendInfo *bi0 = op->o_bd->bd_info;
-       int rc;
+       int rc = SLAP_CB_CONTINUE;
 
        op->o_bd = glue_back_select (b0, &op->o_req_ndn);
        b0->bd_info = on->on_info->oi_orig;
 
-       if ( op->o_bd->bd_info->bi_chk_controls )
+       /* if the subordinate database has overlays, the bi_chk_controls()
+        * hook is actually over_aux_chk_controls(); in case it actually
+        * wraps a missing hok, we need to mimic the behavior
+        * of the frontend applied to that database */
+       if ( op->o_bd->bd_info->bi_chk_controls ) {
                rc = ( *op->o_bd->bd_info->bi_chk_controls )( op, rs );
-       else
-               rc = SLAP_CB_CONTINUE;
+       }
+
+       
+       if ( rc == SLAP_CB_CONTINUE ) {
+               rc = backend_check_controls( op, rs );
+       }
 
        op->o_bd = b0;
        op->o_bd->bd_info = bi0;
index 157b62343546236c2580b64ea2ec7f19b6f766e4..bfb41fb18f4fd86888821615c460ba2305bb8ea8 100644 (file)
@@ -264,6 +264,9 @@ LDAP_SLAPD_F (int) backend_unbind LDAP_P((Operation *op, SlapReply *rs));
 LDAP_SLAPD_F (int) backend_connection_init LDAP_P((Connection *conn));
 LDAP_SLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn));
 
+LDAP_SLAPD_F( int ) backend_check_controls LDAP_P((
+       Operation *op,
+       SlapReply *rs ));
 LDAP_SLAPD_F( int )    backend_check_restrictions LDAP_P((
        Operation *op,
        SlapReply *rs,