diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-02 18:31:59 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-02 18:31:59 -0400 |
| commit | 4469854652b9fba043d8430fe1ceb0a4f50c9c5b (patch) | |
| tree | 3a5ea86c5f7bca80d76a02ac46ee3e1486abe424 /src | |
| parent | 33385e9b68d34fc5d7c97ad7d61d05c245b32209 (diff) | |
- handle dynamic map reconfiguration (not being very clever about it)
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend.c | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/backend.c b/src/backend.c index afa2302..a85abe8 100644 --- a/src/backend.c +++ b/src/backend.c @@ -200,7 +200,7 @@ backend_copy_cb_data(const struct backend_map_data *data) * determine which value should be associated with those keys, and add them to * the map cache. */ static int -backend_map_entry_cb(Slapi_Entry *e, void *callback_data) +backend_map_config_entry_add_one_cb(Slapi_Entry *e, void *callback_data) { struct backend_map_data *data; char *key, *value, *dn, **visited_dn_list; @@ -312,7 +312,8 @@ backend_map_config_filter(const char *format, return ret; } -/* Given an entry, read the map configuration. */ +/* Given an entry, read the map configuration for the given domain and map + * name. */ static void backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, const char *domain, const char *map, @@ -362,8 +363,8 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, /* Given a directory server entry which represents a map's configuration, set * up and populate the map. */ static int -backend_map_config_entry(struct plugin_state *state, Slapi_Entry *e, - const char *domain, const char *map) +backend_map_config_entry_add_one(struct plugin_state *state, Slapi_Entry *e, + const char *domain, const char *map) { Slapi_PBlock *pb; int i; @@ -399,7 +400,7 @@ backend_map_config_entry(struct plugin_state *state, Slapi_Entry *e, 0); slapi_search_internal_callback_pb(pb, &cb_data, NULL, - backend_map_entry_cb, + backend_map_config_entry_add_one_cb, NULL); slapi_free_search_results_internal(pb); } @@ -413,7 +414,7 @@ backend_map_config_entry(struct plugin_state *state, Slapi_Entry *e, * names which are valid for this configuration and configure such a map for * each in turn. */ static int -backend_map_config_entry_cb(Slapi_Entry *e, void *callback_data) +backend_map_config_entry_add_cb(Slapi_Entry *e, void *callback_data) { char **domains, **maps; int i, j, ret; @@ -428,9 +429,9 @@ backend_map_config_entry_cb(Slapi_Entry *e, void *callback_data) state->plugin_desc->spd_id, "initializing map %s in %s\n", maps[j], domains[i]); - ret = backend_map_config_entry(state, e, - domains[i], - maps[j]); + ret = backend_map_config_entry_add_one(state, e, + domains[i], + maps[j]); } } slapi_ch_array_free(maps); @@ -550,13 +551,39 @@ backend_startup(struct plugin_state *state) map_wrlock(); slapi_search_internal_callback_pb(pb, state, NULL, - backend_map_config_entry_cb, + backend_map_config_entry_add_cb, NULL); map_unlock(); slapi_free_search_results_internal(pb); slapi_pblock_destroy(pb); } +/* Process a map configuration directory entry. Pull out the domain and map + * names which are specified in the entry and delete each in turn. */ +static int +backend_map_config_entry_delete_cb(Slapi_Entry *e, void *callback_data) +{ + char **domains, **maps; + int i, j, ret; + struct plugin_state *state; + + state = callback_data; + domains = slapi_entry_attr_get_charray(e, "domain"); + 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, + "removing map %s in %s\n", + maps[j], domains[i]); + map_data_unset_map(state, domains[i], maps[j]); + } + } + slapi_ch_array_free(maps); + slapi_ch_array_free(domains); + return 0; +} + /* Our postoperation callbacks. */ /* Given a map configuration, return true if the entry is supposed to be in the @@ -757,12 +784,13 @@ backend_add_cb(Slapi_PBlock *pb) "error adding map entries corresponding to " "\"%s\"\n", cbdata.dn); } - /* If it's a map configuration entry, add and populate the map. */ + /* If it's a map configuration entry, add and populate the maps it + * describes. */ if (backend_entry_is_a_map(cbdata.state, pb, cbdata.e)) { slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "new entry \"%s\" is a map\n", cbdata.dn); - /* XXX */ + backend_map_config_entry_add_cb(cbdata.e, cbdata.state); } map_unlock(); return 0; @@ -882,14 +910,14 @@ backend_modify_cb(Slapi_PBlock *pb) slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "modified entry \"%s\" was a map\n", cbdata.dn); - /* XXX */ + backend_map_config_entry_delete_cb(cbdata.e_pre, cbdata.state); } if (backend_entry_is_a_map(cbdata.state, pb, cbdata.e_post)) { slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "modified entry \"%s\" is now a map\n", cbdata.dn); - /* XXX */ + backend_map_config_entry_add_cb(cbdata.e_pre, cbdata.state); } return 0; } @@ -1053,14 +1081,14 @@ backend_modrdn_cb(Slapi_PBlock *pb) cbdata.state->plugin_desc->spd_id, "renamed entry \"%s\" was a map\n", cbdata.e_pre); - /* XXX */ + backend_map_config_entry_delete_cb(cbdata.e_pre, cbdata.state); } if (backend_entry_is_a_map(cbdata.state, pb, cbdata.e_post)) { slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "renamed entry \"%s\" is now a map\n", cbdata.e_post); - /* XXX */ + backend_map_config_entry_add_cb(cbdata.e_pre, cbdata.state); } map_unlock(); return 0; @@ -1121,7 +1149,7 @@ backend_delete_cb(Slapi_PBlock *pb) slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "deleted entry \"%s\" is a map\n", cbdata.dn); - /* XXX */ + backend_map_config_entry_delete_cb(cbdata.e, cbdata.state); } map_unlock(); return 0; |
