diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: ssh.c,v 1.84 2001/01/21 19:05:58 markus Exp $"); | 42 | RCSID("$OpenBSD: ssh.c,v 1.85 2001/01/29 12:36:10 djm Exp $"); |
43 | 43 | ||
44 | #include <openssl/evp.h> | 44 | #include <openssl/evp.h> |
45 | #include <openssl/err.h> | 45 | #include <openssl/err.h> |
@@ -139,6 +139,9 @@ uid_t original_real_uid; | |||
139 | /* command to be executed */ | 139 | /* command to be executed */ |
140 | Buffer command; | 140 | Buffer command; |
141 | 141 | ||
142 | /* Should we execute a command or invoke a subsystem? */ | ||
143 | int subsystem_flag = 0; | ||
144 | |||
142 | /* Prints a help message to the user. This function never returns. */ | 145 | /* Prints a help message to the user. This function never returns. */ |
143 | 146 | ||
144 | void | 147 | void |
@@ -181,6 +184,7 @@ usage() | |||
181 | fprintf(stderr, " -6 Use IPv6 only.\n"); | 184 | fprintf(stderr, " -6 Use IPv6 only.\n"); |
182 | fprintf(stderr, " -2 Force protocol version 2.\n"); | 185 | fprintf(stderr, " -2 Force protocol version 2.\n"); |
183 | fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n"); | 186 | 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"); | ||
184 | exit(1); | 188 | exit(1); |
185 | } | 189 | } |
186 | 190 | ||
@@ -484,6 +488,9 @@ main(int ac, char **av) | |||
484 | "command-line", 0, &dummy) != 0) | 488 | "command-line", 0, &dummy) != 0) |
485 | exit(1); | 489 | exit(1); |
486 | break; | 490 | break; |
491 | case 's': | ||
492 | subsystem_flag = 1; | ||
493 | break; | ||
487 | default: | 494 | default: |
488 | usage(); | 495 | usage(); |
489 | } | 496 | } |
@@ -507,6 +514,10 @@ main(int ac, char **av) | |||
507 | if (optind == ac) { | 514 | if (optind == ac) { |
508 | /* No command specified - execute shell on a tty. */ | 515 | /* No command specified - execute shell on a tty. */ |
509 | tty_flag = 1; | 516 | tty_flag = 1; |
517 | if (subsystem_flag) { | ||
518 | fprintf(stderr, "You must specify a subsystem to invoke."); | ||
519 | usage(); | ||
520 | } | ||
510 | } else { | 521 | } else { |
511 | /* A command has been specified. Store it into the | 522 | /* A command has been specified. Store it into the |
512 | buffer. */ | 523 | buffer. */ |
@@ -978,8 +989,13 @@ ssh_session2_callback(int id, void *arg) | |||
978 | if (len > 0) { | 989 | if (len > 0) { |
979 | if (len > 900) | 990 | if (len > 900) |
980 | len = 900; | 991 | len = 900; |
981 | debug("Sending command: %.*s", len, buffer_ptr(&command)); | 992 | if (subsystem_flag) { |
982 | channel_request_start(id, "exec", 0); | 993 | debug("Sending subsystem: %.*s", len, buffer_ptr(&command)); |
994 | channel_request_start(id, "subsystem", 0); | ||
995 | } else { | ||
996 | debug("Sending command: %.*s", len, buffer_ptr(&command)); | ||
997 | channel_request_start(id, "exec", 0); | ||
998 | } | ||
983 | packet_put_string(buffer_ptr(&command), len); | 999 | packet_put_string(buffer_ptr(&command), len); |
984 | packet_send(); | 1000 | packet_send(); |
985 | } else { | 1001 | } else { |