version 1.61, 2003/06/28 16:23:06 |
version 1.61.2.2, 2004/08/19 22:37:30 |
|
|
static int |
static int |
ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply) |
ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply) |
{ |
{ |
int l, len; |
int l; |
|
u_int len; |
char buf[1024]; |
char buf[1024]; |
|
|
/* Get the length of the message, and format it in the buffer. */ |
/* Get the length of the message, and format it in the buffer. */ |
|
|
* Wait for response from the agent. First read the length of the |
* Wait for response from the agent. First read the length of the |
* response packet. |
* response packet. |
*/ |
*/ |
len = 4; |
if (atomicio(read, auth->fd, buf, 4) != 4) { |
while (len > 0) { |
error("Error reading response length from authentication socket."); |
l = read(auth->fd, buf + 4 - len, len); |
return 0; |
if (l == -1 && (errno == EAGAIN || errno == EINTR)) |
|
continue; |
|
if (l <= 0) { |
|
error("Error reading response length from authentication socket."); |
|
return 0; |
|
} |
|
len -= l; |
|
} |
} |
|
|
/* Extract the length, and check it for sanity. */ |
/* Extract the length, and check it for sanity. */ |
len = GET_32BIT(buf); |
len = GET_32BIT(buf); |
if (len > 256 * 1024) |
if (len > 256 * 1024) |
fatal("Authentication response too long: %d", len); |
fatal("Authentication response too long: %u", len); |
|
|
/* Read the rest of the response in to the buffer. */ |
/* Read the rest of the response in to the buffer. */ |
buffer_clear(reply); |
buffer_clear(reply); |
|
|
l = len; |
l = len; |
if (l > sizeof(buf)) |
if (l > sizeof(buf)) |
l = sizeof(buf); |
l = sizeof(buf); |
l = read(auth->fd, buf, l); |
l = atomicio(read, auth->fd, buf, l); |
if (l == -1 && (errno == EAGAIN || errno == EINTR)) |
|
continue; |
|
if (l <= 0) { |
if (l <= 0) { |
error("Error reading response from authentication socket."); |
error("Error reading response from authentication socket."); |
return 0; |
return 0; |
|
|
|
|
/* Get the number of entries in the response and check it for sanity. */ |
/* Get the number of entries in the response and check it for sanity. */ |
auth->howmany = buffer_get_int(&auth->identities); |
auth->howmany = buffer_get_int(&auth->identities); |
if (auth->howmany > 1024) |
if ((u_int)auth->howmany > 1024) |
fatal("Too many identities in authentication reply: %d", |
fatal("Too many identities in authentication reply: %d", |
auth->howmany); |
auth->howmany); |
|
|
|
|
} |
} |
|
|
int |
int |
ssh_update_card(AuthenticationConnection *auth, int add, |
ssh_update_card(AuthenticationConnection *auth, int add, |
const char *reader_id, const char *pin, u_int life, u_int confirm) |
const char *reader_id, const char *pin, u_int life, u_int confirm) |
{ |
{ |
Buffer msg; |
Buffer msg; |
|
|
buffer_put_char(&msg, type); |
buffer_put_char(&msg, type); |
buffer_put_cstring(&msg, reader_id); |
buffer_put_cstring(&msg, reader_id); |
buffer_put_cstring(&msg, pin); |
buffer_put_cstring(&msg, pin); |
|
|
if (constrained) { |
if (constrained) { |
if (life != 0) { |
if (life != 0) { |
buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME); |
buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME); |