diff options
author | 2001-01-29 12:36:10 +0000 | |
---|---|---|
committer | 2001-01-29 12:36:10 +0000 | |
commit | cfaddbde98c9990ed792e695454c9bedcbd0651e (patch) | |
tree | 800e22db25c7c8e6ac9f08e7cff9a9b849b66b44 /usr.bin/ssh/ssh.c | |
parent | Add a few ``const''s to silence some -Wwrite-strings warnings (diff) | |
download | wireguard-openbsd-cfaddbde98c9990ed792e695454c9bedcbd0651e.tar.xz wireguard-openbsd-cfaddbde98c9990ed792e695454c9bedcbd0651e.zip |
Allow invocation of sybsystem by commandline (-s); ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r-- | usr.bin/ssh/ssh.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 41e24605e97..6e70e823e60 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.84 2001/01/21 19:05:58 markus Exp $"); +RCSID("$OpenBSD: ssh.c,v 1.85 2001/01/29 12:36:10 djm Exp $"); #include <openssl/evp.h> #include <openssl/err.h> @@ -131,6 +131,9 @@ uid_t original_real_uid; /* command to be executed */ Buffer command; +/* Should we execute a command or invoke a subsystem? */ +int subsystem_flag = 0; + /* Prints a help message to the user. This function never returns. */ void @@ -173,6 +176,7 @@ usage() fprintf(stderr, " -6 Use IPv6 only.\n"); fprintf(stderr, " -2 Force protocol version 2.\n"); fprintf(stderr, " -o 'option' Process the option as if it was read from a configuration file.\n"); + fprintf(stderr, " -s Invoke command (mandatory) as SSH2 subsystem.\n"); exit(1); } @@ -462,6 +466,9 @@ main(int ac, char **av) "command-line", 0, &dummy) != 0) exit(1); break; + case 's': + subsystem_flag = 1; + break; default: usage(); } @@ -485,6 +492,10 @@ main(int ac, char **av) if (optind == ac) { /* No command specified - execute shell on a tty. */ tty_flag = 1; + if (subsystem_flag) { + fprintf(stderr, "You must specify a subsystem to invoke."); + usage(); + } } else { /* A command has been specified. Store it into the buffer. */ @@ -949,8 +960,13 @@ ssh_session2_callback(int id, void *arg) if (len > 0) { if (len > 900) len = 900; - debug("Sending command: %.*s", len, buffer_ptr(&command)); - channel_request_start(id, "exec", 0); + if (subsystem_flag) { + debug("Sending subsystem: %.*s", len, buffer_ptr(&command)); + channel_request_start(id, "subsystem", 0); + } else { + debug("Sending command: %.*s", len, buffer_ptr(&command)); + channel_request_start(id, "exec", 0); + } packet_put_string(buffer_ptr(&command), len); packet_send(); } else { |