diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-03 14:15:32 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-03 14:15:32 -0400 |
| commit | f421501cf65db22629d3ae820a7bfd57cc5fcdd1 (patch) | |
| tree | 77b43966cbaa33a06b0ea9cca49000e4ffd6b436 /src | |
| parent | 951b63ff30067d826be1b56861a02a4421f07b85 (diff) | |
| download | slapi-nis-f421501cf65db22629d3ae820a7bfd57cc5fcdd1.tar.gz slapi-nis-f421501cf65db22629d3ae820a7bfd57cc5fcdd1.tar.xz slapi-nis-f421501cf65db22629d3ae820a7bfd57cc5fcdd1.zip | |
- check over some comments
- differentiate between no-original-key and no-map when handling yp_next()
Diffstat (limited to 'src')
| -rw-r--r-- | src/nis.c | 45 |
1 files changed, 37 insertions, 8 deletions
@@ -49,7 +49,9 @@ #include "nis.h" #include "plugin.h" -/* Indicate whether or not we serve the specified domain. */ +/* Indicate whether or not we serve the specified domain. We handle both the + * normal and nonack case by letting the caller tell us which of the two types + * of requests is being handled. */ static void nis_domain(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -85,6 +87,7 @@ nis_domain(struct plugin_state *state, } } +/* Search for a single entry in a NIS map. */ static void nis_match(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -109,6 +112,7 @@ nis_match(struct plugin_state *state, (const char **) &reply_val->valdat.valdat_val, &entry_id, NULL) && (map_secure ? client_secure : TRUE)) { + /* Success! */ reply_val->status = YP_TRUE; slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -119,6 +123,9 @@ nis_match(struct plugin_state *state, req_key.keydat.keydat_val, reply_val->status); } else { + /* Distinguish between no-such-key and no-such-map for + * reporting the error. We're making maps which the + * client isn't allowed to read appear to be empty. */ map_supported = FALSE; map_supports_map(state, req_key.domain, req_key.map, &map_supported, NULL); @@ -131,6 +138,7 @@ nis_match(struct plugin_state *state, } } +/* Read the first entry in a given map. */ static void nis_first(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -157,6 +165,7 @@ nis_first(struct plugin_state *state, &reply_key_val->valdat.valdat_val, &entry_id, &entry_key_index) && (map_secure ? client_secure : TRUE)) { + /* Success! */ reply_key_val->status = YP_TRUE; slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -165,6 +174,9 @@ nis_first(struct plugin_state *state, req_nokey.map, reply_key_val->status); } else { + /* Distinguish between no-such-key and no-such-map for + * reporting the error. We're making maps which the + * client isn't allowed to read appear to be empty. */ map_supported = FALSE; map_supports_map(state, req_nokey.domain, req_nokey.map, &map_supported, NULL); @@ -178,6 +190,7 @@ nis_first(struct plugin_state *state, } } +/* Find the key and value which follow the passed-in key. */ static void nis_next(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -202,6 +215,7 @@ nis_next(struct plugin_state *state, &reply_key_val->valdat.valdat_len, &reply_key_val->valdat.valdat_val) && (map_secure ? client_secure : TRUE)) { + /* Success! */ reply_key_val->status = YP_TRUE; slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -212,6 +226,10 @@ nis_next(struct plugin_state *state, req_key.keydat.keydat_val, reply_key_val->status); } else { + /* Distinguish between no-next-key and no-this-key for + * reporting the error so that the client can know when + * to stop. We're making maps which the client isn't + * allowed to read appear to be empty. */ if (map_match(state, req_key.domain, req_key.map, &map_secure, req_key.keydat.keydat_len, @@ -223,16 +241,24 @@ nis_next(struct plugin_state *state, /* Have data for this key, but not the next. */ reply_key_val->status = YP_NOMORE; } else { - /* No data for this key. */ - reply_key_val->status = YP_NOKEY; + /* No data for this key. Check if we even have + * a map by that name, just to be sure. */ + map_supported = FALSE; + map_supports_map(state, + req_key.domain, + req_key.map, + &map_supported, NULL); + reply_key_val->status = map_supported ? + YP_NOKEY : YP_NOMAP; } slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "next(%s/%s/%.*s) -> no more!\n", + "next(%s/%s/%.*s) -> no %s!\n", req_key.domain, req_key.map, req_key.keydat.keydat_len, - req_key.keydat.keydat_val); + req_key.keydat.keydat_val, + map_supported ? "more" : "map"); } (*reply_fn)(state, cdata, reply, reply_xdrs); map_unlock(); @@ -241,6 +267,8 @@ nis_next(struct plugin_state *state, } } +/* Return information about where we think this map is maintained: here, of + * course. */ static void nis_master(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -274,6 +302,7 @@ nis_master(struct plugin_state *state, } } +/* Return the time the map was last changed. */ static void nis_order(struct plugin_state *state, dispatch_reply_fragment *reply_fragment_fn, @@ -315,6 +344,7 @@ nis_order(struct plugin_state *state, } } +/* Return the list of maps. */ static bool_t nis_maplist_cb(const char *domain, const char *mapname, bool_t secure, void *backend_data, void *cbdata) @@ -802,9 +832,8 @@ nis_all(struct plugin_state *state, } } -/* Process a NIS request in the buffer. If we get a client address, then we - * assume that the client is a datagram client, otherwise we assume it's a - * stream client. */ +/* Process a NIS request in the buffer and use a passed-in callback function to + * send the response back to the client. */ void nis_process_request(struct plugin_state *state, char *request_buf, size_t request_buflen, |
