mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
avoid cycling twice in the control list
This commit is contained in:
parent
0056109b82
commit
cd797f8089
3 changed files with 39 additions and 25 deletions
|
|
@ -873,9 +873,9 @@ backend_check_controls(
|
|||
if( ctrls ) {
|
||||
for( ; *ctrls != NULL ; ctrls++ ) {
|
||||
int cid;
|
||||
if( slap_find_control_id( (*ctrls)->ldctl_oid, &cid ) ==
|
||||
LDAP_CONTROL_NOT_FOUND )
|
||||
{
|
||||
|
||||
switch ( slap_global_control( op, (*ctrls)->ldctl_oid, &cid ) ) {
|
||||
case LDAP_CONTROL_NOT_FOUND:
|
||||
/* unrecognized control */
|
||||
if ( (*ctrls)->ldctl_iscritical ) {
|
||||
/* should not be reachable */
|
||||
|
|
@ -884,26 +884,39 @@ backend_check_controls(
|
|||
(*ctrls)->ldctl_oid, 0, 0 );
|
||||
assert( 0 );
|
||||
}
|
||||
|
||||
} else if ( !slap_global_control( op, (*ctrls)->ldctl_oid ) &&
|
||||
!op->o_bd->be_ctrls[ cid ] )
|
||||
{
|
||||
/* Per RFC 2251 (and LDAPBIS discussions), if the control
|
||||
* is recognized and appropriate for the operation (which
|
||||
* we've already verified), then the server should make
|
||||
* use of the control when performing the operation.
|
||||
*
|
||||
* Here we find that operation extended by the control
|
||||
* is not unavailable in a particular context, hence the
|
||||
* return of unwillingToPerform.
|
||||
*/
|
||||
rs->sr_text = "control unavailable in context";
|
||||
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
|
||||
break;
|
||||
|
||||
case LDAP_COMPARE_FALSE:
|
||||
if ( !op->o_bd->be_ctrls[ cid ] )
|
||||
{
|
||||
/* Per RFC 2251 (and LDAPBIS discussions), if the control
|
||||
* is recognized and appropriate for the operation (which
|
||||
* we've already verified), then the server should make
|
||||
* use of the control when performing the operation.
|
||||
*
|
||||
* Here we find that operation extended by the control
|
||||
* is not unavailable in a particular context, hence the
|
||||
* return of unwillingToPerform.
|
||||
*/
|
||||
rs->sr_text = "control unavailable in context";
|
||||
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
||||
case LDAP_COMPARE_TRUE:
|
||||
break;
|
||||
|
||||
default:
|
||||
/* unreachable */
|
||||
rs->sr_err = "unable to check control";
|
||||
rs->sr_err = LDAP_OTHER;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:;
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ slap_find_control_id(
|
|||
}
|
||||
|
||||
int
|
||||
slap_global_control( Operation *op, const char *oid )
|
||||
slap_global_control( Operation *op, const char *oid, int *cid )
|
||||
{
|
||||
struct slap_control *ctrl = find_ctrl( oid );
|
||||
|
||||
|
|
@ -390,22 +390,23 @@ slap_global_control( Operation *op, const char *oid )
|
|||
Debug( LDAP_DEBUG_ANY,
|
||||
"slap_global_control: unrecognized control: %s\n",
|
||||
oid, 0, 0 );
|
||||
assert( 0 );
|
||||
return 0;
|
||||
return LDAP_CONTROL_NOT_FOUND;
|
||||
}
|
||||
|
||||
if ( ctrl->sc_mask & SLAP_CTRL_GLOBAL ) return 1;
|
||||
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 ))
|
||||
{
|
||||
return 1;
|
||||
return LDAP_COMPARE_TRUE;
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"slap_global_control: unavailable control: %s\n",
|
||||
oid, 0, 0 );
|
||||
return 0;
|
||||
return LDAP_COMPARE_FALSE;
|
||||
}
|
||||
|
||||
void slap_free_ctrls(
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ LDAP_SLAPD_F (int) get_supported_controls LDAP_P ((
|
|||
LDAP_SLAPD_F (int) slap_find_control_id LDAP_P ((
|
||||
const char *oid, int *cid ));
|
||||
LDAP_SLAPD_F (int) slap_global_control LDAP_P ((
|
||||
Operation *op, const char *oid ));
|
||||
Operation *op, const char *oid, int *cid ));
|
||||
|
||||
/*
|
||||
* config.c
|
||||
|
|
|
|||
Loading…
Reference in a new issue