summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2006-07-06 10:47:06 +0000
committerDamien Miller <djm@cvs.openbsd.org>2006-07-06 10:47:06 +0000
commit41198f1e70baf63ab5763cc2bd680d190cdb13b4 (patch)
tree3a89e969ed0eddc0da8c9b23e7350d41e2953e14 /usr.bin
parent2557013620e372dba851b2f36499f1a34f76957e (diff)
support arguments to Subsystem commands; ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/servconf.c14
-rw-r--r--usr.bin/ssh/servconf.h3
-rw-r--r--usr.bin/ssh/session.c11
-rw-r--r--usr.bin/ssh/sshd_config.56
4 files changed, 24 insertions, 10 deletions
diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c
index d24d19c5284..03edd92f643 100644
--- a/usr.bin/ssh/servconf.c
+++ b/usr.bin/ssh/servconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.c,v 1.150 2006/03/25 13:17:02 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.151 2006/07/06 10:47:05 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -411,6 +411,7 @@ process_server_config_line(ServerOptions *options, char *line,
ServerOpCodes opcode;
u_short port;
u_int i;
+ size_t len;
cp = line;
if ((arg = strdelim(&cp)) == NULL)
@@ -860,6 +861,17 @@ parse_flag:
fatal("%s line %d: Missing subsystem command.",
filename, linenum);
options->subsystem_command[options->num_subsystems] = xstrdup(arg);
+
+ /* Collect arguments (separate to executable) */
+ p = xstrdup(arg);
+ len = strlen(p) + 1;
+ while ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
+ len += 1 + strlen(arg);
+ p = xrealloc(p, 1, len);
+ strlcat(p, " ", len);
+ strlcat(p, arg, len);
+ }
+ options->subsystem_args[options->num_subsystems] = p;
options->num_subsystems++;
break;
diff --git a/usr.bin/ssh/servconf.h b/usr.bin/ssh/servconf.h
index f304e662d4a..5152e936c7f 100644
--- a/usr.bin/ssh/servconf.h
+++ b/usr.bin/ssh/servconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.h,v 1.73 2006/03/25 22:22:43 djm Exp $ */
+/* $OpenBSD: servconf.h,v 1.74 2006/07/06 10:47:05 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -111,6 +111,7 @@ typedef struct {
u_int num_subsystems;
char *subsystem_name[MAX_SUBSYSTEMS];
char *subsystem_command[MAX_SUBSYSTEMS];
+ char *subsystem_args[MAX_SUBSYSTEMS];
u_int num_accept_env;
char *accept_env[MAX_ACCEPT_ENV];
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index 5871699259f..3bb9a896aae 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.204 2006/07/02 22:45:59 stevesk Exp $ */
+/* $OpenBSD: session.c,v 1.205 2006/07/06 10:47:05 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -1419,7 +1419,7 @@ session_subsystem_req(Session *s)
struct stat st;
u_int len;
int success = 0;
- char *cmd, *subsys = packet_get_string(&len);
+ char *prog, *cmd, *subsys = packet_get_string(&len);
u_int i;
packet_check_eom();
@@ -1427,9 +1427,10 @@ session_subsystem_req(Session *s)
for (i = 0; i < options.num_subsystems; i++) {
if (strcmp(subsys, options.subsystem_name[i]) == 0) {
- cmd = options.subsystem_command[i];
- if (stat(cmd, &st) < 0) {
- error("subsystem: cannot stat %s: %s", cmd,
+ prog = options.subsystem_command[i];
+ cmd = options.subsystem_args[i];
+ if (stat(prog, &st) < 0) {
+ error("subsystem: cannot stat %s: %s", prog,
strerror(errno));
break;
}
diff --git a/usr.bin/ssh/sshd_config.5 b/usr.bin/ssh/sshd_config.5
index 77132e21cad..20260d94efe 100644
--- a/usr.bin/ssh/sshd_config.5
+++ b/usr.bin/ssh/sshd_config.5
@@ -34,7 +34,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $OpenBSD: sshd_config.5,v 1.58 2006/07/02 17:12:58 stevesk Exp $
+.\" $OpenBSD: sshd_config.5,v 1.59 2006/07/06 10:47:05 djm Exp $
.Dd September 25, 1999
.Dt SSHD_CONFIG 5
.Os
@@ -643,8 +643,8 @@ The default is
.Dq yes .
.It Cm Subsystem
Configures an external subsystem (e.g. file transfer daemon).
-Arguments should be a subsystem name and a command to execute upon subsystem
-request.
+Arguments should be a subsystem name and a command (with optional arguments)
+to execute upon subsystem request.
The command
.Xr sftp-server 8
implements the