Blame SOURCES/0038-Issue-4649-crash-in-sync_repl-when-a-MODRDN-create-a.patch

3280a9
From b01e30c79b1364ac35c0b2db2ef4a2ff64600a7f Mon Sep 17 00:00:00 2001
3280a9
From: tbordaz <tbordaz@redhat.com>
3280a9
Date: Tue, 23 Feb 2021 08:58:37 +0100
3280a9
Subject: [PATCH 1/2] Issue 4649 - crash in sync_repl when a MODRDN create a
3280a9
 cenotaph (#4652)
3280a9
3280a9
Bug description:
3280a9
	When an operation is flagged OP_FLAG_NOOP, it skips BETXN plugins but calls POST plugins.
3280a9
	For sync_repl, betxn (sync_update_persist_betxn_pre_op) creates an operation extension to be
3280a9
	consumed by the post (sync_update_persist_op). In case of OP_FLAG_NOOP, there is no
3280a9
	operation extension.
3280a9
3280a9
Fix description:
3280a9
	Test that the operation is OP_FLAG_NOOP if the operation extension is missing
3280a9
3280a9
relates: https://github.com/389ds/389-ds-base/issues/4649
3280a9
3280a9
Reviewed by: William Brown (thanks)
3280a9
3280a9
Platforms tested: F31
3280a9
---
3280a9
 ldap/servers/plugins/sync/sync_persist.c      | 14 ++++-
3280a9
 2 files changed, 75 insertions(+), 2 deletions(-)
3280a9
diff --git a/ldap/servers/plugins/sync/sync_persist.c b/ldap/servers/plugins/sync/sync_persist.c
3280a9
index e93a8fa83..12b23ebac 100644
3280a9
--- a/ldap/servers/plugins/sync/sync_persist.c
3280a9
+++ b/ldap/servers/plugins/sync/sync_persist.c
3280a9
@@ -206,7 +206,9 @@ sync_update_persist_op(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eprev, ber
3280a9
     slapi_pblock_get(pb, SLAPI_TARGET_SDN, &sdn;;
3280a9
 
3280a9
     if (NULL == e) {
3280a9
-        /* Ignore this operation (for example case of failure of the operation) */
3280a9
+        /* Ignore this operation (for example case of failure of the operation
3280a9
+         * or operation resulting in an empty Mods))
3280a9
+         */
3280a9
         ignore_op_pl(pb);
3280a9
         return;
3280a9
     }
3280a9
@@ -232,7 +234,15 @@ sync_update_persist_op(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eprev, ber
3280a9
     prim_op = get_thread_primary_op();
3280a9
     ident = sync_persist_get_operation_extension(pb);
3280a9
     PR_ASSERT(prim_op);
3280a9
-    PR_ASSERT(ident);
3280a9
+
3280a9
+    if ((ident == NULL) && operation_is_flag_set(pb_op, OP_FLAG_NOOP)) {
3280a9
+        /* This happens for URP (add cenotaph, fixup rename, tombstone resurrect)
3280a9
+         * As a NOOP betxn plugins are not called and operation ext is not created
3280a9
+         */
3280a9
+        slapi_log_err(SLAPI_LOG_PLUGIN, SYNC_PLUGIN_SUBSYSTEM, "Skip noop operation (0x%lx)\n",
3280a9
+                       (ulong) pb_op);
3280a9
+        return;
3280a9
+    }
3280a9
     /* First mark the operation as completed/failed
3280a9
      * the param to be used once the operation will be pushed
3280a9
      * on the listeners queue
3280a9
-- 
3280a9
2.26.2
3280a9