]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
fix ITS#3406 wrt/ dnattr; silence warning
[openldap] / servers / slapd / controls.c
index 075cff8c1b61b328d12264df43d99b5d104bee13..7b1604468369bcb9d44e59409d36207386e2b794 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),
@@ -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 (( 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 1;
+               return LDAP_COMPARE_TRUE;
        }
 
-       Debug( LDAP_DEBUG_ANY,
+       Debug( LDAP_DEBUG_TRACE,
                "slap_global_control: unavailable control: %s\n",      
                oid, 0, 0 );
-       return 0;
+
+       return LDAP_COMPARE_FALSE;
 }
 
 void slap_free_ctrls(
@@ -640,24 +641,6 @@ int get_ctrls(
                                        goto return_results;
                                }
 
-#ifdef SLAP_CONTROL_AVAILABILITY_KLUDGE
-                               /* backend_check_controls() kludge */
-                               if ( sc->sc_mask & SLAP_CTRL_GLOBAL ) {
-                                       /* KLUDGE: disable backend_control() check */
-                                       c->ldctl_iscritical = 0;
-
-                               } else if ( tagmask == SLAP_CTRL_SEARCH &&
-                                       sc->sc_mask & SLAP_CTRL_GLOBAL_SEARCH )
-                               {
-                                       /* KLUDGE: disable backend_control() check */
-                                       c->ldctl_iscritical = 0;
-
-                               } else {
-                                       /* KLUDGE: enable backend_control() check */
-                                       c->ldctl_iscritical = 1;
-                               }
-#endif
-
                        } else if( c->ldctl_iscritical ) {
                                /* unavailable CRITICAL control */
                                rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
@@ -1208,8 +1191,8 @@ static int parseSubentries (
 
        /* FIXME: should use BER library */
        if( ( ctrl->ldctl_value.bv_len != 3 )
-               && ( ctrl->ldctl_value.bv_val[0] != 0x01 )
-               && ( ctrl->ldctl_value.bv_val[1] != 0x01 ))
+               || ( ctrl->ldctl_value.bv_val[0] != 0x01 )
+               || ( ctrl->ldctl_value.bv_val[1] != 0x01 ))
        {
                rs->sr_text = "subentries control value encoding is bogus";
                return LDAP_PROTOCOL_ERROR;
@@ -1219,8 +1202,9 @@ static int parseSubentries (
                ? SLAP_CONTROL_CRITICAL
                : SLAP_CONTROL_NONCRITICAL;
 
-       if ( (void *)(ctrl->ldctl_value.bv_val[2] != 0x00))
+       if ( (void *)(ctrl->ldctl_value.bv_val[2] != 0x00)) {
                set_subentries_visibility( op );
+       }
 
        return LDAP_SUCCESS;
 }