From 97fa3f1efd7c23c5e9f5f4c4af90d9df004bdb8c Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Tue, 22 Aug 2006 00:45:16 +0000
Subject: [PATCH] More LDAP_DEVEL cleanup Rename ManageDIT to Relax

---
 clients/tools/common.c        | 18 +++++++-------
 include/ldap.h                |  3 ++-
 servers/slapd/config.c        |  4 ----
 servers/slapd/controls.c      | 24 ++++++++++++-------
 servers/slapd/result.c        | 45 +----------------------------------
 servers/slapd/slap.h          |  8 +++++--
 tests/scripts/test022-ppolicy |  2 +-
 tests/scripts/test037-manage  | 18 ++------------
 8 files changed, 37 insertions(+), 85 deletions(-)

diff --git a/clients/tools/common.c b/clients/tools/common.c
index 271a133869..c6fc018af3 100644
--- a/clients/tools/common.c
+++ b/clients/tools/common.c
@@ -200,17 +200,17 @@ N_("             [!]chaining[=<resolveBehavior>[/<continuationBehavior>]]\n")
 N_("                     one of \"chainingPreferred\", \"chainingRequired\",\n")
 N_("                     \"referralsPreferred\", \"referralsRequired\"\n")
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
-#ifdef LDAP_DEVEL
-N_("             [!]manageDIT\n")
-#endif
 N_("             [!]manageDSAit\n")
 N_("             [!]noop\n")
 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
 N_("             ppolicy\n")
 #endif
 N_("             [!]postread[=<attrs>]  (a comma-separated attribute list)\n")
-N_("             [!]preread[=<attrs>]   (a comma-separated attribute list)\n"),
-N_("             abandon, cancel (SIGINT sends abandon/cancel; not really controls)\n")
+N_("             [!]preread[=<attrs>]   (a comma-separated attribute list)\n")
+#ifdef LDAP_DEVEL
+N_("             [!]relax\n")
+#endif
+N_("             abandon, cancel (SIGINT sends abandon/cancel; not really controls)\n"),
 N_("  -f file    read operations from `file'\n"),
 N_("  -h host    LDAP server\n"),
 N_("  -H URI     LDAP Uniform Resource Indentifier(s)\n"),
@@ -383,15 +383,17 @@ tool_args( int argc, char **argv )
 				proxydn = cvalue;
 #endif /* LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ */
 
-			} else if ( strcasecmp( control, "manageDIT" ) == 0 ) {
+			} else if ( ( strcasecmp( control, "relax" ) == 0 ) ||
+				( strcasecmp( control, "manageDIT" ) == 0 ) )
+			{
 				if( manageDIT ) {
 					fprintf( stderr,
-						"manageDIT control previously specified\n");
+						"relax control previously specified\n");
 					exit( EXIT_FAILURE );
 				}
 				if( cvalue != NULL ) {
 					fprintf( stderr,
-						"manageDIT: no control value expected\n" );
+						"relax: no control value expected\n" );
 					usage();
 				}
 
