summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-02-09 02:36:43 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-02-09 02:36:43 +0000
commit1e7d30611bc8d7c2383fc59133996363f84a5911 (patch)
treeeaf3b67f20366ebcdbd0c4380bdbbe503f591940 /ssh.c
parentb0407fc670012c2f299978ad9e971697437fd006 (diff)
- markus@cvs.openbsd.org 2001/02/06 22:07:42
[ssh.c] fatal() if subsystem fails - markus@cvs.openbsd.org 2001/02/06 22:43:02 [ssh.c] remove confusing callback code - jakob@cvs.openbsd.org 2001/02/06 23:03:24 [ssh.c] add -1 option (force protocol version 1). ok markus@ - jakob@cvs.openbsd.org 2001/02/06 23:06:21 [ssh.c] reorder -{1,2,4,6} options. ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/ssh.c b/ssh.c
index 1d7582333..ddf28c538 100644
--- a/ssh.c
+++ b/ssh.c
@@ -63,6 +63,7 @@ RCSID("$OpenBSD: ssh.c,v 1.93 2001/02/08 19:30:52 itojun Exp $");
63#include "readconf.h" 63#include "readconf.h"
64#include "sshconnect.h" 64#include "sshconnect.h"
65#include "tildexpand.h" 65#include "tildexpand.h"
66#include "dispatch.h"
66#include "misc.h" 67#include "misc.h"
67 68
68#ifdef HAVE___PROGNAME 69#ifdef HAVE___PROGNAME
@@ -180,9 +181,10 @@ usage(void)
180 fprintf(stderr, " -C Enable compression.\n"); 181 fprintf(stderr, " -C Enable compression.\n");
181 fprintf(stderr, " -N Do not execute a shell or command.\n"); 182 fprintf(stderr, " -N Do not execute a shell or command.\n");
182 fprintf(stderr, " -g Allow remote hosts to connect to forwarded ports.\n"); 183 fprintf(stderr, " -g Allow remote hosts to connect to forwarded ports.\n");
184 fprintf(stderr, " -1 Force protocol version 1.\n");
185 fprintf(stderr, " -2 Force protocol version 2.\n");
183 fprintf(stderr, " -4 Use IPv4 only.\n"); 186 fprintf(stderr, " -4 Use IPv4 only.\n");
184 fprintf(stderr, " -6 Use IPv6 only.\n"); 187 fprintf(stderr, " -6 Use IPv6 only.\n");
185 fprintf(stderr, " -2 Force protocol version 2.\n");
186 fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n"); 188 fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n");
187 fprintf(stderr, " -s Invoke command (mandatory) as SSH2 subsystem.\n"); 189 fprintf(stderr, " -s Invoke command (mandatory) as SSH2 subsystem.\n");
188 exit(1); 190 exit(1);
@@ -331,6 +333,9 @@ main(int ac, char **av)
331 optarg = NULL; 333 optarg = NULL;
332 } 334 }
333 switch (opt) { 335 switch (opt) {
336 case '1':
337 options.protocol = SSH_PROTO_1;
338 break;
334 case '2': 339 case '2':
335 options.protocol = SSH_PROTO_2; 340 options.protocol = SSH_PROTO_2;
336 break; 341 break;
@@ -939,6 +944,20 @@ ssh_session(void)
939} 944}
940 945
941void 946void
947client_subsystem_reply(int type, int plen, void *ctxt)
948{
949 int id, len;
950
951 id = packet_get_int();
952 len = buffer_len(&command);
953 len = MAX(len, 900);
954 packet_done();
955 if (type == SSH2_MSG_CHANNEL_FAILURE)
956 fatal("Request for subsystem '%.*s' failed on channel %d",
957 len, buffer_ptr(&command), id);
958}
959
960void
942ssh_session2_callback(int id, void *arg) 961ssh_session2_callback(int id, void *arg)
943{ 962{
944 int len; 963 int len;
@@ -995,7 +1014,11 @@ ssh_session2_callback(int id, void *arg)
995 len = 900; 1014 len = 900;
996 if (subsystem_flag) { 1015 if (subsystem_flag) {
997 debug("Sending subsystem: %.*s", len, buffer_ptr(&command)); 1016 debug("Sending subsystem: %.*s", len, buffer_ptr(&command));
998 channel_request_start(id, "subsystem", 0); 1017 channel_request_start(id, "subsystem", /*want reply*/ 1);
1018 /* register callback for reply */
1019 /* XXX we asume that client_loop has already been called */
1020 dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &client_subsystem_reply);
1021 dispatch_set(SSH2_MSG_CHANNEL_SUCCESS, &client_subsystem_reply);
999 } else { 1022 } else {
1000 debug("Sending command: %.*s", len, buffer_ptr(&command)); 1023 debug("Sending command: %.*s", len, buffer_ptr(&command));
1001 channel_request_start(id, "exec", 0); 1024 channel_request_start(id, "exec", 0);
@@ -1006,10 +1029,10 @@ ssh_session2_callback(int id, void *arg)
1006 channel_request(id, "shell", 0); 1029 channel_request(id, "shell", 0);
1007 } 1030 }
1008 /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */ 1031 /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */
1032
1009done: 1033done:
1010 /* register different callback, etc. XXX */ 1034 /* register different callback, etc. XXX */
1011 packet_set_interactive(interactive); 1035 packet_set_interactive(interactive);
1012 clientloop_set_session_ident(id);
1013} 1036}
1014 1037
1015int 1038int