summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile4
-rw-r--r--src/backend.c11
-rw-r--r--src/backend.h4
-rw-r--r--src/dummymap.c7
-rw-r--r--src/map.c9
-rw-r--r--src/map.h4
-rw-r--r--src/plugin.c15
-rw-r--r--src/plugin.h1
8 files changed, 38 insertions, 17 deletions
diff --git a/src/Makefile b/src/Makefile
index b8f9f88..dc2b23a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,9 +3,9 @@ LDFLAGS = -lnsl -lpthread
all:: plugin.so dummyplugin.so portmap
-plugin.so: backend.c dispatch.c map.c nis.c plugin.c portmap.c defaults.h
+plugin.so: backend.c dispatch.c map.c nis.c plugin.c plugin.h portmap.c defaults.h
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS)
-dummyplugin.so: dispatch.c dummymap.c nis.c plugin.c portmap.c
+dummyplugin.so: dispatch.c dummymap.c nis.c plugin.c plugin.h portmap.c
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS)
portmap: portmap.c
$(CC) $(CFLAGS) -o $@ -DPORTMAP_MAIN $^ $(LDFLAGS)
diff --git a/src/backend.c b/src/backend.c
index 9d96605..959055a 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -220,16 +220,16 @@ backend_map_config_entry_cb(Slapi_Entry *e, void *callback_data)
/* Scan for the list of configured domains and maps. */
void
-backend_init(struct plugin_state *state)
+backend_startup(struct plugin_state *state)
{
Slapi_PBlock *pb;
char *attrs = NULL;
pb = slapi_pblock_new();
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
- "searching for maps");
+ "searching \"%s\" for maps\n", state->plugin_base);
slapi_search_internal_set_pb(pb,
- "cn=NIS Server, cn=Plugins, cn=config",
+ state->plugin_base,
LDAP_SCOPE_ONE,
"(objectclass=*)",
NULL, 0,
@@ -244,3 +244,8 @@ backend_init(struct plugin_state *state)
slapi_free_search_results_internal(pb);
slapi_pblock_destroy(pb);
}
+
+void
+backend_init(struct slapi_pblock *pb, struct plugin_state *state)
+{
+}
diff --git a/src/backend.h b/src/backend.h
index 0f92a76..6bc3099 100644
--- a/src/backend.h
+++ b/src/backend.h
@@ -1,3 +1,5 @@
/* Initialize maps. */
struct plugin_state;
-void backend_init(struct plugin_state *state);
+struct slapi_pblock;
+void backend_startup(struct plugin_state *state);
+void backend_init(struct slapi_pblock *pb, struct plugin_state *state);
diff --git a/src/dummymap.c b/src/dummymap.c
index 5cb8436..104fdc6 100644
--- a/src/dummymap.c
+++ b/src/dummymap.c
@@ -64,7 +64,12 @@ struct domain domains[] = {
};
void
-map_init(struct plugin_state *state)
+map_startup(struct plugin_state *state)
+{
+}
+
+void
+map_init(struct slapi_pblock *pb, struct plugin_state *state)
{
}
diff --git a/src/map.c b/src/map.c
index dfe8fc6..0caf00c 100644
--- a/src/map.c
+++ b/src/map.c
@@ -496,7 +496,12 @@ map_data_set_entry(struct plugin_state *state,
}
void
-map_init(struct plugin_state *state)
+map_startup(struct plugin_state *state)
{
- backend_init(state);
+ backend_startup(state);
+}
+void
+map_init(struct slapi_pblock *pb, struct plugin_state *state)
+{
+ backend_init(pb, state);
}
diff --git a/src/map.h b/src/map.h
index b2836c1..ec32f4b 100644
--- a/src/map.h
+++ b/src/map.h
@@ -1,6 +1,8 @@
struct plugin_state;
+struct slapi_pblock;
/* Functions to pull data out of maps. */
-void map_init(struct plugin_state *state);
+void map_startup(struct plugin_state *state);
+void map_init(struct slapi_pblock *pb, struct plugin_state *state);
PRBool map_supports_domain(struct plugin_state *state,
const char *domain,
PRBool *supported);
diff --git a/src/plugin.c b/src/plugin.c
index 330fd02..c554eb1 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -49,13 +49,9 @@ plugin_startup(Slapi_PBlock *pb)
const char *pname;
int i, protocol;
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
- slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id,
- "plugin starting\n");
- /* Initialize the maps and data. */
- map_init(state);
- slapi_log_error(SLAPI_LOG_PLUGIN,
- plugin_description.spd_id,
- "initialized maps\n");
+ slapi_pblock_get(pb, SLAPI_TARGET_DN, &state->plugin_base);
+ /* Populate the maps and data. */
+ map_startup(state);
/* Register the listener sockets with the portmapper. */
if (state->pmap_client_socket != -1) {
for (i = 0; i < state->n_listeners; i++) {
@@ -111,6 +107,7 @@ plugin_shutdown(Slapi_PBlock *pb)
portmap_unregister(plugin_description.spd_id,
state->pmap_client_socket, YPPROG, YPVERS);
}
+ free(state);
return 0;
}
@@ -134,8 +131,10 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
goto failed;
}
state->arena = arena;
+ state->plugin_base = NULL;
state->plugin_desc = &plugin_description;
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &state->plugin_identity);
+ slapi_pblock_get(pb, SLAPI_TARGET_DN, &state->plugin_base);
/* Create a socket for use in communicating with the portmapper. */
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
@@ -264,6 +263,8 @@ 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 backend do its registration. */
+ map_init(pb, state);
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"registered plugin hooks\n");
return 0;
diff --git a/src/plugin.h b/src/plugin.h
index 3701173..0b3a653 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -12,6 +12,7 @@
struct plugin_state {
PLArenaPool *arena;
pthread_t tid;
+ char *plugin_base;
Slapi_ComponentId *plugin_identity;
Slapi_PluginDesc *plugin_desc;
int pmap_client_socket;