summaryrefslogtreecommitdiffstats
path: root/src/back-shr.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/back-shr.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/back-shr.c')
-rw-r--r--src/back-shr.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/back-shr.c b/src/back-shr.c
index a2c31c9..99955b6 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -2245,26 +2245,40 @@ backend_shr_internal_delete_cb(Slapi_PBlock *pb)
int
backend_shr_postop_init(Slapi_PBlock *pb, struct plugin_state *state)
{
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN,
- backend_shr_add_cb) != 0) {
+ int addfn = SLAPI_PLUGIN_POST_ADD_FN;
+ int modfn = SLAPI_PLUGIN_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
+ int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
+ Slapi_Entry *plugin_entry = NULL;
+ char *plugin_type = NULL;
+
+ if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
+ plugin_entry &&
+ (plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
+ plugin_type && strstr(plugin_type, "betxn")) {
+ addfn = SLAPI_PLUGIN_BE_TXN_POST_ADD_FN;
+ modfn = SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN;
+ mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
+ delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
+ }
+ slapi_ch_free_string(&plugin_type);
+
+ if (slapi_pblock_set(pb, addfn, backend_shr_add_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up add callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN,
- backend_shr_modify_cb) != 0) {
+ if (slapi_pblock_set(pb, modfn, backend_shr_modify_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up modify callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN,
- backend_shr_modrdn_cb) != 0) {
+ if (slapi_pblock_set(pb, mdnfn, backend_shr_modrdn_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up modrdn callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN,
- backend_shr_delete_cb) != 0) {
+ if (slapi_pblock_set(pb, delfn, backend_shr_delete_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up delete callback\n");
return -1;
@@ -2275,26 +2289,27 @@ backend_shr_postop_init(Slapi_PBlock *pb, struct plugin_state *state)
int
backend_shr_internal_postop_init(Slapi_PBlock *pb, struct plugin_state *state)
{
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN,
- backend_shr_internal_add_cb) != 0) {
+ int addfn = SLAPI_PLUGIN_INTERNAL_POST_ADD_FN;
+ int modfn = SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN;
+ int mdnfn = SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN;
+ int delfn = SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN;
+
+ if (slapi_pblock_set(pb, addfn, backend_shr_internal_add_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up internal add callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN,
- backend_shr_internal_modify_cb) != 0) {
+ if (slapi_pblock_set(pb, modfn, backend_shr_internal_modify_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up internal modify callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN,
- backend_shr_internal_modrdn_cb) != 0) {
+ if (slapi_pblock_set(pb, mdnfn, backend_shr_internal_modrdn_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up internal modrdn callback\n");
return -1;
}
- if (slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN,
- backend_shr_internal_delete_cb) != 0) {
+ if (slapi_pblock_set(pb, delfn, backend_shr_internal_delete_cb) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"error hooking up internal delete callback\n");
return -1;