summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-04-04 23:46:07 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-04-04 23:46:07 +0000
commitbe2cc43c3ad65dc7af5bdd350eccecefa05c80ff (patch)
tree87743bbb2501bd579088303769f73c4f79fd0ad7 /clientloop.c
parent78c261ab4afa9236b54b51663eb35460d2fea635 (diff)
- markus@cvs.openbsd.org 2001/04/04 20:25:38
[channels.c channels.h clientloop.c kex.c kex.h serverloop.c sshconnect2.c sshd.c] more robust rekeying don't send channel data after rekeying is started.
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c75
1 files changed, 45 insertions, 30 deletions
diff --git a/clientloop.c b/clientloop.c
index 1d09a8dd9..4b87e3b6d 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.55 2001/04/04 14:34:58 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.56 2001/04/04 20:25:37 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -127,6 +127,7 @@ static u_long stdin_bytes, stdout_bytes, stderr_bytes;
127static u_int buffer_high;/* Soft max buffer size. */ 127static u_int buffer_high;/* Soft max buffer size. */
128static int connection_in; /* Connection to server (input). */ 128static int connection_in; /* Connection to server (input). */
129static int connection_out; /* Connection to server (output). */ 129static int connection_out; /* Connection to server (output). */
130static int need_rekeying; /* Set to non-zero if rekeying is requested. */
130 131
131void client_init_dispatch(void); 132void client_init_dispatch(void);
132int session_ident = -1; 133int session_ident = -1;
@@ -367,10 +368,10 @@ client_check_window_change(void)
367 368
368void 369void
369client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, 370client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
370 int *maxfdp) 371 int *maxfdp, int rekeying)
371{ 372{
372 /* Add any selections by the channel mechanism. */ 373 /* Add any selections by the channel mechanism. */
373 channel_prepare_select(readsetp, writesetp, maxfdp); 374 channel_prepare_select(readsetp, writesetp, maxfdp, rekeying);
374 375
375 if (!compat20) { 376 if (!compat20) {
376 /* Read from the connection, unless our buffers are full. */ 377 /* Read from the connection, unless our buffers are full. */
@@ -553,8 +554,8 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
553 continue; 554 continue;
554 555
555 case 'R': 556 case 'R':
556 debug("Rekeying"); 557 if (compat20)
557 kex_send_kexinit(xxx_kex); 558 need_rekeying = 1;
558 continue; 559 continue;
559 560
560 case '&': 561 case '&':
@@ -794,9 +795,8 @@ int
794client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) 795client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
795{ 796{
796 fd_set *readset = NULL, *writeset = NULL; 797 fd_set *readset = NULL, *writeset = NULL;
797 int max_fd = 0;
798 double start_time, total_time; 798 double start_time, total_time;
799 int len; 799 int max_fd = 0, len, rekeying = 0;
800 char buf[100]; 800 char buf[100];
801 801
802 debug("Entering interactive session."); 802 debug("Entering interactive session.");
@@ -858,45 +858,60 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
858 /* Process buffered packets sent by the server. */ 858 /* Process buffered packets sent by the server. */
859 client_process_buffered_input_packets(); 859 client_process_buffered_input_packets();
860 860
861 rekeying = (xxx_kex != NULL && !xxx_kex->done);
862
861 if (compat20 && !channel_still_open()) { 863 if (compat20 && !channel_still_open()) {
862 debug2("!channel_still_open."); 864 debug2("!channel_still_open.");
863 break; 865 break;
864 } 866 }
865 867
866 /* 868 if (rekeying) {
867 * Make packets of buffered stdin data, and buffer them for 869 debug("rekeying in progress");
868 * sending to the server. 870 } else {
869 */ 871 /*
870 if (!compat20) 872 * Make packets of buffered stdin data, and buffer
871 client_make_packets_from_stdin_data(); 873 * them for sending to the server.
872 874 */
873 /* 875 if (!compat20)
874 * Make packets from buffered channel data, and enqueue them 876 client_make_packets_from_stdin_data();
875 * for sending to the server.
876 */
877 if (packet_not_very_much_data_to_write())
878 channel_output_poll();
879 877
880 /* 878 /*
881 * Check if the window size has changed, and buffer a message 879 * Make packets from buffered channel data, and
882 * about it to the server if so. 880 * enqueue them for sending to the server.
883 */ 881 */
884 client_check_window_change(); 882 if (packet_not_very_much_data_to_write())
883 channel_output_poll();
885 884
886 if (quit_pending) 885 /*
887 break; 886 * Check if the window size has changed, and buffer a
887 * message about it to the server if so.
888 */
889 client_check_window_change();
888 890
891 if (quit_pending)
892 break;
893 }
889 /* 894 /*
890 * Wait until we have something to do (something becomes 895 * Wait until we have something to do (something becomes
891 * available on one of the descriptors). 896 * available on one of the descriptors).
892 */ 897 */
893 client_wait_until_can_do_something(&readset, &writeset, &max_fd); 898 client_wait_until_can_do_something(&readset, &writeset,
899 &max_fd, rekeying);
894 900
895 if (quit_pending) 901 if (quit_pending)
896 break; 902 break;
897 903
898 /* Do channel operations. */ 904 /* Do channel operations unless rekeying in progress. */
899 channel_after_select(readset, writeset); 905 if (!rekeying) {
906 channel_after_select(readset, writeset);
907
908 if (need_rekeying) {
909 debug("user requests rekeying");
910 xxx_kex->done = 0;
911 kex_send_kexinit(xxx_kex);
912 need_rekeying = 0;
913 }
914 }
900 915
901 /* Buffer input from the connection. */ 916 /* Buffer input from the connection. */
902 client_process_net_input(readset); 917 client_process_net_input(readset);