diff --git a/include/ldap.h b/include/ldap.h
index 38f48556ad..9562b8c37f 100644
--- a/include/ldap.h
+++ b/include/ldap.h
@@ -262,7 +262,8 @@ typedef struct ldapcontrol {
 /* various works in progress */
 #define LDAP_CONTROL_NOOP				"1.3.6.1.4.1.4203.666.5.2"
 #define LDAP_CONTROL_NO_SUBORDINATES	"1.3.6.1.4.1.4203.666.5.11"
-#define LDAP_CONTROL_MANAGEDIT			"1.3.6.1.4.1.4203.666.5.12"
+#define LDAP_CONTROL_RELAX				"1.3.6.1.4.1.4203.666.5.12"
+#define LDAP_CONTROL_MANAGEDIT			LDAP_CONTROL_RELAX
 #define LDAP_CONTROL_SLURP				"1.3.6.1.4.1.4203.666.5.13"
 #define LDAP_CONTROL_VALSORT			"1.3.6.1.4.1.4203.666.5.14"
 #define LDAP_CONTROL_DONTUSECOPY		"1.3.6.1.4.1.4203.666.5.15"
diff --git a/servers/slapd/config.c b/servers/slapd/config.c
index cbf71e3bde..5ff1c3776b 100644
--- a/servers/slapd/config.c
+++ b/servers/slapd/config.c
@@ -150,14 +150,10 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
 		snprintf( c->msg, sizeof( c->msg ), "<%s> extra cruft after <%s>",
 			c->argv[0], Conf->what );
 
-#ifdef LDAP_DEVEL
 		ignored = "";
-#endif /* LDAP_DEVEL */
 		Debug(LDAP_DEBUG_CONFIG, "%s: %s%s.\n",
 				c->log, c->msg, ignored );
-#ifdef LDAP_DEVEL
 		return(ARG_BAD_CONF);
-#endif /* LDAP_DEVEL */
 	}
 	if((arg_syn & ARG_DB) && !c->be) {
 		snprintf( c->msg, sizeof( c->msg ), "<%s> only allowed within database declaration",
diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c
index 6c61000884..431d97a36f 100644
--- a/servers/slapd/controls.c
+++ b/servers/slapd/controls.c
@@ -28,14 +28,16 @@ static SLAP_CTRL_PARSE_FN parseAssert;
 static SLAP_CTRL_PARSE_FN parsePreRead;
 static SLAP_CTRL_PARSE_FN parsePostRead;
 static SLAP_CTRL_PARSE_FN parseProxyAuthz;
-#ifdef LDAP_DEVEL
+#ifdef SLAP_DONTUSECOPY
 static SLAP_CTRL_PARSE_FN parseDontUseCopy;
+#endif
+#ifdef SLAP_RELAX
 static SLAP_CTRL_PARSE_FN parseManageDIT;
 #endif
 static SLAP_CTRL_PARSE_FN parseManageDSAit;
 static SLAP_CTRL_PARSE_FN parseNoOp;
 static SLAP_CTRL_PARSE_FN parsePagedResults;
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTEDRESULTS
 static SLAP_CTRL_PARSE_FN parseSortedResults;
 #endif
 static SLAP_CTRL_PARSE_FN parseValuesReturnFilter;
@@ -133,7 +135,7 @@ static struct slap_control control_defs[] = {
 		SLAP_CTRL_SEARCH,
 		NULL, NULL,
 		parsePagedResults, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTEDRESULTS
 	{ LDAP_CONTROL_SORTREQUEST,
  		(int)offsetof(struct slap_control_ids, sc_sortedResults),
 		SLAP_CTRL_GLOBAL|SLAP_CTRL_SEARCH|SLAP_CTRL_HIDE,
@@ -172,13 +174,15 @@ static struct slap_control control_defs[] = {
 		SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE,
 		NULL, NULL,
 		parseNoOp, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-#ifdef LDAP_DEVEL
+#ifdef SLAP_DONTUSECOPY
 	{ LDAP_CONTROL_DONTUSECOPY,
  		(int)offsetof(struct slap_control_ids, sc_dontUseCopy),
 		SLAP_CTRL_INTROGATE|SLAP_CTRL_HIDE,
 		NULL, NULL,
 		parseDontUseCopy, LDAP_SLIST_ENTRY_INITIALIZER(next) },
-	{ LDAP_CONTROL_MANAGEDIT,
+#endif
+#ifdef SLAP_RELAX
+	{ LDAP_CONTROL_RELAX,
  		(int)offsetof(struct slap_control_ids, sc_manageDIT),
 		SLAP_CTRL_GLOBAL|SLAP_CTRL_UPDATE|SLAP_CTRL_HIDE,
 		NULL, NULL,
@@ -844,7 +848,7 @@ slap_remove_control(
 	return rs->sr_err;
 }
 
-#ifdef LDAP_DEVEL
+#ifdef SLAP_DONTUSECOPY
 static int parseDontUseCopy (
 	Operation *op,
 	SlapReply *rs,
@@ -868,19 +872,21 @@ static int parseDontUseCopy (
 	op->o_dontUseCopy = SLAP_CONTROL_CRITICAL;
 	return LDAP_SUCCESS;
 }
+#endif
 
+#ifdef SLAP_RELAX
 static int parseManageDIT (
 	Operation *op,
 	SlapReply *rs,
 	LDAPControl *ctrl )
 {
 	if ( op->o_managedit != SLAP_CONTROL_NONE ) {
-		rs->sr_text = "manageDIT control specified multiple times";
+		rs->sr_text = "relax control specified multiple times";
 		return LDAP_PROTOCOL_ERROR;
 	}
 
 	if ( ctrl->ldctl_value.bv_len ) {
-		rs->sr_text = "manageDIT control value not empty";
+		rs->sr_text = "relax control value not empty";
 		return LDAP_PROTOCOL_ERROR;
 	}
 
@@ -1107,7 +1113,7 @@ done:;
 	return rc;
 }
 
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTEDRESULTS
 static int parseSortedResults (
 	Operation *op,
 	SlapReply *rs,
diff --git a/servers/slapd/result.c b/servers/slapd/result.c
index bb27c760f3..c6ec836159 100644
--- a/servers/slapd/result.c
+++ b/servers/slapd/result.c
@@ -247,7 +247,7 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
 		if( rc == -1 ) return rc;
 	}
 
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTED_RESULTS
 	/* this is a hack to avoid having to modify op->s_ctrls */
 	if( o->o_sortedresults ) {
 		BerElementBuffer berbuf;
@@ -306,7 +306,6 @@ slap_response_play(
 {
 	int rc;
 
-#ifdef LDAP_DEVEL
 	slap_callback	*sc = op->o_callback, **scp;
 
 	rc = SLAP_CB_CONTINUE;
@@ -334,27 +333,6 @@ slap_response_play(
 	}
 
 	op->o_callback = sc;
-#else /* ! LDAP_DEVEL */
-	slap_callback	*sc = op->o_callback, **sc_prev = &sc, *sc_next;
-
-	rc = SLAP_CB_CONTINUE;
-	for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
-		sc_next = op->o_callback->sc_next;
-		if ( op->o_callback->sc_response ) {
-			slap_callback *sc2 = op->o_callback;
-			rc = op->o_callback->sc_response( op, rs );
-			if ( op->o_callback != sc2 ) {
-				*sc_prev = op->o_callback;
-			}
-			if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
-			if ( op->o_callback != sc2 ) continue;
-		}
-		sc_prev = &op->o_callback->sc_next;
-	}
-
-	op->o_callback = sc;
-#endif /* ! LDAP_DEVEL */
-
 	return rc;
 }
 
@@ -363,7 +341,6 @@ slap_cleanup_play(
 	Operation *op,
 	SlapReply *rs )
 {
-#ifdef LDAP_DEVEL
 	slap_callback	*sc = op->o_callback, **scp;
 
 	for ( scp = &sc; *scp; ) {
@@ -392,26 +369,6 @@ slap_cleanup_play(
 	}
 
 	op->o_callback = sc;
-#else /* ! LDAP_DEVEL */
-	slap_callback	*sc = op->o_callback, **sc_prev = &sc, *sc_next;
-
-	for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
-		sc_next = op->o_callback->sc_next;
-		if ( op->o_callback->sc_cleanup ) {
-			slap_callback *sc2 = op->o_callback;
-			(void)op->o_callback->sc_cleanup( op, rs );
-			if ( op->o_callback != sc2 ) {
-				*sc_prev = op->o_callback;
-			}
-			if ( !op->o_callback ) break;
-			if ( op->o_callback != sc2 ) continue;
-		}
-		sc_prev = &op->o_callback->sc_next;
-	}
-
-	op->o_callback = sc;
-#endif /* ! LDAP_DEVEL */
-
 	return LDAP_SUCCESS;
 }
 
diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h
index 9177407c76..5ed8fedd58 100644
--- a/servers/slapd/slap.h
+++ b/servers/slapd/slap.h
@@ -67,8 +67,12 @@ LDAP_BEGIN_DECL
 #define LDAP_COLLECTIVE_ATTRIBUTES
 #define LDAP_COMP_MATCH
 #define LDAP_SYNC_TIMESTAMP
+
+#define SLAP_DONTUSECOPY
+#define SLAP_SORTEDRESULTS
 #endif
 
+#define SLAP_RELAX
 #define LDAP_DYNAMIC_OBJECTS
 #define SLAP_CONTROL_X_TREE_DELETE LDAP_CONTROL_X_TREE_DELETE
 #define SLAP_DISTPROC
@@ -2303,7 +2307,7 @@ struct slap_control_ids {
 	int sc_preRead;
 	int sc_proxyAuthz;
 	int sc_searchOptions;
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTEDRESULTS
 	int sc_sortedResults;
 #endif
 	int sc_subentries;
@@ -2507,7 +2511,7 @@ typedef struct slap_op {
 #define o_pagedresults_state	o_controls[slap_cids.sc_pagedResults]
 #define get_pagedresults(op)			((int)(op)->o_pagedresults)
 
-#ifdef LDAP_DEVEL
+#ifdef SLAP_SORTEDRESULTS
 #define o_sortedresults		o_ctrlflag[slap_cids.sc_sortedResults]
 #endif
 
diff --git a/tests/scripts/test022-ppolicy b/tests/scripts/test022-ppolicy
index 7f55cd09bc..de6b9fb8c8 100755
--- a/tests/scripts/test022-ppolicy
+++ b/tests/scripts/test022-ppolicy
@@ -56,7 +56,7 @@ if test $RC != 0 ; then
 fi
 
 echo "Using ldapadd to populate the database..."
-# may need -e manageDIT for draft 09, but not yet.
+# may need "-e relax" for draft 09, but not yet.
 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
 	$LDIFPPOLICY > $TESTOUT 2>&1
 RC=$?
diff --git a/tests/scripts/test037-manage b/tests/scripts/test037-manage
index f37cb39249..b50c7777da 100755
--- a/tests/scripts/test037-manage
+++ b/tests/scripts/test037-manage
@@ -56,23 +56,9 @@ if test $RC != 0 ; then
 	exit $RC
 fi
 
-# ITS#3898: #ifndef LDAP_DEVEL, the control is not available
-MANAGEDITOID="1.3.6.1.4.1.4203.666.5.12"
-case `$LDAPSEARCH -s base -b "" -h $LOCALHOST -p $PORT1 \
-	'(supportedControl:objectIdentifierMatch:='${MANAGEDITOID}')' \
-	supportedControl | grep "supportedControl: ${MANAGEDITOID}"` in
-"supportedControl: ${MANAGEDITOID}")
-	;;
-*)
-	echo "The \"manageDIT\" control appears to be unsupported; test disabled"
-	test $KILLSERVERS != no && kill -HUP $KILLPIDS
-	exit 0
-	;;
-esac
-
 echo "Testing modify, add, and delete..."
 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
-	-e \!manageDIT > \
+	-e \!relax > \
 	$TESTOUT 2>&1 << EOMODS
 version: 1
 #
@@ -150,7 +136,7 @@ fi
 
 echo "Testing modify, add, and delete..."
 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
-	-e \!manageDIT > \
+	-e \!relax > \
 	$TESTOUT 2>&1 << EOMODS
 version: 1
 #
-- 
GitLab