summaryrefslogtreecommitdiffstats
path: root/src/plug-nis.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-12-03 16:06:36 -0500
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-12-03 16:06:36 -0500
commit5f0bf222e0e11fa3265b02a993653ebd400018c3 (patch)
treefaed59d8d6541851c6ee20765adf0860b29ab4e1 /src/plug-nis.c
parentcd84215d4d2907ddfae0b560ae8adfe40bc5f1cf (diff)
downloadslapi-nis-5f0bf222e0e11fa3265b02a993653ebd400018c3.tar.gz
slapi-nis-5f0bf222e0e11fa3265b02a993653ebd400018c3.tar.xz
slapi-nis-5f0bf222e0e11fa3265b02a993653ebd400018c3.zip
- give callback registration the ability to return errors
- make the nis plugin register two types of internal plugins, since it can't just be a postop plugin any more
Diffstat (limited to 'src/plug-nis.c')
-rw-r--r--src/plug-nis.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/src/plug-nis.c b/src/plug-nis.c
index 6f911d1..ae01984 100644
--- a/src/plug-nis.c
+++ b/src/plug-nis.c
@@ -59,6 +59,10 @@
#include "portmap.h"
#include "wrap.h"
+#define PLUGIN_ID "nis-server-plugin"
+#define PLUGIN_POSTOP_ID PLUGIN_ID "-postop"
+#define PLUGIN_INTERNAL_POSTOP_ID PLUGIN_ID "-internal-postop"
+
/* the module initialization function */
static Slapi_PluginDesc
plugin_description = {
@@ -67,6 +71,7 @@ plugin_description = {
.spd_version = PACKAGE_VERSION,
.spd_description = "NIS Server Plugin",
};
+static struct plugin_state *global_plugin_state;
/* Populate the map cache, register with the local portmapper, and then start
* the plugin's work thread to answer requests using the cache. */
@@ -411,6 +416,34 @@ failed:
return -1;
}
+static int
+nis_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);
+ 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
+nis_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
nis_plugin_init(Slapi_PBlock *pb)
{
@@ -427,11 +460,30 @@ nis_plugin_init(Slapi_PBlock *pb)
slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, &plugin_startup);
slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, &plugin_shutdown);
slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, state);
- /* Let the map cache initialize itself and let the backend do its
- * registration. */
+ /* Let the map cache initialize itself. */
map_init(pb, state);
- backend_init(pb, state);
+ /* Register the sub-plugins. */
+ global_plugin_state = state;
+ if (slapi_register_plugin("postoperation", TRUE,
+ "nis_plugin_init_postop",
+ nis_plugin_init_postop,
+ PLUGIN_POSTOP_ID, NULL,
+ 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,
+ "nis_plugin_init_internal_postop",
+ nis_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 hooks\n");
+ global_plugin_state = NULL;
return 0;
}