summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/clientloop.c b/clientloop.c
index ef97859f1..ed1902363 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",
@@ -548,7 +548,7 @@ static void
548server_alive_check(void) 548server_alive_check(void)
549{ 549{
550 if (packet_inc_alive_timeouts() > options.server_alive_count_max) { 550 if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
551 logit("Timeout, server not responding."); 551 logit("Timeout, server %s not responding.", host);
552 cleanup_exit(255); 552 cleanup_exit(255);
553 } 553 }
554 packet_start(SSH2_MSG_GLOBAL_REQUEST); 554 packet_start(SSH2_MSG_GLOBAL_REQUEST);
@@ -1603,25 +1603,23 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1603 } 1603 }
1604 1604
1605 /* Output any buffered data for stdout. */ 1605 /* Output any buffered data for stdout. */
1606 while (buffer_len(&stdout_buffer) > 0) { 1606 if (buffer_len(&stdout_buffer) > 0) {
1607 len = write(fileno(stdout), buffer_ptr(&stdout_buffer), 1607 len = atomicio(vwrite, fileno(stdout),
1608 buffer_len(&stdout_buffer)); 1608 buffer_ptr(&stdout_buffer), buffer_len(&stdout_buffer));
1609 if (len <= 0) { 1609 if (len < 0 || (u_int)len != buffer_len(&stdout_buffer))
1610 error("Write failed flushing stdout buffer."); 1610 error("Write failed flushing stdout buffer.");
1611 break; 1611 else
1612 } 1612 buffer_consume(&stdout_buffer, len);
1613 buffer_consume(&stdout_buffer, len);
1614 } 1613 }
1615 1614
1616 /* Output any buffered data for stderr. */ 1615 /* Output any buffered data for stderr. */
1617 while (buffer_len(&stderr_buffer) > 0) { 1616 if (buffer_len(&stderr_buffer) > 0) {
1618 len = write(fileno(stderr), buffer_ptr(&stderr_buffer), 1617 len = atomicio(vwrite, fileno(stderr),
1619 buffer_len(&stderr_buffer)); 1618 buffer_ptr(&stderr_buffer), buffer_len(&stderr_buffer));
1620 if (len <= 0) { 1619 if (len < 0 || (u_int)len != buffer_len(&stderr_buffer))
1621 error("Write failed flushing stderr buffer."); 1620 error("Write failed flushing stderr buffer.");
1622 break; 1621 else
1623 } 1622 buffer_consume(&stderr_buffer, len);
1624 buffer_consume(&stderr_buffer, len);
1625 } 1623 }
1626 1624
1627 /* Clear and free any buffers. */ 1625 /* Clear and free any buffers. */
@@ -1635,7 +1633,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1635 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); 1633 packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes);
1636 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); 1634 packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes);
1637 verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds", 1635 verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds",
1638 obytes, ibytes, total_time); 1636 (unsigned long long)obytes, (unsigned long long)ibytes, total_time);
1639 if (total_time > 0) 1637 if (total_time > 0)
1640 verbose("Bytes per second: sent %.1f, received %.1f", 1638 verbose("Bytes per second: sent %.1f, received %.1f",
1641 obytes / total_time, ibytes / total_time); 1639 obytes / total_time, ibytes / total_time);
@@ -1946,7 +1944,7 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
1946 } 1944 }
1947 packet_check_eom(); 1945 packet_check_eom();
1948 } 1946 }
1949 if (reply) { 1947 if (reply && c != NULL) {
1950 packet_start(success ? 1948 packet_start(success ?
1951 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE); 1949 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
1952 packet_put_int(c->remote_id); 1950 packet_put_int(c->remote_id);
@@ -1986,6 +1984,9 @@ client_session2_setup(int id, int want_tty, int want_subsystem,
1986 if ((c = channel_lookup(id)) == NULL) 1984 if ((c = channel_lookup(id)) == NULL)
1987 fatal("client_session2_setup: channel %d: unknown channel", id); 1985 fatal("client_session2_setup: channel %d: unknown channel", id);
1988 1986
1987 packet_set_interactive(want_tty,
1988 options.ip_qos_interactive, options.ip_qos_bulk);
1989
1989 if (want_tty) { 1990 if (want_tty) {
1990 struct winsize ws; 1991 struct winsize ws;
1991 1992
@@ -2142,5 +2143,6 @@ cleanup_exit(int i)
2142 leave_non_blocking(); 2143 leave_non_blocking();
2143 if (options.control_path != NULL && muxserver_sock != -1) 2144 if (options.control_path != NULL && muxserver_sock != -1)
2144 unlink(options.control_path); 2145 unlink(options.control_path);
2146 ssh_kill_proxy_command();
2145 _exit(i); 2147 _exit(i);
2146} 2148}