]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
Happy New Year
[openldap] / servers / slapd / controls.c
index 13f0a6eabd96806ec2dedb8da44985d401206cbc..5599bd7b9d23092d2976390edb9a9297176a302a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2014 The OpenLDAP Foundation.
+ * Copyright 1998-2018 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,9 @@ static SLAP_CTRL_PARSE_FN parseSessionTracking;
 #ifdef SLAP_CONTROL_X_WHATFAILED
 static SLAP_CTRL_PARSE_FN parseWhatFailed;
 #endif
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+static SLAP_CTRL_PARSE_FN parseLazyCommit;
+#endif
 
 #undef sc_mask /* avoid conflict with Irix 6.5 <sys/signal.h> */
 
@@ -226,6 +229,13 @@ static struct slap_control control_defs[] = {
                NULL, NULL,
                parseWhatFailed, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+       { LDAP_CONTROL_X_LAZY_COMMIT,
+               (int)offsetof(struct slap_control_ids, sc_lazyCommit),
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE,
+               NULL, NULL,
+               parseLazyCommit, LDAP_SLIST_ENTRY_INITIALIZER(next) },
+#endif
 
        { NULL, 0, 0, NULL, 0, NULL, LDAP_SLIST_ENTRY_INITIALIZER(next) }
 };
@@ -304,6 +314,7 @@ register_supported_control2(const char *controloid,
        if ( sc == NULL ) {
                sc = (struct slap_control *)SLAP_MALLOC( sizeof( *sc ) );
                if ( sc == NULL ) {
+                       ber_bvarray_free( extendedopsbv );
                        return LDAP_NO_MEMORY;
                }
 
@@ -565,6 +576,29 @@ void slap_free_ctrls(
 {
        int i;
 
+       if( ctrls == op->o_ctrls ) {
+               if( op->o_assertion != NULL ) {
+                       filter_free_x( op, op->o_assertion, 1 );
+                       op->o_assertion = NULL;
+               }
+               if( op->o_vrFilter != NULL) {
+                       vrFilter_free( op, op->o_vrFilter );
+                       op->o_vrFilter = NULL;
+               }
+               if( op->o_preread_attrs != NULL ) {
+                       op->o_tmpfree( op->o_preread_attrs, op->o_tmpmemctx );
+                       op->o_preread_attrs = NULL;
+               }
+               if( op->o_postread_attrs != NULL ) {
+                       op->o_tmpfree( op->o_postread_attrs, op->o_tmpmemctx );
+                       op->o_postread_attrs = NULL;
+               }
+               if( op->o_pagedresults_state != NULL ) {
+                       op->o_tmpfree( op->o_pagedresults_state, op->o_tmpmemctx );
+                       op->o_pagedresults_state = NULL;
+               }
+       }
+
        for (i=0; ctrls[i]; i++) {
                op->o_tmpfree(ctrls[i], op->o_tmpmemctx );
        }
@@ -809,7 +843,7 @@ get_ctrls2(
 
                } else if( c->ldctl_oid == NULL ) {
                        Debug( LDAP_DEBUG_TRACE,
-                               "get_ctrls: conn %lu got emtpy OID.\n",
+                               "get_ctrls: conn %lu got empty OID.\n",
                                op->o_connid, 0, 0 );
 
                        slap_free_ctrls( op, op->o_ctrls );
@@ -1379,6 +1413,7 @@ static int parseAssert (
                }
                if( op->o_assertion != NULL ) {
                        filter_free_x( op, op->o_assertion, 1 );
+                       op->o_assertion = NULL;
                }
                return rs->sr_err;
        }
@@ -2131,3 +2166,27 @@ done:;
        return rc;
 }
 #endif
+
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+static int parseLazyCommit(
+       Operation *op,
+       SlapReply *rs,
+       LDAPControl *ctrl )
+{
+       if ( op->o_lazyCommit != SLAP_CONTROL_NONE ) {
+               rs->sr_text = "\"Lazy Commit?\" control specified multiple times";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       if ( !BER_BVISNULL( &ctrl->ldctl_value )) {
+               rs->sr_text = "\"Lazy Commit?\" control value not absent";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       op->o_lazyCommit = ctrl->ldctl_iscritical
+               ? SLAP_CONTROL_CRITICAL
+               : SLAP_CONTROL_NONCRITICAL;
+
+       return LDAP_SUCCESS;
+}
+#endif