"ultimate" fix of glued databases controls checking; other minor fixes

This commit is contained in:
Pierangelo Masarati 2005-01-30 22:02:37 +00:00
parent e96e874a18
commit 7cd731ec56
5 changed files with 81 additions and 17 deletions

View 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;
}

View 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;

View 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;
}

View 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;

View 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,