summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-03 14:21:28 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-03 14:21:28 -0400
commitbb89666d73fbbba8717ec231d29e7d4752100c8f (patch)
tree7fd0f13fcd4646fe78f7ee9282ec2acfc35fba9f /src
parent0f642c8d2d2c9fdae20d882943308a07c8e934f5 (diff)
downloadslapi-nis-bb89666d73fbbba8717ec231d29e7d4752100c8f.tar.gz
slapi-nis-bb89666d73fbbba8717ec231d29e7d4752100c8f.tar.xz
slapi-nis-bb89666d73fbbba8717ec231d29e7d4752100c8f.zip
- handle map updates correctly now
Diffstat (limited to 'src')
-rw-r--r--src/backend.c78
1 files changed, 65 insertions, 13 deletions
diff --git a/src/backend.c b/src/backend.c
index a85abe8..f06ef2b 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -425,10 +425,6 @@ backend_map_config_entry_add_cb(Slapi_Entry *e, void *callback_data)
maps = slapi_entry_attr_get_charray(e, "map");
for (i = 0; (domains != NULL) && (domains[i] != NULL); i++) {
for (j = 0; (maps != NULL) && (maps[j] != NULL); j++) {
- slapi_log_error(SLAPI_LOG_PLUGIN,
- state->plugin_desc->spd_id,
- "initializing map %s in %s\n",
- maps[j], domains[i]);
ret = backend_map_config_entry_add_one(state, e,
domains[i],
maps[j]);
@@ -651,13 +647,14 @@ backend_entry_is_a_map(struct plugin_state *state,
Slapi_DN *entry_sdn, *plugin_sdn;
Slapi_Filter *filter;
bool_t ret;
+ char map_configuration_filter[] = MAP_CONFIGURATION_FILTER;
/* First, just do the scope test. */
entry_sdn = slapi_sdn_new_ndn_byref(slapi_entry_get_ndn(e));
if (entry_sdn == NULL) {
return FALSE;
} else {
- plugin_sdn = slapi_sdn_new_ndn_byref(state->plugin_base);
+ plugin_sdn = slapi_sdn_new_dn_byval(state->plugin_base);
if (plugin_sdn == NULL) {
slapi_sdn_free(&entry_sdn);
return FALSE;
@@ -665,7 +662,13 @@ backend_entry_is_a_map(struct plugin_state *state,
}
if (slapi_sdn_scope_test(entry_sdn,
plugin_sdn,
- LDAP_SCOPE_SUB) == 0) {
+ LDAP_SCOPE_ONE) == 0) {
+ /* Didn't match. */
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "entry \"%s\" is not a child of \"%s\"\n",
+ slapi_sdn_get_ndn(entry_sdn),
+ slapi_sdn_get_ndn(plugin_sdn));
ret = FALSE;
} else {
ret = TRUE;
@@ -675,11 +678,18 @@ backend_entry_is_a_map(struct plugin_state *state,
/* If it's actually part of our configuration tree, check if it's a
* valid entry. */
if (ret) {
- filter = slapi_str2filter(MAP_CONFIGURATION_FILTER);
+ filter = slapi_str2filter(map_configuration_filter);
if (filter != NULL) {
if (slapi_vattr_filter_test(pb, e, filter, 0) != 0) {
/* Didn't match. */
- slapi_filter_free(filter, 1);
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "entry \"%s\" doesn't look "
+ "like a map configuration "
+ "(didn't match filter "
+ "\"%s\")\n",
+ slapi_sdn_get_ndn(entry_sdn),
+ MAP_CONFIGURATION_FILTER);
ret = FALSE;
}
slapi_filter_free(filter, 1);
@@ -770,10 +780,19 @@ backend_add_cb(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &cbdata.state);
slapi_pblock_get(pb, SLAPI_ADD_TARGET, &cbdata.dn);
- slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &cbdata.e);
+ slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &cbdata.e);
cbdata.pb = pb;
slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id,
"added \"%s\"\n", cbdata.dn);
+
+ /* Check for NULL entries. */
+ if (cbdata.e == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "added entry is NULL\n");
+ return 0;
+ }
+
/* Add map entries which corresponded to this directory server
* entry. */
map_wrlock();
@@ -888,11 +907,24 @@ backend_modify_cb(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &cbdata.state);
slapi_pblock_get(pb, SLAPI_MODIFY_TARGET, &cbdata.dn);
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &cbdata.mods);
- slapi_pblock_get(pb, SLAPI_MODIFY_EXISTING_ENTRY, &cbdata.e_pre);
+ slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &cbdata.e_pre);
slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &cbdata.e_post);
cbdata.pb = pb;
slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id,
"modified \"%s\"\n", cbdata.dn);
+ /* Check for NULL entries. */
+ if (cbdata.e_pre == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "pre-modify entry is NULL\n");
+ return 0;
+ }
+ if (cbdata.e_post == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "post-modify entry is NULL\n");
+ return 0;
+ }
/* Modify map entries which corresponded to this directory server
* entry. */
map_wrlock();
@@ -917,7 +949,7 @@ backend_modify_cb(Slapi_PBlock *pb)
cbdata.state->plugin_desc->spd_id,
"modified entry \"%s\" is now a map\n",
cbdata.dn);
- backend_map_config_entry_add_cb(cbdata.e_pre, cbdata.state);
+ backend_map_config_entry_add_cb(cbdata.e_post, cbdata.state);
}
return 0;
}
@@ -1064,6 +1096,19 @@ backend_modrdn_cb(Slapi_PBlock *pb)
slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id,
"renamed \"%s\" to \"%s\"\n",
cbdata.dn_pre, cbdata.dn_post);
+ /* Check for NULL entries. */
+ if (cbdata.e_pre == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "pre-modrdn entry is NULL\n");
+ return 0;
+ }
+ if (cbdata.e_post == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "post-modrdn entry is NULL\n");
+ return 0;
+ }
/* Modify map entries which corresponded to this directory server
* entry. */
map_wrlock();
@@ -1088,7 +1133,7 @@ backend_modrdn_cb(Slapi_PBlock *pb)
cbdata.state->plugin_desc->spd_id,
"renamed entry \"%s\" is now a map\n",
cbdata.e_post);
- backend_map_config_entry_add_cb(cbdata.e_pre, cbdata.state);
+ backend_map_config_entry_add_cb(cbdata.e_post, cbdata.state);
}
map_unlock();
return 0;
@@ -1130,10 +1175,17 @@ backend_delete_cb(Slapi_PBlock *pb)
struct backend_delete_entry_cbdata cbdata;
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &cbdata.state);
slapi_pblock_get(pb, SLAPI_DELETE_TARGET, &cbdata.dn);
- slapi_pblock_get(pb, SLAPI_DELETE_EXISTING_ENTRY, &cbdata.e);
+ slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &cbdata.e);
cbdata.pb = pb;
slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id,
"deleted \"%s\"\n", cbdata.dn);
+ /* Check for NULL entries. */
+ if (cbdata.e == NULL) {
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ cbdata.state->plugin_desc->spd_id,
+ "deleted entry is NULL\n");
+ return 0;
+ }
/* Remove map entries which corresponded to this directory server
* entry. */
map_wrlock();