From 4f9b916b61cf7544d843975221ebee238c7e5a08 Mon Sep 17 00:00:00 2001
From: Pierangelo Masarati <ando@openldap.org>
Date: Sat, 29 Jan 2005 22:04:34 +0000
Subject: [PATCH] now works

---
 servers/slapd/backend.c             | 75 ++++++++++++++---------------
 servers/slapd/backover.c            | 11 ++++-
 tests/scripts/test033-glue-syncrepl |  3 --
 3 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c
index 02e41b82ad..0698243ed4 100644
--- a/servers/slapd/backend.c
+++ b/servers/slapd/backend.c
@@ -190,54 +190,20 @@ int backend_add(BackendInfo *aBackendInfo)
 	}
 }
 
-/* startup a specific backend database */
-int backend_startup_one(Backend *be)
+static int
+backend_set_controls( BackendDB *be )
 {
-	int		rc = 0;
 	BackendInfo	*bi = be->bd_info;
 
-	assert(be);
-
-	be->be_pending_csn_list = (struct be_pcl *)
-		ch_calloc( 1, sizeof( struct be_pcl ));
-
-	LDAP_TAILQ_INIT( be->be_pending_csn_list );
-
-	/* back-relay takes care of itself; so may do other */
-	if ( be->be_ctrls[ SLAP_MAX_CIDS ] == 0 ) {
-		if ( overlay_is_over( be ) ) {
-			bi = ((slap_overinfo *)be->bd_info->bi_private)->oi_orig;
-		}
-
-		if ( bi->bi_controls ) {
-			AC_MEMCPY( be->be_ctrls, bi->bi_ctrls, sizeof( be->be_ctrls ) );
-		}
-
-		be->be_ctrls[ SLAP_MAX_CIDS ] = 1;
-	}
-
-	Debug( LDAP_DEBUG_TRACE,
-		"backend_startup_one: starting \"%s\"\n",
-		be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
-		0, 0 );
-	if ( be->bd_info->bi_db_open ) {
-		rc = be->bd_info->bi_db_open( be );
-		if ( rc != 0 ) {
-			Debug( LDAP_DEBUG_ANY,
-				"backend_startup_one: bi_db_open failed! (%d)\n",
-				rc, 0, 0 );
-		}
-	}
-
 	/* back-relay takes care of itself; so may do other */
-	bi = be->bd_info;
 	if ( overlay_is_over( be ) ) {
 		bi = ((slap_overinfo *)be->bd_info->bi_private)->oi_orig;
 	}
 
 	if ( bi->bi_controls ) {
 		if ( be->be_ctrls[ SLAP_MAX_CIDS ] == 0 ) {
-			AC_MEMCPY( be->be_ctrls, bi->bi_ctrls, sizeof( be->be_ctrls ) );
+			AC_MEMCPY( be->be_ctrls, bi->bi_ctrls,
+					sizeof( be->be_ctrls ) );
 			be->be_ctrls[ SLAP_MAX_CIDS ] = 1;
 
 		} else {
@@ -245,12 +211,43 @@ int backend_startup_one(Backend *be)
 
 			for ( i = 0; i < SLAP_MAX_CIDS; i++ ) {
 				if ( bi->bi_ctrls[ i ] ) {
-					be->be_ctrls[ i ] = 1;
+					be->be_ctrls[ i ] = bi->bi_ctrls[ i ];
 				}
 			}
 		}
 	}
 
+	return 0;
+}
+
+
+/* startup a specific backend database */
+int backend_startup_one(Backend *be)
+{
+	int		rc = 0;
+
+	be->be_pending_csn_list = (struct be_pcl *)
+		ch_calloc( 1, sizeof( struct be_pcl ));
+
+	LDAP_TAILQ_INIT( be->be_pending_csn_list );
+
+	Debug( LDAP_DEBUG_TRACE,
+		"backend_startup_one: starting \"%s\"\n",
+		be->be_suffix ? be->be_suffix[0].bv_val : "(unknown)",
+		0, 0 );
+	(void)backend_set_controls( be );
+	if ( be->bd_info->bi_db_open ) {
+		rc = be->bd_info->bi_db_open( be );
+		if ( rc == 0 ) {
+			(void)backend_set_controls( be );
+
+		} else {
+			Debug( LDAP_DEBUG_ANY,
+				"backend_startup_one: bi_db_open failed! (%d)\n",
+				rc, 0, 0 );
+		}
+	}
+
 	return rc;
 }
 
diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c
index 0ab6beb4ca..9c77024a21 100644
--- a/servers/slapd/backover.c
+++ b/servers/slapd/backover.c
@@ -223,6 +223,7 @@ enum op_which {
 	op_extended,
 	op_aux_operational,
 	op_aux_chk_referrals,
+	op_aux_chk_controls,
 	op_last
 };
 
@@ -243,7 +244,8 @@ static int op_rc[] = {
 	LDAP_UNWILLING_TO_PERFORM,	/* cancel */
 	LDAP_UNWILLING_TO_PERFORM,	/* extended */
 	LDAP_SUCCESS,			/* aux_operational */
-	LDAP_SUCCESS			/* aux_chk_referrals */
+	LDAP_SUCCESS,			/* aux_chk_referrals */
+	LDAP_SUCCESS			/* aux_chk_controls */
 };
 
 static int
@@ -377,6 +379,12 @@ over_aux_chk_referrals( Operation *op, SlapReply *rs )
 	return over_op_func( op, rs, op_aux_chk_referrals );
 }
 
+static int
+over_aux_chk_controls( Operation *op, SlapReply *rs )
+{
+	return over_op_func( op, rs, op_aux_chk_controls );
+}
+
 int
 overlay_register(
 	slap_overinst *on
@@ -564,6 +572,7 @@ overlay_config( BackendDB *be, const char *ov )
 		 */
 		bi->bi_operational = over_aux_operational;
 		bi->bi_chk_referrals = over_aux_chk_referrals;
+		bi->bi_chk_controls = over_aux_chk_controls;
 
 		be->bd_info = bi;
 
diff --git a/tests/scripts/test033-glue-syncrepl b/tests/scripts/test033-glue-syncrepl
index 2bcefa1044..82e3f3b07c 100755
--- a/tests/scripts/test033-glue-syncrepl
+++ b/tests/scripts/test033-glue-syncrepl
@@ -20,9 +20,6 @@ if test $GLUE = glueno; then
 	exit 0
 fi 
 
-echo "Test temporarily disabled"
-exit 0
-
 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C
 
 echo "Running slapadd to build glued slapd databases..."
-- 
GitLab