]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
fix ITS#3406 wrt/ dnattr; silence warning
[openldap] / servers / slapd / controls.c
index 8d0114917245a9cce44f0e43a217d687f8d4ee76..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),
@@ -115,7 +115,7 @@ static struct slap_control control_defs[] = {
 #ifdef LDAP_CONTROL_X_DOMAIN_SCOPE
        { LDAP_CONTROL_X_DOMAIN_SCOPE,
                (int)offsetof(struct slap_control_ids, sc_domainScope),
-               SLAP_CTRL_FRONTEND|SLAP_CTRL_SEARCH, NULL,
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_SEARCH, NULL,
                parseDomainScope, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
@@ -133,7 +133,7 @@ static struct slap_control control_defs[] = {
 #ifdef LDAP_CONTORL_X_SEARCH_OPTIONS
        { LDAP_CONTORL_X_SEARCH_OPTIONS,
                (int)offsetof(struct slap_control_ids, sc_searchOptions),
-               SLAP_CTRL_FRONTEND|SLAP_CTRL_SEARCH, NULL,
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_SEARCH, NULL,
                parseSearchOptions, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
 #ifdef LDAP_CONTROL_SUBENTRIES
@@ -158,7 +158,7 @@ static struct slap_control control_defs[] = {
                parseManageDSAit, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_PROXY_AUTHZ,
                (int)offsetof(struct slap_control_ids, sc_proxyAuthz),
-               SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS, proxy_authz_extops,
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS, proxy_authz_extops,
                parseProxyAuthz, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { NULL, 0, 0, NULL, 0, LDAP_SLIST_ENTRY_INITIALIZER(next) }
 };
@@ -380,6 +380,35 @@ slap_find_control_id(
        return LDAP_CONTROL_NOT_FOUND;
 }
 
+int
+slap_global_control( Operation *op, const char *oid, int *cid )
+{
+       struct slap_control *ctrl = find_ctrl( oid );
+
+       if ( ctrl == NULL ) {
+               /* should not be reachable */
+               Debug( LDAP_DEBUG_ANY,
+                       "slap_global_control: unrecognized control: %s\n",      
+                       oid, 0, 0 );
+               return LDAP_CONTROL_NOT_FOUND;
+       }
+
+       if ( cid ) *cid = ctrl->sc_cid;
+
+       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_TRACE,
+               "slap_global_control: unavailable control: %s\n",      
+               oid, 0, 0 );
+
+       return LDAP_COMPARE_FALSE;
+}
+
 void slap_free_ctrls(
        Operation *op,
        LDAPControl **ctrls )
@@ -612,17 +641,6 @@ int get_ctrls(
                                        goto return_results;
                                }
 
-                               if ( sc->sc_mask & SLAP_CTRL_FRONTEND ) {
-                                       /* kludge to disable backend_control() check */
-                                       c->ldctl_iscritical = 0;
-
-                               } else if ( tagmask == SLAP_CTRL_SEARCH &&
-                                       sc->sc_mask & SLAP_CTRL_FRONTEND_SEARCH )
-                               {
-                                       /* kludge to disable backend_control() check */
-                                       c->ldctl_iscritical = 0;
-                               }
-
                        } else if( c->ldctl_iscritical ) {
                                /* unavailable CRITICAL control */
                                rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
@@ -1173,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;
@@ -1184,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;
 }