X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/875ec2753a1297bbed3492345f6fd1069fd7f809..9a6fee8b2b42608a177803d2351d3cfe732910d8:/clientloop.c diff --git a/clientloop.c b/clientloop.c index aa8e9bed..f07725bb 100644 --- a/clientloop.c +++ b/clientloop.c @@ -59,7 +59,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: clientloop.c,v 1.100 2002/04/22 21:04:52 markus Exp $"); +RCSID("$OpenBSD: clientloop.c,v 1.108 2003/04/02 09:48:07 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -490,13 +490,13 @@ process_cmdline(void) if (*s == 0) goto out; if (strlen(s) < 2 || s[0] != '-' || !(s[1] == 'L' || s[1] == 'R')) { - log("Invalid command."); + logit("Invalid command."); goto out; } if (s[1] == 'L') local = 1; if (!local && !compat20) { - log("Not supported for SSH protocol version 1."); + logit("Not supported for SSH protocol version 1."); goto out; } s += 2; @@ -507,24 +507,24 @@ process_cmdline(void) sfwd_port, buf, sfwd_host_port) != 3 && sscanf(s, "%5[0-9]/%255[^/]/%5[0-9]", sfwd_port, buf, sfwd_host_port) != 3) { - log("Bad forwarding specification."); + logit("Bad forwarding specification."); goto out; } if ((fwd_port = a2port(sfwd_port)) == 0 || (fwd_host_port = a2port(sfwd_host_port)) == 0) { - log("Bad forwarding port(s)."); + logit("Bad forwarding port(s)."); goto out; } if (local) { if (channel_setup_local_fwd_listener(fwd_port, buf, fwd_host_port, options.gateway_ports) < 0) { - log("Port forwarding failed."); + logit("Port forwarding failed."); goto out; } } else channel_request_remote_forwarding(fwd_port, buf, fwd_host_port); - log("Forwarding port."); + logit("Forwarding port."); out: signal(SIGINT, handler); enter_raw_mode(); @@ -577,7 +577,7 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len) case 'R': if (compat20) { if (datafellows & SSH_BUG_NOREKEY) - log("Server does not support re-keying"); + logit("Server does not support re-keying"); else need_rekeying = 1; } @@ -635,16 +635,18 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len) snprintf(string, sizeof string, "%c?\r\n\ Supported escape sequences:\r\n\ -~. - terminate connection\r\n\ -~C - open a command line\r\n\ -~R - Request rekey (SSH protocol 2 only)\r\n\ -~^Z - suspend ssh\r\n\ -~# - list forwarded connections\r\n\ -~& - background ssh (when waiting for connections to terminate)\r\n\ -~? - this message\r\n\ -~~ - send the escape character by typing it twice\r\n\ +%c. - terminate connection\r\n\ +%cC - open a command line\r\n\ +%cR - Request rekey (SSH protocol 2 only)\r\n\ +%c^Z - suspend ssh\r\n\ +%c# - list forwarded connections\r\n\ +%c& - background ssh (when waiting for connections to terminate)\r\n\ +%c? - this message\r\n\ +%c%c - send the escape character by typing it twice\r\n\ (Note that escapes are only recognized immediately after newline.)\r\n", - escape_char); + escape_char, escape_char, escape_char, escape_char, + escape_char, escape_char, escape_char, escape_char, + escape_char, escape_char); buffer_append(berr, string, strlen(string)); continue; @@ -886,10 +888,16 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) client_init_dispatch(); - /* Set signal handlers to restore non-blocking mode. */ - signal(SIGINT, signal_handler); - signal(SIGQUIT, signal_handler); - signal(SIGTERM, signal_handler); + /* + * Set signal handlers, (e.g. to restore non-blocking mode) + * but don't overwrite SIG_IGN, matches behaviour from rsh(1) + */ + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + signal(SIGINT, signal_handler); + if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) + signal(SIGQUIT, signal_handler); + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) + signal(SIGTERM, signal_handler); if (have_pty) signal(SIGWINCH, window_change_handler); @@ -960,9 +968,8 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) /* Do channel operations unless rekeying in progress. */ if (!rekeying) { channel_after_select(readset, writeset); - - if (need_rekeying) { - debug("user requests rekeying"); + if (need_rekeying || packet_need_rekeying()) { + debug("need rekeying"); xxx_kex->done = 0; kex_send_kexinit(xxx_kex); need_rekeying = 0; @@ -1114,7 +1121,7 @@ client_input_exit_status(int type, u_int32_t seq, void *ctxt) static Channel * client_request_forwarded_tcpip(const char *request_type, int rchan) { - Channel* c = NULL; + Channel *c = NULL; char *listen_address, *originator_address; int listen_port, originator_port; int sock; @@ -1144,7 +1151,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan) return c; } -static Channel* +static Channel * client_request_x11(const char *request_type, int rchan) { Channel *c = NULL; @@ -1180,7 +1187,7 @@ client_request_x11(const char *request_type, int rchan) return c; } -static Channel* +static Channel * client_request_agent(const char *request_type, int rchan) { Channel *c = NULL; @@ -1208,10 +1215,8 @@ client_input_channel_open(int type, u_int32_t seq, void *ctxt) { Channel *c = NULL; char *ctype; - u_int len; int rchan; - int rmaxpack; - int rwindow; + u_int rmaxpack, rwindow, len; ctype = packet_get_string(&len); rchan = packet_get_int();