diff options
Diffstat (limited to 'src/plug-sch.c')
-rw-r--r-- | src/plug-sch.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/plug-sch.c b/src/plug-sch.c index 2e7dc35..f5fdbf4 100644 --- a/src/plug-sch.c +++ b/src/plug-sch.c @@ -61,6 +61,7 @@ #define PLUGIN_ID "schema-compat-plugin" #define PLUGIN_PREOP_ID PLUGIN_ID "-preop" #define PLUGIN_POSTOP_ID PLUGIN_ID "-postop" +#define PLUGIN_INTERNAL_POSTOP_ID PLUGIN_ID "-internal-postop" /* the module initialization function */ static Slapi_PluginDesc @@ -129,7 +130,12 @@ schema_compat_plugin_init_preop(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description); slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, global_plugin_state); - backend_init_preop(pb, global_plugin_state); + if (backend_init_preop(pb, global_plugin_state) == -1) { + slapi_log_error(SLAPI_LOG_PLUGIN, + global_plugin_state->plugin_desc->spd_id, + "error registering postoperation hooks\n"); + return -1; + } return 0; } static int @@ -138,7 +144,26 @@ schema_compat_plugin_init_postop(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description); slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, global_plugin_state); - backend_init_postop(pb, global_plugin_state); + if (backend_init_postop(pb, global_plugin_state) == -1) { + slapi_log_error(SLAPI_LOG_PLUGIN, + global_plugin_state->plugin_desc->spd_id, + "error registering postoperation hooks\n"); + return -1; + } + return 0; +} +static int +schema_compat_plugin_init_internal_postop(Slapi_PBlock *pb) +{ + slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); + slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description); + slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, global_plugin_state); + if (backend_init_internal_postop(pb, global_plugin_state) == -1) { + slapi_log_error(SLAPI_LOG_PLUGIN, + global_plugin_state->plugin_desc->spd_id, + "error registering internal postop hooks\n"); + return -1; + } return 0; } int @@ -159,8 +184,6 @@ schema_compat_plugin_init(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, state); /* Let the backend do its setup. */ map_init(pb, state); - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "registered plugin\n"); /* Register the sub-plugins. */ global_plugin_state = state; if (slapi_register_plugin("preoperation", TRUE, @@ -170,6 +193,7 @@ schema_compat_plugin_init(Slapi_PBlock *pb) state->plugin_identity) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "error registering preoperation plugin\n"); + return -1; } if (slapi_register_plugin("postoperation", TRUE, "schema_compat_plugin_init_postop", @@ -178,7 +202,19 @@ schema_compat_plugin_init(Slapi_PBlock *pb) state->plugin_identity) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "error registering postoperation plugin\n"); + return -1; } + if (slapi_register_plugin("internalpostoperation", TRUE, + "schema_compat_plugin_init_internal_postop", + schema_compat_plugin_init_internal_postop, + PLUGIN_INTERNAL_POSTOP_ID, NULL, + state->plugin_identity) != 0) { + slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + "error registering internal postoperation plugin\n"); + return -1; + } + slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + "registered plugin\n"); global_plugin_state = NULL; return 0; } |