]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
IANA Assigned OIDs
[openldap] / servers / slapd / controls.c
index 341d7ab962f4c3765aa1c3e042e9a6167df359c1..61bc21e0dc6b03552fe0046808bb8e2414fd54e3 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,6 @@ static SLAP_CTRL_PARSE_FN parsePreRead;
 static SLAP_CTRL_PARSE_FN parsePostRead;
 static SLAP_CTRL_PARSE_FN parseProxyAuthz;
 static SLAP_CTRL_PARSE_FN parseManageDSAit;
-static SLAP_CTRL_PARSE_FN parseModifyIncrement;
 static SLAP_CTRL_PARSE_FN parseNoOp;
 static SLAP_CTRL_PARSE_FN parsePagedResults;
 static SLAP_CTRL_PARSE_FN parseValuesReturnFilter;
@@ -80,13 +79,13 @@ static char *proxy_authz_extops[] = {
 
 static struct slap_control control_defs[] = {
        { LDAP_CONTROL_ASSERT,
-               SLAP_CTRL_HIDE|SLAP_CTRL_ACCESS, NULL,
+               SLAP_CTRL_ACCESS, NULL,
                parseAssert, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_PRE_READ,
-               SLAP_CTRL_HIDE|SLAP_CTRL_DELETE|SLAP_CTRL_MODIFY|SLAP_CTRL_RENAME, NULL,
+               SLAP_CTRL_DELETE|SLAP_CTRL_MODIFY|SLAP_CTRL_RENAME, NULL,
                parsePreRead, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_POST_READ,
-               SLAP_CTRL_HIDE|SLAP_CTRL_ADD|SLAP_CTRL_MODIFY|SLAP_CTRL_RENAME, NULL,
+               SLAP_CTRL_ADD|SLAP_CTRL_MODIFY|SLAP_CTRL_RENAME, NULL,
                parsePostRead, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_VALUESRETURNFILTER,
                SLAP_CTRL_SEARCH, NULL,
@@ -125,11 +124,6 @@ static struct slap_control control_defs[] = {
        { LDAP_CONTROL_SYNC,
                SLAP_CTRL_HIDE|SLAP_CTRL_SEARCH, NULL,
                parseLDAPsync, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#ifdef LDAP_CONTROL_MODIFY_INCREMENT
-       { LDAP_CONTROL_MODIFY_INCREMENT,
-               SLAP_CTRL_HIDE|SLAP_CTRL_MODIFY, NULL,
-               parseModifyIncrement, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#endif
        { LDAP_CONTROL_MANAGEDSAIT,
                SLAP_CTRL_ACCESS, NULL,
                parseManageDSAit, LDAP_SLIST_ENTRY_INITIALIZER(next) },
@@ -664,32 +658,6 @@ return_results:
        return rs->sr_err;
 }
 
-static int parseModifyIncrement (
-       Operation *op,
-       SlapReply *rs,
-       LDAPControl *ctrl )
-{
-#if 0
-       if ( op->o_modifyIncrement != SLAP_NO_CONTROL ) {
-               rs->sr_text = "modifyIncrement control specified multiple times";
-               return LDAP_PROTOCOL_ERROR;
-       }
-#endif
-
-       if ( ctrl->ldctl_value.bv_len ) {
-               rs->sr_text = "modifyIncrement control value not empty";
-               return LDAP_PROTOCOL_ERROR;
-       }
-
-#if 0
-       op->o_modifyIncrement = ctrl->ldctl_iscritical
-               ? SLAP_CRITICAL_CONTROL
-               : SLAP_NONCRITICAL_CONTROL;
-#endif
-
-       return LDAP_SUCCESS;
-}
-
 static int parseManageDSAit (
        Operation *op,
        SlapReply *rs,
@@ -844,10 +812,11 @@ static int parsePagedResults (
        SlapReply *rs,
        LDAPControl *ctrl )
 {
-       ber_tag_t tag;
-       ber_int_t size;
-       BerElement *ber;
-       struct berval cookie = BER_BVNULL;
+       int             rc = LDAP_SUCCESS;
+       ber_tag_t       tag;
+       ber_int_t       size;
+       BerElement      *ber;
+       struct berval   cookie = BER_BVNULL;
 
        if ( op->o_pagedresults != SLAP_NO_CONTROL ) {
                rs->sr_text = "paged results control specified multiple times";
@@ -879,16 +848,17 @@ static int parsePagedResults (
        }
 
        tag = ber_scanf( ber, "{im}", &size, &cookie );
-       (void) ber_free( ber, 1 );
 
        if( tag == LBER_ERROR ) {
                rs->sr_text = "paged results control could not be decoded";
-               return LDAP_PROTOCOL_ERROR;
+               rc = LDAP_PROTOCOL_ERROR;
+               goto done;
        }
 
        if( size < 0 ) {
                rs->sr_text = "paged results control size invalid";
-               return LDAP_PROTOCOL_ERROR;
+               rc = LDAP_PROTOCOL_ERROR;
+               goto done;
        }
 
        if( cookie.bv_len ) {
@@ -896,7 +866,8 @@ static int parsePagedResults (
                if( cookie.bv_len != sizeof( reqcookie ) ) {
                        /* bad cookie */
                        rs->sr_text = "paged results cookie is invalid";
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto done;
                }
 
                AC_MEMCPY( &reqcookie, cookie.bv_val, sizeof( reqcookie ));
@@ -904,17 +875,28 @@ static int parsePagedResults (
                if ( reqcookie > op->o_pagedresults_state.ps_cookie ) {
                        /* bad cookie */
                        rs->sr_text = "paged results cookie is invalid";
-                       return LDAP_PROTOCOL_ERROR;
+                       rc = LDAP_PROTOCOL_ERROR;
+                       goto done;
 
                } else if ( reqcookie < op->o_pagedresults_state.ps_cookie ) {
                        rs->sr_text = "paged results cookie is invalid or old";
-                       return LDAP_UNWILLING_TO_PERFORM;
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
                }
 
        } else {
                /* Initial request.  Initialize state. */
+#if 0
+               if ( op->o_conn->c_pagedresults_state.ps_cookie != 0 ) {
+                       /* There's another pagedResults control on the
+                        * same connection; reject new pagedResults controls 
+                        * (allowed by RFC2696) */
+                       rs->sr_text = "paged results cookie unavailable; try later";
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto done;
+               }
+#endif
                op->o_pagedresults_state.ps_cookie = 0;
-               op->o_pagedresults_state.ps_id = NOID;
                op->o_pagedresults_state.ps_count = 0;
        }
 
@@ -939,7 +921,9 @@ static int parsePagedResults (
                op->o_pagedresults = SLAP_NONCRITICAL_CONTROL;
        }
 
-       return LDAP_SUCCESS;
+done:;
+       (void)ber_free( ber, 1 );
+       return rc;
 }
 
 static int parseAssert (
@@ -1191,8 +1175,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;