diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | clientloop.c | 23 | ||||
-rw-r--r-- | ssh.c | 38 |
3 files changed, 44 insertions, 22 deletions
@@ -32,6 +32,9 @@ | |||
32 | - markus@cvs.openbsd.org 2001/04/05 21:02:46 | 32 | - markus@cvs.openbsd.org 2001/04/05 21:02:46 |
33 | [buffer.c] | 33 | [buffer.c] |
34 | better error message | 34 | better error message |
35 | - markus@cvs.openbsd.org 2001/04/05 21:05:24 | ||
36 | [clientloop.c ssh.c] | ||
37 | don't request a session for 'ssh -N', pointed out slade@shore.net | ||
35 | 38 | ||
36 | 20010405 | 39 | 20010405 |
37 | - OpenBSD CVS Sync | 40 | - OpenBSD CVS Sync |
@@ -4904,4 +4907,4 @@ | |||
4904 | - Wrote replacements for strlcpy and mkdtemp | 4907 | - Wrote replacements for strlcpy and mkdtemp |
4905 | - Released 1.0pre1 | 4908 | - Released 1.0pre1 |
4906 | 4909 | ||
4907 | $Id: ChangeLog,v 1.1072 2001/04/05 23:36:01 mouring Exp $ | 4910 | $Id: ChangeLog,v 1.1073 2001/04/05 23:37:36 mouring Exp $ |
diff --git a/clientloop.c b/clientloop.c index 74610c6b1..ad20b2f0e 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -59,7 +59,7 @@ | |||
59 | */ | 59 | */ |
60 | 60 | ||
61 | #include "includes.h" | 61 | #include "includes.h" |
62 | RCSID("$OpenBSD: clientloop.c,v 1.59 2001/04/05 20:01:10 markus Exp $"); | 62 | RCSID("$OpenBSD: clientloop.c,v 1.60 2001/04/05 21:05:23 markus Exp $"); |
63 | 63 | ||
64 | #include "ssh.h" | 64 | #include "ssh.h" |
65 | #include "ssh1.h" | 65 | #include "ssh1.h" |
@@ -128,6 +128,7 @@ static u_int buffer_high;/* Soft max buffer size. */ | |||
128 | static int connection_in; /* Connection to server (input). */ | 128 | static int connection_in; /* Connection to server (input). */ |
129 | static int connection_out; /* Connection to server (output). */ | 129 | static int connection_out; /* Connection to server (output). */ |
130 | static int need_rekeying; /* Set to non-zero if rekeying is requested. */ | 130 | static int need_rekeying; /* Set to non-zero if rekeying is requested. */ |
131 | static int session_closed = 0; /* In SSH2: login session closed. */ | ||
131 | 132 | ||
132 | void client_init_dispatch(void); | 133 | void client_init_dispatch(void); |
133 | int session_ident = -1; | 134 | int session_ident = -1; |
@@ -788,6 +789,15 @@ simple_escape_filter(Channel *c, char *buf, int len) | |||
788 | return process_escapes(&c->input, &c->output, &c->extended, buf, len); | 789 | return process_escapes(&c->input, &c->output, &c->extended, buf, len); |
789 | } | 790 | } |
790 | 791 | ||
792 | void | ||
793 | client_channel_closed(int id, void *arg) | ||
794 | { | ||
795 | if (id != session_ident) | ||
796 | error("client_channel_closed: id %d != session_ident %d", | ||
797 | id, session_ident); | ||
798 | session_closed = 1; | ||
799 | } | ||
800 | |||
791 | /* | 801 | /* |
792 | * Implements the interactive session with the server. This is called after | 802 | * Implements the interactive session with the server. This is called after |
793 | * the user has been authenticated, and a command has been started on the | 803 | * the user has been authenticated, and a command has been started on the |
@@ -851,6 +861,9 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
851 | if (escape_char != -1) | 861 | if (escape_char != -1) |
852 | channel_register_filter(session_ident, | 862 | channel_register_filter(session_ident, |
853 | simple_escape_filter); | 863 | simple_escape_filter); |
864 | if (session_ident != -1) | ||
865 | channel_register_cleanup(session_ident, | ||
866 | client_channel_closed); | ||
854 | } else { | 867 | } else { |
855 | /* Check if we should immediately send eof on stdin. */ | 868 | /* Check if we should immediately send eof on stdin. */ |
856 | client_check_initial_eof_on_stdin(); | 869 | client_check_initial_eof_on_stdin(); |
@@ -862,12 +875,10 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
862 | /* Process buffered packets sent by the server. */ | 875 | /* Process buffered packets sent by the server. */ |
863 | client_process_buffered_input_packets(); | 876 | client_process_buffered_input_packets(); |
864 | 877 | ||
865 | rekeying = (xxx_kex != NULL && !xxx_kex->done); | 878 | if (compat20 && session_closed && !channel_still_open()) |
866 | |||
867 | if (compat20 && !channel_still_open()) { | ||
868 | debug2("!channel_still_open."); | ||
869 | break; | 879 | break; |
870 | } | 880 | |
881 | rekeying = (xxx_kex != NULL && !xxx_kex->done); | ||
871 | 882 | ||
872 | if (rekeying) { | 883 | if (rekeying) { |
873 | debug("rekeying in progress"); | 884 | debug("rekeying in progress"); |
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: ssh.c,v 1.105 2001/03/26 08:07:09 markus Exp $"); | 42 | RCSID("$OpenBSD: ssh.c,v 1.106 2001/04/05 21:05:24 markus Exp $"); |
43 | 43 | ||
44 | #include <openssl/evp.h> | 44 | #include <openssl/evp.h> |
45 | #include <openssl/err.h> | 45 | #include <openssl/err.h> |
@@ -946,9 +946,6 @@ ssh_session2_callback(int id, void *arg) | |||
946 | 946 | ||
947 | debug("client_init id %d arg %ld", id, (long)arg); | 947 | debug("client_init id %d arg %ld", id, (long)arg); |
948 | 948 | ||
949 | if (no_shell_flag) | ||
950 | goto done; | ||
951 | |||
952 | if (tty_flag) { | 949 | if (tty_flag) { |
953 | struct winsize ws; | 950 | struct winsize ws; |
954 | char *cp; | 951 | char *cp; |
@@ -1011,15 +1008,14 @@ ssh_session2_callback(int id, void *arg) | |||
1011 | } | 1008 | } |
1012 | /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */ | 1009 | /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */ |
1013 | 1010 | ||
1014 | done: | ||
1015 | /* register different callback, etc. XXX */ | 1011 | /* register different callback, etc. XXX */ |
1016 | packet_set_interactive(interactive); | 1012 | packet_set_interactive(interactive); |
1017 | } | 1013 | } |
1018 | 1014 | ||
1019 | int | 1015 | int |
1020 | ssh_session2(void) | 1016 | ssh_session2_command(void) |
1021 | { | 1017 | { |
1022 | int window, packetmax, id; | 1018 | int id, window, packetmax; |
1023 | int in, out, err; | 1019 | int in, out, err; |
1024 | 1020 | ||
1025 | if (stdin_null_flag) { | 1021 | if (stdin_null_flag) { |
@@ -1041,14 +1037,6 @@ ssh_session2(void) | |||
1041 | if (!isatty(err)) | 1037 | if (!isatty(err)) |
1042 | set_nonblock(err); | 1038 | set_nonblock(err); |
1043 | 1039 | ||
1044 | /* XXX should be pre-session */ | ||
1045 | ssh_init_forwarding(); | ||
1046 | |||
1047 | /* If requested, let ssh continue in the background. */ | ||
1048 | if (fork_after_authentication_flag) | ||
1049 | if (daemon(1, 1) < 0) | ||
1050 | fatal("daemon() failed: %.200s", strerror(errno)); | ||
1051 | |||
1052 | window = CHAN_SES_WINDOW_DEFAULT; | 1040 | window = CHAN_SES_WINDOW_DEFAULT; |
1053 | packetmax = CHAN_SES_PACKET_DEFAULT; | 1041 | packetmax = CHAN_SES_PACKET_DEFAULT; |
1054 | if (!tty_flag) { | 1042 | if (!tty_flag) { |
@@ -1060,10 +1048,30 @@ ssh_session2(void) | |||
1060 | window, packetmax, CHAN_EXTENDED_WRITE, | 1048 | window, packetmax, CHAN_EXTENDED_WRITE, |
1061 | xstrdup("client-session"), /*nonblock*/0); | 1049 | xstrdup("client-session"), /*nonblock*/0); |
1062 | 1050 | ||
1051 | debug("channel_new: %d", id); | ||
1052 | |||
1063 | channel_open(id); | 1053 | channel_open(id); |
1064 | channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, | 1054 | channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, |
1065 | ssh_session2_callback, (void *)0); | 1055 | ssh_session2_callback, (void *)0); |
1066 | 1056 | ||
1057 | return id; | ||
1058 | } | ||
1059 | |||
1060 | int | ||
1061 | ssh_session2(void) | ||
1062 | { | ||
1063 | int id; | ||
1064 | |||
1065 | /* XXX should be pre-session */ | ||
1066 | ssh_init_forwarding(); | ||
1067 | |||
1068 | id = no_shell_flag ? -1 : ssh_session2_command(); | ||
1069 | |||
1070 | /* If requested, let ssh continue in the background. */ | ||
1071 | if (fork_after_authentication_flag) | ||
1072 | if (daemon(1, 1) < 0) | ||
1073 | fatal("daemon() failed: %.200s", strerror(errno)); | ||
1074 | |||
1067 | return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id); | 1075 | return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id); |
1068 | } | 1076 | } |
1069 | 1077 | ||