diff options
Diffstat (limited to 'clientloop.c')
-rw-r--r-- | clientloop.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/clientloop.c b/clientloop.c index 337f47c09..97032e6a8 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.222 2010/07/19 09:15:12 djm Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.231 2011/01/16 12:05:59 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -329,7 +329,7 @@ client_x11_get_proto(const char *display, const char *xauth_path, | |||
329 | if (trusted == 0) { | 329 | if (trusted == 0) { |
330 | xauthdir = xmalloc(MAXPATHLEN); | 330 | xauthdir = xmalloc(MAXPATHLEN); |
331 | xauthfile = xmalloc(MAXPATHLEN); | 331 | xauthfile = xmalloc(MAXPATHLEN); |
332 | strlcpy(xauthdir, "/tmp/ssh-XXXXXXXXXX", MAXPATHLEN); | 332 | mktemp_proto(xauthdir, MAXPATHLEN); |
333 | if (mkdtemp(xauthdir) != NULL) { | 333 | if (mkdtemp(xauthdir) != NULL) { |
334 | do_unlink = 1; | 334 | do_unlink = 1; |
335 | snprintf(xauthfile, MAXPATHLEN, "%s/xauthfile", | 335 | snprintf(xauthfile, MAXPATHLEN, "%s/xauthfile", |
@@ -549,7 +549,7 @@ server_alive_check(void) | |||
549 | { | 549 | { |
550 | if (compat20) { | 550 | if (compat20) { |
551 | if (packet_inc_alive_timeouts() > options.server_alive_count_max) { | 551 | if (packet_inc_alive_timeouts() > options.server_alive_count_max) { |
552 | logit("Timeout, server not responding."); | 552 | logit("Timeout, server %s not responding.", host); |
553 | cleanup_exit(255); | 553 | cleanup_exit(255); |
554 | } | 554 | } |
555 | packet_start(SSH2_MSG_GLOBAL_REQUEST); | 555 | packet_start(SSH2_MSG_GLOBAL_REQUEST); |
@@ -1610,25 +1610,23 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | /* Output any buffered data for stdout. */ | 1612 | /* Output any buffered data for stdout. */ |
1613 | while (buffer_len(&stdout_buffer) > 0) { | 1613 | if (buffer_len(&stdout_buffer) > 0) { |
1614 | len = write(fileno(stdout), buffer_ptr(&stdout_buffer), | 1614 | len = atomicio(vwrite, fileno(stdout), |
1615 | buffer_len(&stdout_buffer)); | 1615 | buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer)); |
1616 | if (len <= 0) { | 1616 | if (len < 0 || (u_int)len != buffer_len(&stdout_buffer)) |
1617 | error("Write failed flushing stdout buffer."); | 1617 | error("Write failed flushing stdout buffer."); |
1618 | break; | 1618 | else |
1619 | } | 1619 | buffer_consume(&stdout_buffer, len); |
1620 | buffer_consume(&stdout_buffer, len); | ||
1621 | } | 1620 | } |
1622 | 1621 | ||
1623 | /* Output any buffered data for stderr. */ | 1622 | /* Output any buffered data for stderr. */ |
1624 | while (buffer_len(&stderr_buffer) > 0) { | 1623 | if (buffer_len(&stderr_buffer) > 0) { |
1625 | len = write(fileno(stderr), buffer_ptr(&stderr_buffer), | 1624 | len = atomicio(vwrite, fileno(stderr), |
1626 | buffer_len(&stderr_buffer)); | 1625 | buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer)); |
1627 | if (len <= 0) { | 1626 | if (len < 0 || (u_int)len != buffer_len(&stderr_buffer)) |
1628 | error("Write failed flushing stderr buffer."); | 1627 | error("Write failed flushing stderr buffer."); |
1629 | break; | 1628 | else |
1630 | } | 1629 | buffer_consume(&stderr_buffer, len); |
1631 | buffer_consume(&stderr_buffer, len); | ||
1632 | } | 1630 | } |
1633 | 1631 | ||
1634 | /* Clear and free any buffers. */ | 1632 | /* Clear and free any buffers. */ |
@@ -1642,7 +1640,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1642 | packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); | 1640 | packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
1643 | packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); | 1641 | packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
1644 | verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds", | 1642 | verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds", |
1645 | obytes, ibytes, total_time); | 1643 | (unsigned long long)obytes, (unsigned long long)ibytes, total_time); |
1646 | if (total_time > 0) | 1644 | if (total_time > 0) |
1647 | verbose("Bytes per second: sent %.1f, received %.1f", | 1645 | verbose("Bytes per second: sent %.1f, received %.1f", |
1648 | obytes / total_time, ibytes / total_time); | 1646 | obytes / total_time, ibytes / total_time); |
@@ -1953,7 +1951,7 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt) | |||
1953 | } | 1951 | } |
1954 | packet_check_eom(); | 1952 | packet_check_eom(); |
1955 | } | 1953 | } |
1956 | if (reply) { | 1954 | if (reply && c != NULL) { |
1957 | packet_start(success ? | 1955 | packet_start(success ? |
1958 | SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE); | 1956 | SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE); |
1959 | packet_put_int(c->remote_id); | 1957 | packet_put_int(c->remote_id); |
@@ -1993,6 +1991,9 @@ client_session2_setup(int id, int want_tty, int want_subsystem, | |||
1993 | if ((c = channel_lookup(id)) == NULL) | 1991 | if ((c = channel_lookup(id)) == NULL) |
1994 | fatal("client_session2_setup: channel %d: unknown channel", id); | 1992 | fatal("client_session2_setup: channel %d: unknown channel", id); |
1995 | 1993 | ||
1994 | packet_set_interactive(want_tty, | ||
1995 | options.ip_qos_interactive, options.ip_qos_bulk); | ||
1996 | |||
1996 | if (want_tty) { | 1997 | if (want_tty) { |
1997 | struct winsize ws; | 1998 | struct winsize ws; |
1998 | 1999 | ||
@@ -2149,5 +2150,6 @@ cleanup_exit(int i) | |||
2149 | leave_non_blocking(); | 2150 | leave_non_blocking(); |
2150 | if (options.control_path != NULL && muxserver_sock != -1) | 2151 | if (options.control_path != NULL && muxserver_sock != -1) |
2151 | unlink(options.control_path); | 2152 | unlink(options.control_path); |
2153 | ssh_kill_proxy_command(); | ||
2152 | _exit(i); | 2154 | _exit(i); |
2153 | } | 2155 | } |