diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-04 17:06:05 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-04 17:06:05 -0400 |
| commit | 1c704ae1dd96ebd30e8069644d6a4a06733d6804 (patch) | |
| tree | ca801ccec0afa6df0cc077d82b2dde5714a97ae2 /src | |
| parent | a0f030ecbe34d9157a842bbc443f5909d8334b4f (diff) | |
- fix things so that when an entry in a map is updated, entries named by the
map configuration's referred attribute in the entry get updated in whichever
map they happen to be in
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend.c | 54 | ||||
| -rw-r--r-- | src/defaults.c | 4 | ||||
| -rw-r--r-- | src/format.c | 2 |
3 files changed, 46 insertions, 14 deletions
diff --git a/src/backend.c b/src/backend.c index f7111ac..c68b323 100644 --- a/src/backend.c +++ b/src/backend.c @@ -87,8 +87,8 @@ backend_read_master_name(struct plugin_state *state, char **master) if (config == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "backend_master_name: failure reading " - "\"cn=config\""); + "backend_master_name: failure reading entry " + "\"cn=config\"\n"); slapi_sdn_free(&config_dn); return -1; } @@ -249,12 +249,40 @@ backend_map_config_entry_add_one_cb(Slapi_Entry *e, void *callback_data) } static void -backend_map_config_entry_set_one_cb(Slapi_Entry *e, - struct backend_map_data *map_data) +backend_map_config_entry_set_one(Slapi_Entry *e, + struct backend_map_data *map_data) { backend_map_config_entry_add_one_cb(e, map_data); } +static void +backend_map_config_entry_set_one_dn(struct plugin_state *state, const char *dn, + struct backend_map_data *map_data) +{ + Slapi_DN *sdn; + Slapi_Entry *entry; + sdn = slapi_sdn_new_dn_byval(dn); + if (sdn == NULL) { + slapi_log_error(SLAPI_LOG_PLUGIN, + state->plugin_desc->spd_id, + "error parsing DN \"%s\"\n", dn); + return; + } else { + entry = NULL; + slapi_search_internal_get_entry(sdn, NULL, &entry, + state->plugin_identity); + if (entry == NULL) { + slapi_log_error(SLAPI_LOG_PLUGIN, + state->plugin_desc->spd_id, + "failure reading entry \"%s\"\n", dn); + } else { + backend_map_config_entry_set_one(entry, map_data); + slapi_entry_free(entry); + } + slapi_sdn_free(&sdn); + } +} + /* * Generate a copy of the filter string, with specific sequences replaced: * %d -> name of the domain @@ -486,8 +514,8 @@ backend_read_params(struct plugin_state *state) if (our_entry == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "backend_read_params: failure reading " - "\"%s\"", state->plugin_base); + "backend_read_params: failure reading entry " + "\"%s\"\n", state->plugin_base); return; } /* Pull out the attribute values. */ @@ -750,7 +778,7 @@ backend_update_referred_to_entries_cb(const char *domain, const char *map, return TRUE; } - /* For every attribute name which is used to refer to another entry.. */ + /* For every attribute name which is used to refer to other entries.. */ referred = cbdata->map_data->referred; for (i = 0; (referred != NULL) && (referred[i] != NULL); i++) { values = NULL; @@ -766,11 +794,14 @@ backend_update_referred_to_entries_cb(const char *domain, const char *map, slapi_sdn_set_dn_byref(referred_to_sdn, dn); ndn = slapi_sdn_get_ndn(referred_to_sdn); + /* If the named entry corresponds to an + * entry in this map.. */ if (map_data_check_entry(map_data->state, map_data->domain, map_data->map, ndn)) { - backend_map_config_entry_set_one_cb(cbdata->e, map_data); + /* Update it. */ + backend_map_config_entry_set_one_dn(map_data->state, ndn, map_data); } } } @@ -778,6 +809,7 @@ backend_update_referred_to_entries_cb(const char *domain, const char *map, buffer_flags); } } + slapi_sdn_free(&referred_to_sdn); return TRUE; } @@ -816,7 +848,7 @@ backend_add_entry_cb(const char *domain, const char *map, void *backend_data, /* Set the entry in the map which corresponds to this entry, or clear * any that might if this entry doesn't have a key and value. */ - backend_map_config_entry_set_one_cb(cbdata->e, map_data); + backend_map_config_entry_set_one(cbdata->e, map_data); /* Update entries which need to be updated in case this entry now * refers to a set of entries. */ @@ -929,7 +961,7 @@ backend_modify_entry_cb(const char *domain, const char *map, void *backend_data, /* Set the entry in the map which corresponds to this entry, or * clear any that might if this entry doesn't have a key and * value. */ - backend_map_config_entry_set_one_cb(cbdata->e_post, map_data); + backend_map_config_entry_set_one(cbdata->e_post, map_data); /* Update entries which need to be updated in case this entry * no longer refers to them. */ rcbdata.map_data = map_data; @@ -1040,7 +1072,7 @@ backend_modrdn_entry_cb(const char *domain, const char *map, void *backend_data, /* Set the entry in the map which corresponds to this entry, or clear * any that might if this entry doesn't have a key and value. */ if (matched_post) { - backend_map_config_entry_set_one_cb(cbdata->e_post, map_data); + backend_map_config_entry_set_one(cbdata->e_post, map_data); } return TRUE; } diff --git a/src/defaults.c b/src/defaults.c index 88db21f..eee06f1 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -33,8 +33,8 @@ #define DEFAULT_VALUE_FORMAT "%{nisMapEntry}" #define DEFAULT_REFERRED NULL -static char *user_referred[] = {"member", NULL}; -static char *group_referred[] = {"memberOf", NULL}; +static char *user_referred[] = {"memberOf", NULL}; +static char *group_referred[] = {"member", "uniqueMember", NULL}; static struct configuration { char *map; diff --git a/src/format.c b/src/format.c index a776d5c..2daef85 100644 --- a/src/format.c +++ b/src/format.c @@ -309,7 +309,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, if (ref == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "deref: failure reading entry \"%s\"", + "deref: failure reading entry \"%s\"\n", slapi_sdn_get_ndn(refdn)); slapi_sdn_free(&refdn); continue; |
