From 8635444b3019ac4ca9fc892cdf6b69b988a53180 Mon Sep 17 00:00:00 2001 From: root Date: Apr 22 2020 15:57:05 +0000 Subject: Ticket 51024 - syncrepl_entry callback does not contain attributes added by postoperation plugins Bug: Changes by internal operations were not handled by the sync repl plugin Fix: Register sync repl postop functions also for internal ops Reviewed by: xAThierry, thanks --- diff --git a/ldap/servers/plugins/sync/sync.h b/ldap/servers/plugins/sync/sync.h index 6253428..a6b54a6 100644 --- a/ldap/servers/plugins/sync/sync.h +++ b/ldap/servers/plugins/sync/sync.h @@ -24,6 +24,7 @@ #define SYNC_PLUGIN_SUBSYSTEM "content-sync-plugin" #define SYNC_PREOP_DESC "content-sync-preop-subplugin" #define SYNC_POSTOP_DESC "content-sync-postop-subplugin" +#define SYNC_INT_POSTOP_DESC "content-sync-int-postop-subplugin" #define OP_FLAG_SYNC_PERSIST 0x01 diff --git a/ldap/servers/plugins/sync/sync_init.c b/ldap/servers/plugins/sync/sync_init.c index 4919681..2843b88 100644 --- a/ldap/servers/plugins/sync/sync_init.c +++ b/ldap/servers/plugins/sync/sync_init.c @@ -14,6 +14,7 @@ static int sync_start(Slapi_PBlock *pb); static int sync_close(Slapi_PBlock *pb); static int sync_preop_init(Slapi_PBlock *pb); static int sync_postop_init(Slapi_PBlock *pb); +static int sync_internal_postop_init(Slapi_PBlock *pb); int sync_init(Slapi_PBlock *pb) @@ -78,6 +79,22 @@ sync_init(Slapi_PBlock *pb) } } + if (rc == 0) { + char *plugin_type = "internalpostoperation"; + /* the config change checking post op */ + if (slapi_register_plugin(plugin_type, + 1, /* Enabled */ + "sync_init", /* this function desc */ + sync_internal_postop_init, /* init func for post op */ + SYNC_INT_POSTOP_DESC, /* plugin desc */ + NULL, + plugin_identity)) { + slapi_log_err(SLAPI_LOG_ERR, SYNC_PLUGIN_SUBSYSTEM, + "sync_init - Failed to register internal postop plugin\n"); + rc = 1; + } + } + return (rc); } @@ -105,6 +122,17 @@ sync_postop_init(Slapi_PBlock *pb) return (rc); } +static int +sync_internal_postop_init(Slapi_PBlock *pb) +{ + int rc; + rc = slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, (void *)sync_add_persist_post_op); + rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, (void *)sync_del_persist_post_op); + rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN, (void *)sync_mod_persist_post_op); + rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN, (void *)sync_modrdn_persist_post_op); + return (rc); +} + /* sync_start --------------