summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--clientloop.c100
2 files changed, 49 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index ed40993a2..7677647ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,9 @@
21 - deraadt@cvs.openbsd.org 2001/02/08 14:38:54 21 - deraadt@cvs.openbsd.org 2001/02/08 14:38:54
22 [scp.c] 22 [scp.c]
23 memory leak fix, and snprintf throughout 23 memory leak fix, and snprintf throughout
24 - markus@cvs.openbsd.org 2001/02/06 22:43:02
25 [clientloop.c]
26 remove confusing callback code
24 27
2520010208 2820010208
26 - (djm) Don't delete external askpass program in make uninstall target. 29 - (djm) Don't delete external askpass program in make uninstall target.
diff --git a/clientloop.c b/clientloop.c
index 721c27905..d57b300de 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.47 2001/01/29 19:42:35 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.48 2001/02/06 22:43:02 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -127,7 +127,6 @@ static u_int buffer_high;/* Soft max buffer size. */
127static int connection_in; /* Connection to server (input). */ 127static int connection_in; /* Connection to server (input). */
128static int connection_out; /* Connection to server (output). */ 128static int connection_out; /* Connection to server (output). */
129 129
130
131void client_init_dispatch(void); 130void client_init_dispatch(void);
132int session_ident = -1; 131int session_ident = -1;
133 132
@@ -834,12 +833,15 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
834 if (have_pty) 833 if (have_pty)
835 enter_raw_mode(); 834 enter_raw_mode();
836 835
837 /* Check if we should immediately send eof on stdin. */ 836 if (compat20) {
838 if (!compat20) 837 session_ident = ssh2_chan_id;
838 if (escape_char != -1)
839 channel_register_filter(session_ident,
840 simple_escape_filter);
841 } else {
842 /* Check if we should immediately send eof on stdin. */
839 client_check_initial_eof_on_stdin(); 843 client_check_initial_eof_on_stdin();
840 844 }
841 if (compat20 && escape_char != -1)
842 channel_register_filter(ssh2_chan_id, simple_escape_filter);
843 845
844 /* Main loop of the client for the interactive session mode. */ 846 /* Main loop of the client for the interactive session mode. */
845 while (!quit_pending) { 847 while (!quit_pending) {
@@ -1155,6 +1157,42 @@ client_input_channel_open(int type, int plen, void *ctxt)
1155 } 1157 }
1156 xfree(ctype); 1158 xfree(ctype);
1157} 1159}
1160void
1161client_input_channel_req(int type, int plen, void *ctxt)
1162{
1163 Channel *c = NULL;
1164 int id, reply, success = 0;
1165 char *rtype;
1166
1167 id = packet_get_int();
1168 rtype = packet_get_string(NULL);
1169 reply = packet_get_char();
1170
1171 debug("client_input_channel_req: channel %d rtype %s reply %d",
1172 id, rtype, reply);
1173
1174 if (session_ident == -1) {
1175 error("client_input_channel_req: no channel %d", session_ident);
1176 } else if (id != session_ident) {
1177 error("client_input_channel_req: channel %d: wrong channel: %d",
1178 session_ident, id);
1179 }
1180 c = channel_lookup(id);
1181 if (c == NULL) {
1182 error("client_input_channel_req: channel %d: unknown channel", id);
1183 } else if (strcmp(rtype, "exit-status") == 0) {
1184 success = 1;
1185 exit_status = packet_get_int();
1186 packet_done();
1187 }
1188 if (reply) {
1189 packet_start(success ?
1190 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
1191 packet_put_int(c->remote_id);
1192 packet_send();
1193 }
1194 xfree(rtype);
1195}
1158 1196
1159void 1197void
1160client_init_dispatch_20() 1198client_init_dispatch_20()
@@ -1167,7 +1205,7 @@ client_init_dispatch_20()
1167 dispatch_set(SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open); 1205 dispatch_set(SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open);
1168 dispatch_set(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation); 1206 dispatch_set(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation);
1169 dispatch_set(SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); 1207 dispatch_set(SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
1170 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); 1208 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &client_input_channel_req);
1171 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 1209 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
1172} 1210}
1173void 1211void
@@ -1206,49 +1244,3 @@ client_init_dispatch()
1206 else 1244 else
1207 client_init_dispatch_15(); 1245 client_init_dispatch_15();
1208} 1246}
1209
1210void
1211client_input_channel_req(int id, void *arg)
1212{
1213 Channel *c = NULL;
1214 u_int len;
1215 int success = 0;
1216 int reply;
1217 char *rtype;
1218
1219 rtype = packet_get_string(&len);
1220 reply = packet_get_char();
1221
1222 debug("client_input_channel_req: rtype %s reply %d", rtype, reply);
1223
1224 c = channel_lookup(id);
1225 if (c == NULL)
1226 fatal("client_input_channel_req: channel %d: bad channel", id);
1227
1228 if (session_ident == -1) {
1229 error("client_input_channel_req: no channel %d", id);
1230 } else if (id != session_ident) {
1231 error("client_input_channel_req: bad channel %d != %d",
1232 id, session_ident);
1233 } else if (strcmp(rtype, "exit-status") == 0) {
1234 success = 1;
1235 exit_status = packet_get_int();
1236 packet_done();
1237 }
1238 if (reply) {
1239 packet_start(success ?
1240 SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
1241 packet_put_int(c->remote_id);
1242 packet_send();
1243 }
1244 xfree(rtype);
1245}
1246
1247void
1248clientloop_set_session_ident(int id)
1249{
1250 debug2("clientloop_set_session_ident: id %d", id);
1251 session_ident = id;
1252 channel_register_callback(id, SSH2_MSG_CHANNEL_REQUEST,
1253 client_input_channel_req, (void *)0);
1254}