summaryrefslogtreecommitdiffstats
path: root/src/plug-nis.c
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2012-08-31 14:42:05 -0700
committerNalin Dahyabhai <nalin@redhat.com>2012-10-16 16:18:34 -0400
commitc5bfff6c6e6ae5e255b2432be1ed8790a6c07e82 (patch)
tree1595673b93e151bdb2782717a62e2dcdf790679d /src/plug-nis.c
parent375c82e0cfc3d7494ddf63610353da30a77b4491 (diff)
downloadslapi-nis-c5bfff6c6e6ae5e255b2432be1ed8790a6c07e82.tar.gz
slapi-nis-c5bfff6c6e6ae5e255b2432be1ed8790a6c07e82.tar.xz
slapi-nis-c5bfff6c6e6ae5e255b2432be1ed8790a6c07e82.zip
make NIS Plugin and Schema Compatibility Plugin betxn aware
When NIS Plugin and Schema Compatibility Plugin config entries include nsslapd-pluginbetxn: on (the value could be yes, true or 1, too), the plugins' update callbacks (add, delete, modify, and modrdn) are called at the betxn pre/postop timing. By default, the value of nsslapd-pluginbetxn is off. (See also https://fedorahosted.org/389/ticket/351)
Diffstat (limited to 'src/plug-nis.c')
-rw-r--r--src/plug-nis.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/plug-nis.c b/src/plug-nis.c
index 4c7ba98..201ba4e 100644
--- a/src/plug-nis.c
+++ b/src/plug-nis.c
@@ -482,6 +482,18 @@ int
nis_plugin_init(Slapi_PBlock *pb)
{
struct plugin_state *state = NULL;
+ Slapi_Entry *plugin_entry = NULL;
+ int is_betxn = 0;
+ char *plugin_type = "postoperation";
+
+ /* get args */
+ 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");
+ plugin_type = "betxnpostoperation";
+ }
+
/* Allocate the module-global data and set up listening sockets. */
if (plugin_state_init(pb, &state) == -1) {
slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id,
@@ -498,7 +510,7 @@ nis_plugin_init(Slapi_PBlock *pb)
slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, state);
/* Register the sub-plugins. */
global_plugin_state = state;
- if (slapi_register_plugin("postoperation", TRUE,
+ if (slapi_register_plugin(plugin_type, TRUE,
"nis_plugin_init_postop",
nis_plugin_init_postop,
PLUGIN_POSTOP_ID, NULL,
@@ -507,14 +519,18 @@ nis_plugin_init(Slapi_PBlock *pb)
"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;
+ if (!is_betxn) {
+ /* if betxn is on, the plugin is called inside of backend transaction,
+ * which does not distinguish the internal operation. */
+ 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");