/* Initialize the legacy replication plugin */ int replication_legacy_plugin_init(Slapi_PBlock *pb) { static int legacy_initialised= 0; int rc= 0; /* OK */ void *identity = NULL; slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &identity); PR_ASSERT (identity); repl_set_plugin_identity (PLUGIN_LEGACY_REPLICATION, identity); if(rc==0 && !legacy_initialised) { rc= slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&legacydesc ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) legacy_start ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) legacy_stop ); rc= slapi_pblock_set( pb, SLAPI_PLUGIN_POSTSTART_FN, (void *) legacy_poststart ); /* Register the plugin interfaces we implement */ rc= slapi_register_plugin("preoperation", 1 /* Enabled */, "legacy_preop_init", legacy_preop_init, "Legacy replication preoperation plugin", NULL, identity); rc= slapi_register_plugin("postoperation", 1 /* Enabled */, "legacy_postop_init", legacy_postop_init, "Legacy replication postoperation plugin", NULL, identity); rc= slapi_register_plugin("internalpreoperation", 1 /* Enabled */, "legacy_internalpreop_init", legacy_internalpreop_init, "Legacy replication internal preoperation plugin", NULL, identity); rc= slapi_register_plugin("internalpostoperation", 1 /* Enabled */, "legacy_internalpostop_init", legacy_internalpostop_init, "Legacy replication internal postoperation plugin", NULL, identity); rc= slapi_register_plugin("entry", 1 /* Enabled */, "legacy_entry_init", legacy_entry_init, "Legacy replication entry plugin", NULL, identity); legacy_initialised= 1; } return rc; }
/* Master init function for the account plugin */ int acct_policy_init( Slapi_PBlock *pb ) { void *plugin_id; int enabled; slapi_pblock_get(pb, SLAPI_PLUGIN_ENABLED, &enabled); if (!enabled) { /* not enabled */ return( CALLBACK_OK ); } if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&plugin_desc ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *)&acct_policy_close ) != 0 || slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *)acct_policy_start ) != 0 ) { slapi_log_err(SLAPI_LOG_ERR, PLUGIN_NAME, "acct_policy_init - Registration failed\n" ); return( CALLBACK_ERR ); } if( slapi_pblock_get( pb, SLAPI_PLUGIN_IDENTITY, &plugin_id ) != 0 ) { slapi_log_err(SLAPI_LOG_ERR, PLUGIN_NAME, "acct_policy_init - Failed to get plugin identity\n" ); return( CALLBACK_ERR ); } set_identity( plugin_id ); /* Register the pre and postop plugins */ if( slapi_register_plugin("preoperation", 1, "acct_preop_init", acct_preop_init, PRE_PLUGIN_DESC, NULL, plugin_id) != 0 || slapi_register_plugin("postoperation", 1, "acct_postop_init", acct_postop_init, POST_PLUGIN_DESC, NULL, plugin_id) != 0 ) { slapi_log_err(SLAPI_LOG_ERR, PLUGIN_NAME, "acct_policy_init - Failed to register callbacks\n" ); return( CALLBACK_ERR ); } return( CALLBACK_OK ); }
/* * Register USN plugin * Note: USN counter initialization is done in the backend (ldbm_usn_init). */ int usn_init(Slapi_PBlock *pb) { int rc = 0; void *identity = NULL; Slapi_Entry *plugin_entry = NULL; int is_betxn = 0; const char *plugintype; slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "--> usn_init\n"); slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity); if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) && plugin_entry) { is_betxn = slapi_entry_attr_get_bool(plugin_entry, "nsslapd-pluginbetxn"); } /* slapi_register_plugin always returns SUCCESS (0) */ if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc) != 0) { slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM, "usn_init: failed to register version & description\n"); rc = -1; goto bail; } if (slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *)usn_start) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, (void *)usn_close) != 0 ) { slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM, "usn_init: failed to register close callback & task\n"); rc = -1; goto bail; } /* usn_preop_init: plugintype is preoperation (not be/betxn) */ plugintype = "preoperation"; rc = slapi_register_plugin(plugintype, 1 /* Enabled */, "usn_preop_init", usn_preop_init, "USN preoperation plugin", NULL, identity); /* usn_bepreop_init: plugintype is bepreoperation (not betxn) */ plugintype = "bepreoperation"; rc |= slapi_register_plugin(plugintype, 1 /* Enabled */, "usn_bepreop_init", usn_bepreop_init, "USN bepreoperation plugin", NULL, identity); /* usn_bepreop_init: plugintype is betxnpreoperation */ plugintype = "betxnpreoperation"; rc |= slapi_register_plugin(plugintype, 1 /* Enabled */, "usn_betxnpreop_init", usn_betxnpreop_init, "USN betxnpreoperation plugin", NULL, identity); plugintype = "bepostoperation"; if (is_betxn) { plugintype = "betxnpostoperation"; } rc |= slapi_register_plugin(plugintype, 1 /* Enabled */, "usn_bepostop_init", usn_bepostop_init, "USN bepostoperation plugin", NULL, identity); usn_set_identity(identity); bail: slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "<-- usn_init\n"); return rc; }
int ipa_topo_init(Slapi_PBlock *pb) { int rc = 0; void *ipa_topo_plugin_identity = NULL; slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "--> ipa_topo_init\n"); /** * Store the plugin identity for later use. * Used for internal operations */ slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &ipa_topo_plugin_identity); ipa_topo_set_plugin_id(ipa_topo_plugin_identity); if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *)ipa_topo_start) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, (void *)ipa_topo_close) != 0 || slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *) &pdesc) != 0) { slapi_log_error(SLAPI_LOG_FATAL, IPA_TOPO_PLUGIN_SUBSYSTEM, "ipa_topo_init: failed to register plugin\n"); rc = 1; } if (rc == 0) { char *plugin_type = "bepreoperation"; if (slapi_register_plugin(plugin_type, 1, "ipa_topo_init", ipa_topo_preop_init, IPA_TOPO_PREOP_DESC, NULL, ipa_topo_get_plugin_id())) { slapi_log_error(SLAPI_LOG_FATAL, IPA_TOPO_PLUGIN_SUBSYSTEM, "ipa_topo_init: failed to register preop plugin\n"); rc = 1; } } if (rc == 0) { char *plugin_type = "postoperation"; if (slapi_register_plugin(plugin_type, 1, "ipa_topo_init", ipa_topo_postop_init, IPA_TOPO_POSTOP_DESC, NULL, ipa_topo_get_plugin_id())) { slapi_log_error(SLAPI_LOG_FATAL, IPA_TOPO_PLUGIN_SUBSYSTEM, "ipa_topo_init: failed to register postop plugin\n"); rc = 1; } } if (rc == 0) { char *plugin_type = "internalpostoperation"; if (slapi_register_plugin(plugin_type, 1, "ipa_topo_internal_init", ipa_topo_internal_postop_init, IPA_TOPO_INTERNAL_POSTOP_DESC, NULL, ipa_topo_get_plugin_id())) { slapi_log_error(SLAPI_LOG_FATAL, IPA_TOPO_PLUGIN_SUBSYSTEM, "ipa_topo_init: failed to register internal postop plugin\n"); rc = 1; } } slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM, "<-- ipa_topo_init\n"); return(rc); }