]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
reject registrations when back-monitor is not configured
[openldap] / servers / slapd / controls.c
index 383b945e0073898b0561518b2cb717194bf6e6eb..4eddc8310b4bbbffdeb00b1ca033cf407177003f 100644 (file)
@@ -32,9 +32,6 @@ static SLAP_CTRL_PARSE_FN parseProxyAuthz;
 static SLAP_CTRL_PARSE_FN parseManageDIT;
 #endif
 static SLAP_CTRL_PARSE_FN parseManageDSAit;
-#ifdef LDAP_CONTROL_MODIFY_INCREMENT
-static SLAP_CTRL_PARSE_FN parseModifyIncrement;
-#endif
 static SLAP_CTRL_PARSE_FN parseNoOp;
 static SLAP_CTRL_PARSE_FN parsePagedResults;
 #ifdef LDAP_DEVEL
@@ -104,15 +101,15 @@ static char *proxy_authz_extops[] = {
 static struct slap_control control_defs[] = {
        {  LDAP_CONTROL_ASSERT,
                (int)offsetof(struct slap_control_ids, sc_assert),
-               SLAP_CTRL_HIDE|SLAP_CTRL_ACCESS, NULL,
+               SLAP_CTRL_ACCESS, NULL,
                parseAssert, LDAP_SLIST_ENTRY_INITIALIZER(next) },
        { LDAP_CONTROL_PRE_READ,
                (int)offsetof(struct slap_control_ids, sc_preRead),
-               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,
                (int)offsetof(struct slap_control_ids, sc_postRead),
-               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,
                (int)offsetof(struct slap_control_ids, sc_valuesReturnFilter),
@@ -162,12 +159,6 @@ static struct slap_control control_defs[] = {
                (int)offsetof(struct slap_control_ids, sc_noOp),
                SLAP_CTRL_HIDE|SLAP_CTRL_ACCESS, NULL,
                parseNoOp, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#ifdef LDAP_CONTROL_MODIFY_INCREMENT
-       { LDAP_CONTROL_MODIFY_INCREMENT,
-               (int)offsetof(struct slap_control_ids, sc_modifyIncrement),
-               SLAP_CTRL_HIDE|SLAP_CTRL_MODIFY, NULL,
-               parseModifyIncrement, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#endif
 #ifdef LDAP_DEVEL
        { LDAP_CONTROL_MANAGEDIT,
                (int)offsetof(struct slap_control_ids, sc_manageDIT),
@@ -703,33 +694,73 @@ return_results:
        return rs->sr_err;
 }
 
-#ifdef LDAP_CONTROL_MODIFY_INCREMENT
-static int parseModifyIncrement (
-       Operation *op,
-       SlapReply *rs,
-       LDAPControl *ctrl )
+int
+slap_remove_control(
+       Operation       *op,
+       SlapReply       *rs,
+       int             ctrl,
+       BI_chk_controls fnc )
 {
-#if 0
-       if ( op->o_modifyIncrement != SLAP_CONTROL_NONE ) {
-               rs->sr_text = "modifyIncrement control specified multiple times";
-               return LDAP_PROTOCOL_ERROR;
-       }
-#endif
+       int             i, j;
+
+       switch ( op->o_ctrlflag[ ctrl ] ) {
+       case SLAP_CONTROL_NONCRITICAL:
+               for ( i = 0, j = -1; op->o_ctrls[ i ] != NULL; i++ ) {
+                       if ( strcmp( op->o_ctrls[ i ]->ldctl_oid, slap_known_controls[ ctrl - 1 ] ) == 0 )
+                       {
+                               j = i;
+                       }
+               }
 
-       if ( ctrl->ldctl_value.bv_len ) {
-               rs->sr_text = "modifyIncrement control value not empty";
-               return LDAP_PROTOCOL_ERROR;
-       }
+               if ( j == -1 ) {
+                       rs->sr_err = LDAP_OTHER;
+                       break;
+               }
 
-#if 0
-       op->o_modifyIncrement = ctrl->ldctl_iscritical
-               ? SLAP_CONTROL_CRITICAL
-               : SLAP_CONTROL_NONCRITICAL;
-#endif
+               if ( fnc ) {
+                       (void)fnc( op, rs );
+               }
 
-       return LDAP_SUCCESS;
+               op->o_tmpfree( op->o_ctrls[ j ], op->o_tmpmemctx );
+
+               if ( i > 1 ) {
+                       AC_MEMCPY( &op->o_ctrls[ j ], &op->o_ctrls[ j + 1 ],
+                               ( i - j ) * sizeof( LDAPControl * ) );
+
+               } else {
+                       op->o_tmpfree( op->o_ctrls, op->o_tmpmemctx );
+                       op->o_ctrls = NULL;
+               }
+
+               op->o_ctrlflag[ ctrl ] = SLAP_CONTROL_IGNORED;
+
+               Debug( LDAP_DEBUG_ANY, "%s: "
+                       "non-critical control \"%s\" not supported; stripped.\n",
+                       op->o_log_prefix, slap_known_controls[ ctrl ], 0 );
+               /* fall thru */
+
+       case SLAP_CONTROL_IGNORED:
+       case SLAP_CONTROL_NONE:
+               rs->sr_err = SLAP_CB_CONTINUE;
+               break;
+
+       case SLAP_CONTROL_CRITICAL:
+               rs->sr_err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+               if ( fnc ) {
+                       (void)fnc( op, rs );
+               }
+               Debug( LDAP_DEBUG_ANY, "%s: "
+                       "critical control \"%s\" not supported.\n",
+                       op->o_log_prefix, slap_known_controls[ ctrl ], 0 );
+               break;
+
+       default:
+               /* handle all cases! */
+               assert( 0 );
+       }
+
+       return rs->sr_err;
 }
-#endif
 
 #ifdef LDAP_DEVEL
 static int parseManageDIT (
@@ -929,48 +960,6 @@ static int parsePagedResults (
                goto done;
        }
 
-#if 0
-       /* defer cookie decoding/checks to backend... */
-       if ( cookie.bv_len ) {
-               PagedResultsCookie reqcookie;
-               if( cookie.bv_len != sizeof( reqcookie ) ) {
-                       /* bad cookie */
-                       rs->sr_text = "paged results cookie is invalid";
-                       rc = LDAP_PROTOCOL_ERROR;
-                       goto done;
-               }
-
-               AC_MEMCPY( &reqcookie, cookie.bv_val, sizeof( reqcookie ));
-
-               if ( reqcookie > op->o_pagedresults_state.ps_cookie ) {
-                       /* bad cookie */
-                       rs->sr_text = "paged results cookie is invalid";
-                       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";
-                       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_count = 0;
-       }
-#endif
-
        ps = op->o_tmpalloc( sizeof(PagedResultsState), op->o_tmpmemctx );
        *ps = op->o_conn->c_pagedresults_state;
        ps->ps_size = size;
@@ -1370,7 +1359,7 @@ static int parseSearchOptions (
        ber_tag_t tag;
 
        if ( ctrl->ldctl_value.bv_len == 0 ) {
-               rs->sr_text = "searchOptions control value not empty";
+               rs->sr_text = "searchOptions control value is empty (or absent)";
                return LDAP_PROTOCOL_ERROR;
        }
 
@@ -1404,7 +1393,7 @@ static int parseSearchOptions (
                 * including:
                 *              LDAP_SEARCH_FLAG_PHANTOM_ROOM
                 */
-               rs->sr_text = "searchOptions contained unrecongized flag";
+               rs->sr_text = "searchOptions contained unrecognized flag";
                return LDAP_UNWILLING_TO_PERFORM;
        }