diff options
Diffstat (limited to 'src/nis.c')
-rw-r--r-- | src/nis.c | 57 |
1 files changed, 38 insertions, 19 deletions
@@ -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. */ |