]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
switch to openldap-data directory
[openldap] / servers / slapd / controls.c
index 3683e23bb5ffa889af3516f3b22e4bae6e46dfb1..459318a930213fc9ac11b3a63571cf17105c3f37 100644 (file)
 
 #include "../../libraries/liblber/lber-int.h"
 
-#define SLAP_CTRL_ABANDON      0x0001
-#define SLAP_CTRL_ADD          0x2002
-#define SLAP_CTRL_BIND         0x0004
-#define SLAP_CTRL_COMPARE      0x1008
-#define SLAP_CTRL_DELETE       0x2010
-#define SLAP_CTRL_MODIFY       0x2020
-#define SLAP_CTRL_RENAME       0x2040
-#define SLAP_CTRL_SEARCH       0x1080
-#define SLAP_CTRL_UNBIND       0x0100
+#define SLAP_CTRL_FRONTEND     0x80000000U
+
+#define SLAP_CTRL_OPFLAGS      0x0000FFFFU
+#define SLAP_CTRL_ABANDON      0x00000001U
+#define SLAP_CTRL_ADD          0x00002002U
+#define SLAP_CTRL_BIND         0x00000004U
+#define SLAP_CTRL_COMPARE      0x00001008U
+#define SLAP_CTRL_DELETE       0x00002010U
+#define SLAP_CTRL_MODIFY       0x00002020U
+#define SLAP_CTRL_RENAME       0x00002040U
+#define SLAP_CTRL_SEARCH       0x00001080U
+#define SLAP_CTRL_UNBIND       0x00000100U
 
 #define SLAP_CTRL_INTROGATE    (SLAP_CTRL_COMPARE|SLAP_CTRL_SEARCH)
 #define SLAP_CTRL_UPDATE \
@@ -42,10 +45,11 @@ typedef int (SLAP_CTRL_PARSE_FN) LDAP_P((
 
 static SLAP_CTRL_PARSE_FN parseManageDSAit;
 static SLAP_CTRL_PARSE_FN parseSubentries;
+static SLAP_CTRL_PARSE_FN parseNoOp;
 
 static struct slap_control {
        char *sc_oid;
-       int sc_ops_mask;
+       slap_mask_t sc_mask;
        char **sc_extendedops;
        SLAP_CTRL_PARSE_FN *sc_parse;
 
@@ -56,6 +60,11 @@ static struct slap_control {
        { LDAP_CONTROL_SUBENTRIES,
                SLAP_CTRL_SEARCH, NULL,
                parseSubentries },
+#ifdef LDAP_CONTROL_NOOP
+       { LDAP_CONTROL_NOOP,
+               SLAP_CTRL_UPDATE, NULL,
+               parseNoOp },
+#endif
        { NULL }
 };
 
@@ -90,7 +99,7 @@ int get_ctrls(
        LDAPControl ***ctrls = &op->o_ctrls;
        struct slap_control *c;
        int rc = LDAP_SUCCESS;
-       char *errmsg = NULL;
+       const char *errmsg = NULL;
 
        len = ber_pvt_ber_remaining(ber);
 
@@ -176,7 +185,7 @@ int get_ctrls(
                if( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                               "get_ctrls: conn %d  get OID failed.\n",
+                               "get_ctrls: conn %d get OID failed.\n",
                                conn->c_connid ));
 #else
                        Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get oid failed.\n",
@@ -198,7 +207,7 @@ int get_ctrls(
                        if( tag == LBER_ERROR ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
-                                       "get_ctrls: conn %d  get crit failed.\n",
+                                       "get_ctrls: conn %d get crit failed.\n",
                                        conn->c_connid ));
 #else
                                Debug( LDAP_DEBUG_TRACE, "=> get_ctrls: get crit failed.\n",
@@ -247,8 +256,8 @@ int get_ctrls(
 
                c = find_ctrl( tctrl->ldctl_oid );
                if( c != NULL ) {
-                       /* recongized control */
-                       int tagmask = -1;
+                       /* recognized control */
+                       slap_mask_t tagmask;
                        switch( op->o_tag ) {
                        case LDAP_REQ_ADD:
                                tagmask = SLAP_CTRL_ADD;
@@ -276,7 +285,7 @@ int get_ctrls(
                                break;
                        case LDAP_REQ_EXTENDED:
                                /* FIXME: check list of extended operations */
-                               tagmask = -1;
+                               tagmask = ~0U;
                                break;
                        default:
                                rc = LDAP_OTHER;
@@ -284,7 +293,7 @@ int get_ctrls(
                                goto return_results;
                        }
 
-                       if (( c->sc_ops_mask & tagmask ) == tagmask ) {
+                       if (( c->sc_mask & tagmask ) == tagmask ) {
                                /* available extension */
 
                                if( !c->sc_parse ) {
@@ -297,6 +306,11 @@ int get_ctrls(
 
                                if( rc != LDAP_SUCCESS ) goto return_results;
 
+                               if( c->sc_mask & SLAP_CTRL_FRONTEND ) {
+                                       /* kludge to disable backend_control() check */
+                                       tctrl->ldctl_iscritical = 0;
+                               }
+
                        } else if( tctrl->ldctl_iscritical ) {
                                /* unavailable CRITICAL control */
                                rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
@@ -305,9 +319,9 @@ int get_ctrls(
                        }
 
                } else if( tctrl->ldctl_iscritical ) {
-                       /* unrecongized CRITICAL control */
+                       /* unrecognized CRITICAL control */
                        rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
-                       errmsg = "critical extension is not recongized";
+                       errmsg = "critical extension is not recognized";
                        goto return_results;
                }
 
@@ -386,4 +400,28 @@ static int parseSubentries (
        op->o_subentries_visibility = (ctrl->ldctl_value.bv_val[2] != 0x00);
 
        return LDAP_SUCCESS;
-}
\ No newline at end of file
+}
+
+static int parseNoOp (
+       Connection *conn,
+       Operation *op,
+       LDAPControl *ctrl,
+       const char **text )
+{
+       if ( op->o_noop != SLAP_NO_CONTROL ) {
+               *text = "noop control specified multiple times";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       if ( ctrl->ldctl_value.bv_len ) {
+               *text = "noop control value not empty";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       op->o_noop = ctrl->ldctl_iscritical
+               ? SLAP_CRITICAL_CONTROL
+               : SLAP_NONCRITICAL_CONTROL;
+
+       return LDAP_SUCCESS;
+}
+