X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/30460aeb3d3c027b85eba1e4d45de75fb4b9d356..ea18de5d8ee46a07fbabb7baf5c5b8061ea95c6d:/openssh/ssh.c diff --git a/openssh/ssh.c b/openssh/ssh.c index ed03f81..dd44efb 100644 --- a/openssh/ssh.c +++ b/openssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.293 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: ssh.c,v 1.294 2006/10/06 02:29:19 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -497,11 +497,6 @@ main(int ac, char **av) case 'N': no_shell_flag = 1; no_tty_flag = 1; - options.none_switch = 0; - break; - case 'T': - no_tty_flag = 1; - options.none_switch = 0; break; case 'o': dummy = 1; @@ -511,6 +506,13 @@ main(int ac, char **av) exit(255); xfree(line); break; + case 'T': + no_tty_flag = 1; + /* ensure that the user doesn't try to backdoor a */ + /* null cipher switch on an interactive session */ + /* so explicitly disable it no matter what */ + options.none_switch=0; + break; case 's': subsystem_flag = 1; break; @@ -525,14 +527,6 @@ main(int ac, char **av) case 'F': config = optarg; break; - case 'z': - /* make sure we can't turn on the none_switch */ - /* if they try to force a no tty flag on a tty session */ - if (!no_tty_flag) { - options.none_switch = 1; - } - break; - default: usage(); } @@ -1196,6 +1190,9 @@ ssh_session2_open(void) { Channel *c; int window, packetmax, in, out, err; + int sock; + int socksize; + int socksizelen = sizeof(int); if (stdin_null_flag) { in = open(_PATH_DEVNULL, O_RDONLY); @@ -1216,10 +1213,64 @@ ssh_session2_open(void) if (!isatty(err)) set_nonblock(err); + /* we need to check to see if what they want to do about buffer */ + /* sizes here. In a hpn to nonhpn connection we want to limit */ + /* the window size to something reasonable in case the far side */ + /* has the large window bug. In hpn to hpn connection we want to */ + /* use the max window size but allow the user to override it */ + /* lastly if they disabled hpn then use the ssh std window size */ + + /* so why don't we just do a getsockopt() here and set the */ + /* ssh window to that? In the case of a autotuning receive */ + /* window the window would get stuck at the initial buffer */ + /* size generally less than 96k. Therefore we need to set the */ + /* maximum ssh window size to the maximum hpn buffer size */ + /* unless the user hasspecifically set the hpnrcvbufpoll */ + /* to no. In which case we *can* just set the window to the */ + /* minimum of the hpn buffer size and tcp receive buffer size */ + if(options.hpn_disabled) - window = CHAN_SES_WINDOW_DEFAULT; - else - window = options.hpn_buffer_size; + { + options.hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT; + } + else if (datafellows & SSH_BUG_LARGEWINDOW) + { + debug("HPN to Non-HPN Connection"); + if (options.hpn_buffer_size < 0) + options.hpn_buffer_size = 2*1024*1024; + } + else + { + if (options.hpn_buffer_size < 0) + options.hpn_buffer_size = BUFFER_MAX_LEN_HPN; + if (options.tcp_rcv_buf_poll <= 0) + { + /*create a socket but don't connect it */ + /* we use that the get the rcv socket size */ + sock = socket(AF_INET, SOCK_STREAM, 0); + /* if they are using the tcp_rcv_buf option */ + /* attempt to set the buffer size to that */ + if (options.tcp_rcv_buf) + setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&options.tcp_rcv_buf, + sizeof(options.tcp_rcv_buf)); + getsockopt(sock, SOL_SOCKET, SO_RCVBUF, + &socksize, &socksizelen); + close(sock); + debug("socksize %d", socksize); + options.hpn_buffer_size = MIN(socksize,options.hpn_buffer_size); + } + else + { + if (options.tcp_rcv_buf > 0) + options.hpn_buffer_size = MIN(options.tcp_rcv_buf, options.hpn_buffer_size); + } + + } + + debug("Final hpn_buffer_size = %d", options.hpn_buffer_size); + + window = options.hpn_buffer_size; + packetmax = CHAN_SES_PACKET_DEFAULT; if (tty_flag) { window = 4*CHAN_SES_PACKET_DEFAULT;