summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@dahyabhai.net>2013-07-22 15:52:50 -0400
committerNalin Dahyabhai <nalin@dahyabhai.net>2013-08-07 14:46:03 -0400
commitf906d30fd05483acfe1c816f91bfd8ff9410897b (patch)
tree9c7c13a344bf4671970383f14b79030dd5ad8763 /src
parente8099d6a0396cdde592eb3e8059af1cb36506271 (diff)
downloadslapi-nis-f906d30fd05483acfe1c816f91bfd8ff9410897b.tar.gz
slapi-nis-f906d30fd05483acfe1c816f91bfd8ff9410897b.tar.xz
slapi-nis-f906d30fd05483acfe1c816f91bfd8ff9410897b.zip
Check if we fail to read-lock
If we fail to get a read lock on the data, fail to answer the client's NIS request.
Diffstat (limited to 'src')
-rw-r--r--src/nis.c83
1 files changed, 75 insertions, 8 deletions
diff --git a/src/nis.c b/src/nis.c
index 239a08b..95cafda 100644
--- a/src/nis.c
+++ b/src/nis.c
@@ -63,7 +63,13 @@ nis_domain(struct plugin_state *state,
char *domain = NULL;
*reply_bool = FALSE;
if (xdr_string(request_xdrs, &domain, YPMAXDOMAIN)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "domain(%s) -> lock error (no reply)\n",
+ domain);
+ goto done_with_lock;
+ }
map_supports_domain(state, domain, reply_bool);
if (*reply_bool || reply_on_failure) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -78,6 +84,7 @@ nis_domain(struct plugin_state *state,
domain, *reply_bool ? "TRUE" : "FALSE");
}
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_string, &domain);
} else {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -104,7 +111,16 @@ nis_match(struct plugin_state *state,
memset(&req_key, 0, sizeof(req_key));
memset(reply_val, 0, sizeof(*reply_val));
if (xdr_ypreq_key(request_xdrs, &req_key)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "match(%s/%s/%.*s) -> "
+ "lock error (no reply)\n",
+ req_key.domain, req_key.map,
+ (int) req_key.key.keydat_len,
+ req_key.key.keydat_val);
+ goto done_with_lock;
+ }
if (map_match(state, req_key.domain, req_key.map, &map_secure,
req_key.key.keydat_len,
req_key.key.keydat_val,
@@ -133,6 +149,7 @@ nis_match(struct plugin_state *state,
}
(*reply_fn)(state, cdata, reply, reply_xdrs);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_ypreq_key, &req_key);
} else {
/* XXX */
@@ -157,7 +174,14 @@ nis_first(struct plugin_state *state,
memset(&req_nokey, 0, sizeof(req_nokey));
memset(reply_key_val, 0, sizeof(*reply_key_val));
if (xdr_ypreq_nokey(request_xdrs, &req_nokey)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "first(%s/%s) -> "
+ "lock error (no reply)\n",
+ req_nokey.domain, req_nokey.map);
+ goto done_with_lock;
+ }
if (map_first(state, req_nokey.domain, req_nokey.map,
&map_secure,
&reply_key_val->key.keydat_len,
@@ -186,6 +210,7 @@ nis_first(struct plugin_state *state,
}
(*reply_fn)(state, cdata, reply, reply_xdrs);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_ypreq_nokey, &req_nokey);
} else {
/* XXX */
@@ -208,7 +233,16 @@ nis_next(struct plugin_state *state,
memset(&req_key, 0, sizeof(req_key));
memset(reply_key_val, 0, sizeof(*reply_key_val));
if (xdr_ypreq_key(request_xdrs, &req_key)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "next(%s/%s/%.*s) -> "
+ "lock error (no reply)\n",
+ req_key.domain, req_key.map,
+ req_key.key.keydat_len,
+ req_key.key.keydat_val);
+ goto done_with_lock;
+ }
if (map_next(state, req_key.domain, req_key.map, &map_secure,
req_key.key.keydat_len,
req_key.key.keydat_val,
@@ -265,6 +299,7 @@ nis_next(struct plugin_state *state,
}
(*reply_fn)(state, cdata, reply, reply_xdrs);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_ypreq_key, &req_key);
} else {
/* XXX */
@@ -288,7 +323,14 @@ nis_master(struct plugin_state *state,
memset(&req_nokey, 0, sizeof(req_nokey));
memset(reply_master, 0, sizeof(*reply_master));
if (xdr_ypreq_nokey(request_xdrs, &req_nokey)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "master(%s/%s) -> "
+ "lock error (no reply)\n",
+ req_nokey.domain, req_nokey.map);
+ goto done_with_lock;
+ }
if (map_supports_domain(state, req_nokey.domain, &supported) &&
supported) {
if (map_supports_map(state,
@@ -326,6 +368,7 @@ nis_master(struct plugin_state *state,
}
(*reply_fn)(state, cdata, reply, reply_xdrs);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_ypreq_nokey, &req_nokey);
} else {
/* XXX */
@@ -347,7 +390,14 @@ nis_order(struct plugin_state *state,
memset(&req_nokey, 0, sizeof(req_nokey));
memset(reply_order, 0, sizeof(*reply_order));
if (xdr_ypreq_nokey(request_xdrs, &req_nokey)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "order(%s/%s) -> "
+ "lock error (no reply)\n",
+ req_nokey.domain, req_nokey.map);
+ goto done_with_lock;
+ }
reply_order->stat = YP_TRUE;
if (map_order(state, req_nokey.domain, req_nokey.map,
&map_secure, &reply_order->ordernum) &&
@@ -369,6 +419,7 @@ nis_order(struct plugin_state *state,
}
(*reply_fn)(state, cdata, reply, reply_xdrs);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_ypreq_nokey, &req_nokey);
} else {
/* XXX */
@@ -429,7 +480,14 @@ nis_maplist(struct plugin_state *state,
struct nis_maplist_cbdata cbdata;
memset(reply_maplist, 0, sizeof(*reply_maplist));
if (xdr_string(request_xdrs, &domain, YPMAXDOMAIN)) {
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "maplist(%s) -> "
+ "lock error (no reply)\n",
+ domain);
+ goto done_with_lock;
+ }
cbdata.list = NULL;
cbdata.client_secure = client_secure;
map_data_foreach_map(state, domain, nis_maplist_cb, &cbdata);
@@ -453,6 +511,7 @@ nis_maplist(struct plugin_state *state,
(*reply_fn)(state, cdata, reply, reply_xdrs);
nis_free_maplist_cb_result(&cbdata);
map_unlock();
+done_with_lock:
xdr_free((xdrproc_t)xdr_string, &domain);
} else {
/* XXX */
@@ -555,7 +614,14 @@ nis_all(struct plugin_state *state,
cookie = nis_all_make_cookie(cookie_bad, NULL, 0);
}
/* Check if we even support the map. */
- map_rdlock();
+ if (map_rdlock() != 0) {
+ slapi_log_error(SLAPI_LOG_FATAL,
+ state->plugin_desc->spd_id,
+ "all(%s/%s) -> "
+ "lock error (no reply)\n",
+ req_nokey.domain, req_nokey.map);
+ goto done_with_lock;
+ }
map_supported = FALSE;
if (!map_supports_map(state, req_nokey.domain, req_nokey.map,
&map_supported, NULL) ||
@@ -873,6 +939,7 @@ nis_all(struct plugin_state *state,
}
}
map_unlock();
+done_with_lock:
/* Return the cookie if we can, else destroy it. */
if (continuation_cookie) {
*continuation_cookie = cookie;