From deeafb04f1c6d634ca408f555f977e64a2660a6a Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 18 Nov 2009 02:27:47 +0000
Subject: [PATCH] ITS#6367

---
 CHANGES                  | 1 +
 servers/slapd/syncrepl.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/CHANGES b/CHANGES
index 8c96c2916d..08a3c6ab62 100644
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,7 @@ OpenLDAP 2.4.20 Engineering
 	Fixed slapd invalid dn log message (ITS#6309)
 	Fixed slapd lockup on shutdown (ITS#6372)
 	Fixed slapd sl_free to better reclaim memory (ITS#6380)
+	Fixed slapd syncrepl to use correct SID (ITS#6367)
 	Fixed slapd termination for one level DNs (ITS#6338)
 	Fixed slapd tls_accept to retry in certain cases (ITS#6304)
 	Fixed slapd unused parameter (ITS#6356)
diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c
index 4933933935..9b6d4d3c00 100644
--- a/servers/slapd/syncrepl.c
+++ b/servers/slapd/syncrepl.c
@@ -665,6 +665,11 @@ do_syncrep1(
 			si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
 			si->si_syncCookie.sid );
 	} else {
+		/* ITS#6367: recreate the cookie so it has our SID, not our peer's */
+		ch_free( si->si_syncCookie.octet_str.bv_val );
+		slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
+			si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
+			si->si_syncCookie.sid );
 		/* Look for contextCSN from syncprov overlay. */
 		check_syncprov( op, si );
 	}
-- 
GitLab