summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/clientloop.c b/clientloop.c
index 9549dadd4..d445230e5 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.107 2003/04/01 10:22:21 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.112 2003/06/28 16:23:06 deraadt Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -414,9 +414,9 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
414 414
415 /* Flush stdout and stderr buffers. */ 415 /* Flush stdout and stderr buffers. */
416 if (buffer_len(bout) > 0) 416 if (buffer_len(bout) > 0)
417 atomicio(write, fileno(stdout), buffer_ptr(bout), buffer_len(bout)); 417 atomicio(vwrite, fileno(stdout), buffer_ptr(bout), buffer_len(bout));
418 if (buffer_len(berr) > 0) 418 if (buffer_len(berr) > 0)
419 atomicio(write, fileno(stderr), buffer_ptr(berr), buffer_len(berr)); 419 atomicio(vwrite, fileno(stderr), buffer_ptr(berr), buffer_len(berr));
420 420
421 leave_raw_mode(); 421 leave_raw_mode();
422 422
@@ -509,13 +509,13 @@ process_cmdline(void)
509 if (*s == 0) 509 if (*s == 0)
510 goto out; 510 goto out;
511 if (strlen(s) < 2 || s[0] != '-' || !(s[1] == 'L' || s[1] == 'R')) { 511 if (strlen(s) < 2 || s[0] != '-' || !(s[1] == 'L' || s[1] == 'R')) {
512 log("Invalid command."); 512 logit("Invalid command.");
513 goto out; 513 goto out;
514 } 514 }
515 if (s[1] == 'L') 515 if (s[1] == 'L')
516 local = 1; 516 local = 1;
517 if (!local && !compat20) { 517 if (!local && !compat20) {
518 log("Not supported for SSH protocol version 1."); 518 logit("Not supported for SSH protocol version 1.");
519 goto out; 519 goto out;
520 } 520 }
521 s += 2; 521 s += 2;
@@ -526,24 +526,24 @@ process_cmdline(void)
526 sfwd_port, buf, sfwd_host_port) != 3 && 526 sfwd_port, buf, sfwd_host_port) != 3 &&
527 sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]", 527 sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]",
528 sfwd_port, buf, sfwd_host_port) != 3) { 528 sfwd_port, buf, sfwd_host_port) != 3) {
529 log("Bad forwarding specification."); 529 logit("Bad forwarding specification.");
530 goto out; 530 goto out;
531 } 531 }
532 if ((fwd_port = a2port(sfwd_port)) == 0 || 532 if ((fwd_port = a2port(sfwd_port)) == 0 ||
533 (fwd_host_port = a2port(sfwd_host_port)) == 0) { 533 (fwd_host_port = a2port(sfwd_host_port)) == 0) {
534 log("Bad forwarding port(s)."); 534 logit("Bad forwarding port(s).");
535 goto out; 535 goto out;
536 } 536 }
537 if (local) { 537 if (local) {
538 if (channel_setup_local_fwd_listener(fwd_port, buf, 538 if (channel_setup_local_fwd_listener(fwd_port, buf,
539 fwd_host_port, options.gateway_ports) < 0) { 539 fwd_host_port, options.gateway_ports) < 0) {
540 log("Port forwarding failed."); 540 logit("Port forwarding failed.");
541 goto out; 541 goto out;
542 } 542 }
543 } else 543 } else
544 channel_request_remote_forwarding(fwd_port, buf, 544 channel_request_remote_forwarding(fwd_port, buf,
545 fwd_host_port); 545 fwd_host_port);
546 log("Forwarding port."); 546 logit("Forwarding port.");
547out: 547out:
548 signal(SIGINT, handler); 548 signal(SIGINT, handler);
549 enter_raw_mode(); 549 enter_raw_mode();
@@ -593,10 +593,23 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
593 /* We have been continued. */ 593 /* We have been continued. */
594 continue; 594 continue;
595 595
596 case 'B':
597 if (compat20) {
598 snprintf(string, sizeof string,
599 "%cB\r\n", escape_char);
600 buffer_append(berr, string,
601 strlen(string));
602 channel_request_start(session_ident,
603 "break", 0);
604 packet_put_int(1000);
605 packet_send();
606 }
607 continue;
608
596 case 'R': 609 case 'R':
597 if (compat20) { 610 if (compat20) {
598 if (datafellows & SSH_BUG_NOREKEY) 611 if (datafellows & SSH_BUG_NOREKEY)
599 log("Server does not support re-keying"); 612 logit("Server does not support re-keying");
600 else 613 else
601 need_rekeying = 1; 614 need_rekeying = 1;
602 } 615 }
@@ -655,6 +668,7 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
655"%c?\r\n\ 668"%c?\r\n\
656Supported escape sequences:\r\n\ 669Supported escape sequences:\r\n\
657%c. - terminate connection\r\n\ 670%c. - terminate connection\r\n\
671%cB - send a BREAK to the remote system\r\n\
658%cC - open a command line\r\n\ 672%cC - open a command line\r\n\
659%cR - Request rekey (SSH protocol 2 only)\r\n\ 673%cR - Request rekey (SSH protocol 2 only)\r\n\
660%c^Z - suspend ssh\r\n\ 674%c^Z - suspend ssh\r\n\
@@ -665,7 +679,7 @@ Supported escape sequences:\r\n\
665(Note that escapes are only recognized immediately after newline.)\r\n", 679(Note that escapes are only recognized immediately after newline.)\r\n",
666 escape_char, escape_char, escape_char, escape_char, 680 escape_char, escape_char, escape_char, escape_char,
667 escape_char, escape_char, escape_char, escape_char, 681 escape_char, escape_char, escape_char, escape_char,
668 escape_char, escape_char); 682 escape_char, escape_char, escape_char);
669 buffer_append(berr, string, strlen(string)); 683 buffer_append(berr, string, strlen(string));
670 continue; 684 continue;
671 685
@@ -988,9 +1002,8 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
988 /* Do channel operations unless rekeying in progress. */ 1002 /* Do channel operations unless rekeying in progress. */
989 if (!rekeying) { 1003 if (!rekeying) {
990 channel_after_select(readset, writeset); 1004 channel_after_select(readset, writeset);
991 1005 if (need_rekeying || packet_need_rekeying()) {
992 if (need_rekeying) { 1006 debug("need rekeying");
993 debug("user requests rekeying");
994 xxx_kex->done = 0; 1007 xxx_kex->done = 0;
995 kex_send_kexinit(xxx_kex); 1008 kex_send_kexinit(xxx_kex);
996 need_rekeying = 0; 1009 need_rekeying = 0;
@@ -1181,7 +1194,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
1181 c = channel_new("forwarded-tcpip", 1194 c = channel_new("forwarded-tcpip",
1182 SSH_CHANNEL_CONNECTING, sock, sock, -1, 1195 SSH_CHANNEL_CONNECTING, sock, sock, -1,
1183 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0, 1196 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1184 xstrdup(originator_address), 1); 1197 originator_address, 1);
1185 xfree(originator_address); 1198 xfree(originator_address);
1186 xfree(listen_address); 1199 xfree(listen_address);
1187 return c; 1200 return c;
@@ -1217,8 +1230,7 @@ client_request_x11(const char *request_type, int rchan)
1217 return NULL; 1230 return NULL;
1218 c = channel_new("x11", 1231 c = channel_new("x11",
1219 SSH_CHANNEL_X11_OPEN, sock, sock, -1, 1232 SSH_CHANNEL_X11_OPEN, sock, sock, -1,
1220 CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, 1233 CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, "x11", 1);
1221 xstrdup("x11"), 1);
1222 c->force_drain = 1; 1234 c->force_drain = 1;
1223 return c; 1235 return c;
1224} 1236}
@@ -1240,7 +1252,7 @@ client_request_agent(const char *request_type, int rchan)
1240 c = channel_new("authentication agent connection", 1252 c = channel_new("authentication agent connection",
1241 SSH_CHANNEL_OPEN, sock, sock, -1, 1253 SSH_CHANNEL_OPEN, sock, sock, -1,
1242 CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0, 1254 CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1243 xstrdup("authentication agent connection"), 1); 1255 "authentication agent connection", 1);
1244 c->force_drain = 1; 1256 c->force_drain = 1;
1245 return c; 1257 return c;
1246} 1258}