From cd158d753a24f84a096d1c2211cd1da400a66036 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 17 Jun 2008 16:41:04 -0400 Subject: - get most of the tree in shape to handle multiple keys per entry - make map_next() not expose entry IDs or key indices, because it has to do all of the heavy lifting anyway --- src/backend.c | 121 +++++++++++++++++++++++++++++++++++---------------------- src/defaults.c | 29 +++++++------- src/defaults.h | 2 +- src/dummymap.c | 17 ++++---- src/map.c | 39 +++++++++++-------- src/map.h | 17 ++++---- src/nis.c | 57 ++++++++++++++++++--------- 7 files changed, 170 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/backend.c b/src/backend.c index 393cc9d..a6946a1 100644 --- a/src/backend.c +++ b/src/backend.c @@ -55,7 +55,9 @@ /* The data we ask the map cache to keep, for us, for each map. */ struct backend_map_data { struct plugin_state *state; - char *domain, *map, **bases, *entry_filter, *key_format, *value_format; + char *domain, *map, **bases, *entry_filter, **key_formats; + char *value_format; + int n_key_formats; char **ref_attrs; struct format_inref_attr **inref_attrs; }; @@ -120,6 +122,17 @@ backend_read_master_name(struct plugin_state *state, char **master) slapi_entry_free(config); return (*master != NULL) ? 0 : -1; } +static void +backend_free_strlist(char **strlist) +{ + int i; + if (strlist) { + for (i = 0; strlist[i] != NULL; i++) { + free(strlist[i]); + } + free(strlist); + } +} static char ** backend_dup_strlist(char **strlist) { @@ -168,7 +181,7 @@ backend_free_map_data_contents(void *data) format_free_attr_list(map_data->ref_attrs); format_free_inref_attrs(map_data->inref_attrs); free(map_data->entry_filter); - free(map_data->key_format); + backend_free_strlist(map_data->key_formats); free(map_data->value_format); } } @@ -198,13 +211,13 @@ backend_copy_cb_data(const struct backend_map_data *data) format_dup_inref_attrs(data->inref_attrs) : NULL; ret->entry_filter = strdup(data->entry_filter); - ret->key_format = strdup(data->key_format); + ret->key_formats = backend_dup_strlist(data->key_formats); ret->value_format = strdup(data->value_format); if ((ret->domain == NULL) || (ret->map == NULL) || (ret->bases == NULL) || (ret->entry_filter == NULL) || - (ret->key_format == NULL) || + (ret->key_formats == NULL) || (ret->value_format == NULL)) { backend_free_map_data(ret); return NULL; @@ -218,13 +231,23 @@ static int backend_map_config_entry_add_one_cb(Slapi_Entry *e, void *callback_data) { struct backend_map_data *data; - char *key, *value, *ndn; + char **keys, *value, *ndn; int i, j; data = callback_data; /* Pull out the key and value for the entry. */ - key = format_get_data(data->state, NULL, e, data->domain, data->map, - data->key_format, - &data->ref_attrs, &data->inref_attrs); + keys = malloc((data->n_key_formats + 1) * sizeof(char *)); + if (keys != NULL) { + for (i = 0; i < data->n_key_formats; i++) { + keys[i] = format_get_data(data->state, NULL, e, + data->domain, data->map, + data->key_formats[i], + &data->ref_attrs, + &data->inref_attrs); + } + keys[i] = NULL; + } else { + return 0; + } value = format_get_data(data->state, NULL, e, data->domain, data->map, data->value_format, &data->ref_attrs, &data->inref_attrs); @@ -232,15 +255,18 @@ backend_map_config_entry_add_one_cb(Slapi_Entry *e, void *callback_data) ndn = slapi_entry_get_ndn(e); /* If we actually generated a value, then set it, otherwise clear it in * case there was one set before. */ - if ((key != NULL) && (value != NULL)) { - slapi_log_error(SLAPI_LOG_PLUGIN, - data->state->plugin_desc->spd_id, - "setting domain/map/key/value " - "\"%s\"/\"%s\"/\"%s\"(\"%s\")=\"%s\"\n", - data->domain, data->map, - key, ndn, value); + if ((keys != NULL) && (value != NULL)) { + for (i = 0; i < data->n_key_formats; i++) { + slapi_log_error(SLAPI_LOG_PLUGIN, + data->state->plugin_desc->spd_id, + "setting domain/map/key/value " + "\"%s\"/\"%s\"/\"%s\"(\"%s\")=\"%s\"\n", + data->domain, data->map, + keys[i], ndn, value); + } map_data_set_entry(data->state, data->domain, data->map, ndn, - -1, key, + data->n_key_formats, + NULL, keys, -1, value); } else { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -253,7 +279,10 @@ backend_map_config_entry_add_one_cb(Slapi_Entry *e, void *callback_data) ndn); } format_free_data(value); - format_free_data(key); + for (i = 0; i < data->n_key_formats; i++) { + format_free_data(keys[i]); + } + free(keys); return 0; } @@ -372,18 +401,20 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, const char *domain, const char *map, bool_t *secure, struct backend_map_data *ret) { - const char *default_filter, *default_key_format, *default_value_format; - char **bases, *entry_filter, *key_format, *value_format, *actual_attr; + const char *default_filter, **default_key_formats; + const char *default_value_format; + char **bases, *entry_filter, **key_formats, *value_format, *actual_attr; char **ref_attrs; struct format_inref_attr **inref_attrs; - char **use_bases, *use_entry_filter, *use_key_format, *use_value_format; + char **use_bases, *use_entry_filter, **use_key_formats; + char *use_value_format; const char *cvalue; - int i, disposition, buffer_flags, count; + int i, j, disposition, buffer_flags, count; Slapi_ValueSet *values; Slapi_Value *value; /* Read the hard-coded defaults for a map with this name. */ defaults_get_map_config(map, secure, &default_filter, - &default_key_format, &default_value_format); + &default_key_formats, &default_value_format); /* Read the values from the configuration entry. */ bases = NULL; if (slapi_vattr_values_get(e, MAP_CONFIGURATION_BASE_ATTR, &values, @@ -413,16 +444,24 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, } slapi_vattr_values_free(&values, &actual_attr, buffer_flags); } - key_format = NULL; + key_formats = NULL; if (slapi_vattr_values_get(e, MAP_CONFIGURATION_KEY_ATTR, &values, &disposition, &actual_attr, 0, &buffer_flags) == 0) { - i = slapi_valueset_first_value(values, &value); - if (i != -1) { - cvalue = slapi_value_get_string(value); - key_format = strdup(cvalue); + key_formats = malloc((slapi_valueset_count(values) + 1) * + (sizeof (char *))); + if (key_formats != NULL) { + for (i = 0; i < slapi_valueset_count(values); i++) { + j = slapi_valueset_first_value(values, &value); + if (j != -1) { + cvalue = slapi_value_get_string(value); + key_formats[i] = strdup(cvalue); + } + slapi_vattr_values_free(&values, &actual_attr, + buffer_flags); + } + key_formats[i] = NULL; } - slapi_vattr_values_free(&values, &actual_attr, buffer_flags); } value_format = NULL; if (slapi_vattr_values_get(e, MAP_CONFIGURATION_VALUE_ATTR, &values, @@ -461,30 +500,25 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, entry_filter : default_filter, domain, map); - use_key_format = key_format ? - strdup(key_format) : - strdup(default_key_format); + use_key_formats = key_formats ? + backend_dup_strlist(key_formats) : + backend_dup_strlist((char **) default_key_formats); use_value_format = value_format ? strdup(value_format) : strdup(default_value_format); use_bases = backend_dup_strlist(bases); /* Free the values we read from the entry. */ free(value_format); - free(key_format); + backend_free_strlist(key_formats); free(entry_filter); - if (bases) { - for (i = 0; bases[i] != NULL; i++) { - free(bases[i]); - } - free(bases); - } + backend_free_strlist(bases); /* Populate the returned structure. */ ret->state = state; ret->domain = strdup(domain); ret->map = strdup(map); ret->bases = use_bases; ret->entry_filter = use_entry_filter; - ret->key_format = use_key_format; + ret->key_formats = use_key_formats; ret->value_format = use_value_format; ret->ref_attrs = NULL; ret->inref_attrs = NULL; @@ -495,7 +529,7 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, "key \"%s\", " "value \"%s\"\n", map, domain, - use_entry_filter, use_key_format, use_value_format); + use_entry_filter, use_key_formats, use_value_format); } /* Given a directory server entry which represents a map's configuration, set @@ -803,12 +837,7 @@ void backend_free_map_config(char **bases, char *entry_filter) { int i; - if (bases != NULL) { - for (i = 0; bases[i] != NULL; i++) { - free(bases[i]); - } - } - free(bases); + backend_free_strlist(bases); free(entry_filter); } diff --git a/src/defaults.c b/src/defaults.c index fe2474d..29e0d8d 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -33,36 +33,37 @@ #define DEFAULT_KEY_FORMAT "%{cn}" #define DEFAULT_VALUE_FORMAT "%{nisMapEntry}" #define DEFAULT_MAP_SECURE FALSE +static const char *default_key_formats[] = {DEFAULT_KEY_FORMAT, NULL}; static struct configuration { char *map; enum { config_exact, config_glob } config_match; bool_t secure; - char *filter, *key_format, *value_format; + char *filter, *key_formats[3], *value_format; } config[] = { {"passwd.byname", config_exact, FALSE, "(objectClass=posixAccount)", - "%{uid}", + {"%{uid}", NULL, NULL}, "%{uid}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{uidNumber}:%{gidNumber}:%{cn!:}:%{homeDirectory:-/}:%{loginShell!:}"}, {"passwd.byuid", config_exact, FALSE, "(objectClass=posixAccount)", - "%{uidNumber}", + {"%{uidNumber}", NULL, NULL}, "%{uid}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{uidNumber}:%{gidNumber}:%{cn!:}:%{homeDirectory:-/}:%{loginShell!:}"}, {"group.byname", config_exact, FALSE, "(objectClass=posixGroup)", - "%{cn}", + {"%{cn}", NULL, NULL}, "%{cn}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{gidNumber}:%merge(\",\",\"%list(\\\",\\\",\\\"memberUid\\\")\",\"%deref(\\\",\\\",\\\"member\\\",\\\"uid\\\")\",\"%deref(\\\",\\\",\\\"uniqueMember\\\",\\\"uid\\\")\",\"%referred(\\\",\\\",\\\"passwd.byname\\\",\\\"memberOf\\\",\\\"uid\\\")\")"}, {"group.bygid", config_exact, FALSE, "(objectClass=posixGroup)", - "%{gidNumber}", + {"%{gidNumber}", NULL, NULL}, "%{cn}:%regsub(\"userPassword\",\"^\\\\{CRYPT\\\\}(..*)\",\"%1\",\"*\"):%{gidNumber}:%merge(\",\",\"%list(\\\",\\\",\\\"memberUid\\\")\",\"%deref(\\\",\\\",\\\"member\\\",\\\"uid\\\")\",\"%deref(\\\",\\\",\\\"uniqueMember\\\",\\\"uid\\\")\",\"%referred(\\\",\\\",\\\"passwd.byuid\\\",\\\"memberOf\\\",\\\"uid\\\")\")"}, {"netgroup", config_exact, FALSE, "(objectClass=nisNetgroup)", - "%{cn}", + {"%{cn}", NULL, NULL}, "%list(\" \",\"nisNetgroupTriple\",\"memberNisNetgroup\")"}, {"auto.*", config_glob, FALSE, "(objectClass=automount)", - "%{automountKey}", + {"%{automountKey}", NULL, NULL}, "%{automountInformation}"}, }; @@ -70,7 +71,7 @@ void defaults_get_map_config(const char *mapname, bool_t *secure, const char **filter, - const char **key_format, + const char ***key_formats, const char **value_format) { unsigned int i; @@ -80,8 +81,8 @@ defaults_get_map_config(const char *mapname, if (secure) { *secure = DEFAULT_MAP_SECURE; } - if (key_format) { - *key_format = DEFAULT_KEY_FORMAT; + if (key_formats) { + *key_formats = default_key_formats; } if (value_format) { *value_format = DEFAULT_VALUE_FORMAT; @@ -96,8 +97,8 @@ defaults_get_map_config(const char *mapname, if (filter) { *filter = config[i].filter; } - if (key_format) { - *key_format = config[i].key_format; + if (key_formats) { + *key_formats = (const char **) config[i].key_formats; } if (value_format) { *value_format = config[i].value_format; @@ -113,8 +114,8 @@ defaults_get_map_config(const char *mapname, if (filter) { *filter = config[i].filter; } - if (key_format) { - *key_format = config[i].key_format; + if (key_formats) { + *key_formats = (const char **) config[i].key_formats; } if (value_format) { *value_format = config[i].value_format; diff --git a/src/defaults.h b/src/defaults.h index 486b9e5..e36cbd1 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -24,6 +24,6 @@ void defaults_get_map_config(const char *mapname, bool_t *secure, const char **filter, - const char **key_format, + const char ***key_formats, const char **value_format); #endif diff --git a/src/dummymap.c b/src/dummymap.c index ffb4ef7..cd36c15 100644 --- a/src/dummymap.c +++ b/src/dummymap.c @@ -219,13 +219,16 @@ map_match(struct plugin_state *state, bool_t map_match_id(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, - const char *in_id, + const char *in_id, int in_index, unsigned int *key_len, char **key, unsigned int *value_len, char **value, const char **id) { struct entry *entries; int i; + if (in_index != 0) { + return FALSE; + } if ((entries = map_find_entries(domain, map)) == NULL) { return FALSE; } @@ -251,7 +254,7 @@ map_first(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, unsigned int *first_key_len, char **first_key, unsigned int *first_value_len, char **first_value, - const char **first_id) + const char **first_id, int *first_id_index) { struct entry *entries; if ((entries = map_find_entries(domain, map)) == NULL) { @@ -266,6 +269,7 @@ map_first(struct plugin_state *state, *first_value = entries[0].value; *first_value_len = strlen(entries[0].value); *first_id = entries[0].id; + *first_id_index = 0; return TRUE; } @@ -274,8 +278,7 @@ map_next(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, unsigned int prev_len, const char *prev, unsigned int *next_key_len, char **next_key, - unsigned int *next_value_len, char **next_value, - const char **next_id) + unsigned int *next_value_len, char **next_value) { struct entry *entries; int i; @@ -299,17 +302,16 @@ map_next(struct plugin_state *state, *next_key_len = strlen(entries[i + 1].key); *next_value = entries[i + 1].value; *next_value_len = strlen(entries[i + 1].value); - *next_id = entries[i + 1].id; return TRUE; } bool_t map_next_id(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, - const char *prev_id, + const char *prev_id, int prev_id_index, unsigned int *next_key_len, char **next_key, unsigned int *next_value_len, char **next_value, - const char **next_id) + const char **next_id, int *next_id_index) { struct entry *entries; int i; @@ -333,5 +335,6 @@ map_next_id(struct plugin_state *state, *next_value = entries[i + 1].value; *next_value_len = strlen(entries[i + 1].value); *next_id = entries[i + 1].id; + *next_id_index = 0; return TRUE; } diff --git a/src/map.c b/src/map.c index 24686b0..3faaaf9 100644 --- a/src/map.c +++ b/src/map.c @@ -64,9 +64,10 @@ struct { /* The name of the backend entry for this * entry. */ char *id; - /* Key and value. */ - char *key; - unsigned int key_len; + /* Keys and value. */ + int n_keys; + char **key; + unsigned int *key_len; char *value; unsigned int value_len; } *entries; @@ -209,10 +210,11 @@ map_data_foreach_entry(struct plugin_state *state, bool_t secure, const char *key, unsigned int key_len, const char *value, unsigned int value_len, - const char *id, void *cbdata), + const char *id, int key_index, + void *cbdata), void *cbdata) { - int i, j; + int i, j, k; struct domain *domain; struct map *map; struct map_entry *entry; @@ -226,14 +228,18 @@ map_data_foreach_entry(struct plugin_state *state, if (all || ((id != NULL) && (strcmp(id, entry->id) == 0))) { - if (!(*fn)(domain->name, map->name, - map->secure, - entry->key, - entry->key_len, - entry->value, - entry->value_len, - entry->id, cbdata)) { - return FALSE; + for (k = 0; k < entry->n_keys; k++) { + if (!(*fn)(domain->name, + map->name, + map->secure, + entry->key[k], + entry->key_len[k], + entry->value, + entry->value_len, + entry->id, k, + cbdata)) { + return FALSE; + } } } } @@ -251,7 +257,8 @@ map_data_foreach_entry_id(struct plugin_state *state, const char *id, unsigned int key_len, const char *value, unsigned int value_len, - const char *id, void *cbdata), + const char *id, int key_index, + void *cbdata), void *cbdata) { return map_data_foreach_entry(state, FALSE, id, fn, cbdata); @@ -452,8 +459,7 @@ map_next(struct plugin_state *state, const char *domain_name, const char *map_name, bool_t *secure, unsigned int prev_len, const char *prev, unsigned int *next_key_len, char **next_key, - unsigned int *next_value_len, char **next_value, - const char **next_id) + unsigned int *next_value_len, char **next_value) { struct map *map; struct map_entry *entry; @@ -470,7 +476,6 @@ map_next(struct plugin_state *state, *next_key = entry->next->key; *next_value_len = entry->next->value_len; *next_value = entry->next->value; - *next_id = entry->next->id; return TRUE; } bool_t diff --git a/src/map.h b/src/map.h index f7cb49d..b0e4a5c 100644 --- a/src/map.h +++ b/src/map.h @@ -41,7 +41,7 @@ bool_t map_match(struct plugin_state *state, unsigned int *value_len, char **value, const char **id); bool_t map_match_id(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, - const char *id_in, + const char *id_in, int id_index, unsigned int *key_len, char **key, unsigned int *value_len, char **value, const char **id); @@ -49,19 +49,18 @@ bool_t map_first(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, unsigned int *first_key_len, char **first_key, unsigned int *first_value_len, char **first_value, - const char **id); + const char **first_id, int *first_key_index); bool_t map_next(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, unsigned int prev_len, const char *prev, unsigned int *next_key_len, char **next_key, - unsigned int *next_value_len, char **next_value, - const char **next_id); + unsigned int *next_value_len, char **next_value); bool_t map_next_id(struct plugin_state *state, const char *domain, const char *map, bool_t *secure, - const char *prev_id, + const char *prev_id, int prev_index, unsigned int *next_key_len, char **next_key, unsigned int *next_value_len, char **next_value, - const char **next_id); + const char **next_id, int *next_key_index); bool_t map_order(struct plugin_state *state, const char *domain, const char *map, bool_t *map_secure, unsigned int *order); @@ -80,7 +79,8 @@ void map_data_unset_entry_id(struct plugin_state *state, void map_data_set_entry(struct plugin_state *state, const char *domain_name, const char *map_name, const char *id, - unsigned int key_len, char *key, + unsigned int n_keys, + unsigned int *key_len, char **key, unsigned int value_len, char *value); bool_t map_data_check_entry(struct plugin_state *state, const char *domain_name, const char *map_name, @@ -93,7 +93,8 @@ bool_t map_data_foreach_entry_id(struct plugin_state *state, const char *id, unsigned int key_len, const char *value, unsigned int value_len, - const char *id, void *cbdata), + const char *id, int key_index, + void *cbdata), void *cbdata); bool_t map_data_foreach_map(struct plugin_state *state, const char *domain_name, bool_t (*fn)(const char *domain, diff --git a/src/nis.c b/src/nis.c index 4ae38b2..7b5eabc 100644 --- a/src/nis.c +++ b/src/nis.c @@ -143,6 +143,7 @@ nis_first(struct plugin_state *state, struct ypreq_nokey req_nokey; bool_t map_supported, map_secure; const char *entry_id; + int entry_key_index; memset(&req_nokey, 0, sizeof(req_nokey)); memset(reply_key_val, 0, sizeof(*reply_key_val)); @@ -154,7 +155,7 @@ nis_first(struct plugin_state *state, &reply_key_val->keydat.keydat_val, &reply_key_val->valdat.valdat_len, &reply_key_val->valdat.valdat_val, - &entry_id) && + &entry_id, &entry_key_index) && (map_secure ? client_secure : TRUE)) { reply_key_val->status = YP_TRUE; slapi_log_error(SLAPI_LOG_PLUGIN, @@ -199,8 +200,7 @@ nis_next(struct plugin_state *state, &reply_key_val->keydat.keydat_len, &reply_key_val->keydat.keydat_val, &reply_key_val->valdat.valdat_len, - &reply_key_val->valdat.valdat_val, - &entry_id) && + &reply_key_val->valdat.valdat_val) && (map_secure ? client_secure : TRUE)) { reply_key_val->status = YP_TRUE; slapi_log_error(SLAPI_LOG_PLUGIN, @@ -404,6 +404,7 @@ struct nis_all_cookie { cookie_end2, } state; unsigned int id_length; + int key_index; char id[1]; }; static void @@ -412,7 +413,8 @@ nis_all_free_cookie(struct nis_all_cookie *cookie) free(cookie); } static struct nis_all_cookie * -nis_all_make_cookie(enum nis_all_cookie_state state, const char *id) +nis_all_make_cookie(enum nis_all_cookie_state state, + const char *id, int key_index) { struct nis_all_cookie *cookie; int length; @@ -420,6 +422,9 @@ nis_all_make_cookie(enum nis_all_cookie_state state, const char *id) cookie = malloc(sizeof(*cookie) + length + 1); if (cookie != NULL) { cookie->state = state; + memset(cookie->id, '\0', sizeof(cookie->id)); + cookie->id_length = 0; + cookie->key_index = 0; switch (cookie->state) { case cookie_bad: case cookie_first: @@ -430,6 +435,7 @@ nis_all_make_cookie(enum nis_all_cookie_state state, const char *id) case cookie_this: case cookie_next: cookie->id_length = length; + cookie->key_index = key_index; if (length > 0) { memcpy(&cookie->id, id, cookie->id_length); cookie->id[length] = '\0'; @@ -458,6 +464,7 @@ nis_all(struct plugin_state *state, enum nis_all_cookie_state next_state; bool_t map_supported, map_secure, stop; const char *entry_id; + int entry_key_index; memset(&req_nokey, 0, sizeof(req_nokey)); reply_key = &reply_all->ypresp_all_u.val.keydat; @@ -468,11 +475,12 @@ nis_all(struct plugin_state *state, if (*continuation_cookie != NULL) { cookie = *continuation_cookie; } else { - cookie = nis_all_make_cookie(cookie_bad, NULL); + cookie = nis_all_make_cookie(cookie_bad, + NULL, 0); } *continuation_cookie = NULL; } else { - cookie = nis_all_make_cookie(cookie_bad, NULL); + cookie = nis_all_make_cookie(cookie_bad, NULL, 0); } /* Check if we even support the map. */ map_rdlock(); @@ -526,7 +534,8 @@ nis_all(struct plugin_state *state, &reply_key->keydat_val, &reply_val->valdat_len, &reply_val->valdat_val, - &entry_id) && + &entry_id, + &entry_key_index) && (map_secure ? client_secure : TRUE); if (found) { /* Next time grab the entry after this @@ -564,12 +573,13 @@ nis_all(struct plugin_state *state, * entry or send end0 or end1, * whichever is appropriate. */ cookie = nis_all_make_cookie(next_state, - entry_id); + entry_id, + entry_key_index); } else { /* Leave a note to try sending the * first entry again. */ cookie = nis_all_make_cookie(cookie_first, - NULL); + NULL, 0); stop = TRUE; } break; @@ -582,11 +592,13 @@ nis_all(struct plugin_state *state, req_nokey.map, &map_secure, cookie->id, + cookie->key_index, &reply_key->keydat_len, &reply_key->keydat_val, &reply_val->valdat_len, &reply_val->valdat_val, - &entry_id) && + &entry_id, + &entry_key_index) && (map_secure ? client_secure : TRUE); if (found) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -625,13 +637,15 @@ nis_all(struct plugin_state *state, * appropriate. */ nis_all_free_cookie(cookie); cookie = nis_all_make_cookie(next_state, - entry_id); + entry_id, + entry_key_index); } else { /* Leave a note to retry sending this * entry the next time. */ nis_all_free_cookie(cookie); cookie = nis_all_make_cookie(cookie_this, - entry_id); + entry_id, + entry_key_index); stop = TRUE; } break; @@ -644,22 +658,25 @@ nis_all(struct plugin_state *state, req_nokey.map, &map_secure, cookie->id, + cookie->key_index, &reply_key->keydat_len, &reply_key->keydat_val, &reply_val->valdat_len, &reply_val->valdat_val, &entry_id) && (map_secure ? client_secure : TRUE); + entry_key_index = cookie->key_index; if (found) { /* Next time grab the entry after this * one. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "all(%s/%s) \"%s\" " + "all(%s/%s) \"%s\":%d " "(retry)\n", req_nokey.domain, req_nokey.map, - cookie->id); + cookie->id, + cookie->key_index); skip = FALSE; reply_all->more = TRUE; reply_all->ypresp_all_u.val.status = YP_TRUE; @@ -669,11 +686,12 @@ nis_all(struct plugin_state *state, * state. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "all(%s/%s) \"%s\" " + "all(%s/%s) \"%s\":%d " "(disappeared?)\n", req_nokey.domain, req_nokey.map, - cookie->id); + cookie->id, + cookie->key_index); skip = TRUE; next_state = cookie_end1; } @@ -692,7 +710,8 @@ nis_all(struct plugin_state *state, * stuck. */ nis_all_free_cookie(cookie); cookie = nis_all_make_cookie(next_state, - entry_id); + entry_id, + entry_key_index); break; case cookie_end0: /* Send the end-of-map message as the first @@ -713,7 +732,7 @@ nis_all(struct plugin_state *state, /* Leave a note to finish the reply. */ nis_all_free_cookie(cookie); cookie = nis_all_make_cookie(cookie_end2, - NULL); + NULL, 0); } else { /* Leave the note alone, so that we'll * have to try again. */ @@ -740,7 +759,7 @@ nis_all(struct plugin_state *state, /* Leave a note to finish the reply. */ nis_all_free_cookie(cookie); cookie = nis_all_make_cookie(cookie_end2, - NULL); + NULL, 0); } else { /* Leave the note alone, so that we'll * have to try again. */ -- cgit