diff options
author | Russ Allbery <rra@stanford.edu> | 2012-02-18 18:03:54 -0800 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2012-02-18 18:03:54 -0800 |
commit | f7a051250bac985d971c14305544ec091bd016e6 (patch) | |
tree | faed9a823e9022e5babf6cb1319d8e76dd8a8eac /client | |
parent | e16d04ffb9ad7ac8ce0c3ebf5e604e507830ac54 (diff) |
Use timeout support for all network operations
Add timeout support to the token functions. Adjust all callers
accordingly. Use a one hour timeout for all server network calls.
Add the data and hook for setting a client timeout, although currently
there's no way to set it.
Change-Id: Ife4c6cd1b4fbc94623b82bd85e17a0d9a3919fb4
Diffstat (limited to 'client')
-rw-r--r-- | client/client-v1.c | 6 | ||||
-rw-r--r-- | client/client-v2.c | 10 | ||||
-rw-r--r-- | client/internal.h | 3 | ||||
-rw-r--r-- | client/open.c | 9 |
4 files changed, 15 insertions, 13 deletions
diff --git a/client/client-v1.c b/client/client-v1.c index e6018ad..16691e2 100644 --- a/client/client-v1.c +++ b/client/client-v1.c @@ -9,7 +9,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -68,7 +68,7 @@ internal_v1_commandv(struct remctl *r, const struct iovec *command, /* Send the result. */ status = token_send_priv(r->fd, r->context, TOKEN_DATA | TOKEN_SEND_MIC, - &token, &major, &minor); + &token, r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "sending token", status, major, minor); free(token.value); @@ -113,7 +113,7 @@ internal_v1_output(struct remctl *r) /* Otherwise, we have to read the token from the server. */ status = token_recv_priv(r->fd, r->context, &flags, &token, - TOKEN_MAX_LENGTH, &major, &minor); + TOKEN_MAX_LENGTH, r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "receiving token", status, major, minor); if (status == TOKEN_FAIL_EOF) { diff --git a/client/client-v2.c b/client/client-v2.c index aff163d..824e2cf 100644 --- a/client/client-v2.c +++ b/client/client-v2.c @@ -6,7 +6,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -150,7 +150,7 @@ internal_v2_commandv(struct remctl *r, const struct iovec *command, token.length -= left; status = token_send_priv(r->fd, r->context, TOKEN_DATA | TOKEN_PROTOCOL, &token, - &major, &minor); + r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "sending token", status, major, minor); free(token.value); @@ -178,7 +178,7 @@ internal_v2_quit(struct remctl *r) token.length = 1 + 1; token.value = buffer; status = token_send_priv(r->fd, r->context, TOKEN_DATA | TOKEN_PROTOCOL, - &token, &major, &minor); + &token, r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "sending QUIT token", status, major, minor); return false; @@ -199,7 +199,7 @@ internal_v2_read_token(struct remctl *r, gss_buffer_t token) char *p; status = token_recv_priv(r->fd, r->context, &flags, token, - TOKEN_MAX_LENGTH, &major, &minor); + TOKEN_MAX_LENGTH, r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "receiving token", status, major, minor); if (status == TOKEN_FAIL_EOF) { @@ -370,7 +370,7 @@ internal_noop(struct remctl *r) token.length = 1 + 1; token.value = buffer; status = token_send_priv(r->fd, r->context, TOKEN_DATA | TOKEN_PROTOCOL, - &token, &major, &minor); + &token, r->timeout, &major, &minor); if (status != TOKEN_OK) { internal_token_error(r, "sending NOOP token", status, major, minor); return false; diff --git a/client/internal.h b/client/internal.h index 9251777..9994cb6 100644 --- a/client/internal.h +++ b/client/internal.h @@ -3,7 +3,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on prior work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -29,6 +29,7 @@ struct remctl { const char *principal; /* connection for each command. */ int protocol; /* Protocol version. */ char *source; /* Source address for connection. */ + time_t timeout; socket_type fd; gss_ctx_id_t context; char *error; diff --git a/client/open.c b/client/open.c index f30afd0..47679f3 100644 --- a/client/open.c +++ b/client/open.c @@ -8,7 +8,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -179,7 +179,7 @@ internal_open(struct remctl *r, const char *host, unsigned short port, /* Send the initial negotiation token. */ status = token_send(fd, TOKEN_NOOP | TOKEN_CONTEXT_NEXT | TOKEN_PROTOCOL, - &empty_token); + &empty_token, r->timeout); if (status != TOKEN_OK) { internal_token_error(r, "sending initial token", status, 0, 0); goto fail; @@ -216,7 +216,7 @@ internal_open(struct remctl *r, const char *host, unsigned short port, flags = TOKEN_CONTEXT; if (r->protocol > 1) flags |= TOKEN_PROTOCOL; - status = token_send(fd, flags, &send_tok); + status = token_send(fd, flags, &send_tok, r->timeout); if (status != TOKEN_OK) { internal_token_error(r, "sending token", status, major, minor); gss_release_buffer(&minor, &send_tok); @@ -234,7 +234,8 @@ internal_open(struct remctl *r, const char *host, unsigned short port, /* If we're still expecting more, retrieve it. */ if (major == GSS_S_CONTINUE_NEEDED) { - status = token_recv(fd, &flags, &recv_tok, TOKEN_MAX_LENGTH); + status = token_recv(fd, &flags, &recv_tok, TOKEN_MAX_LENGTH, + r->timeout); if (status != TOKEN_OK) { internal_token_error(r, "receiving token", status, major, minor); |