diff options
author | Damien Miller <djm@mindrot.org> | 2001-10-10 07:08:06 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-10-10 07:08:06 +0200 |
commit | ae45246696fed011e1a9941d33b89669c74b3198 (patch) | |
tree | 6f6be5c9b623c09b2e1df73473b1fc4d3dc92e72 /session.c | |
parent | - markus@cvs.openbsd.org 2001/10/09 10:12:08 (diff) | |
download | openssh-ae45246696fed011e1a9941d33b89669c74b3198.tar.xz openssh-ae45246696fed011e1a9941d33b89669c74b3198.zip |
- markus@cvs.openbsd.org 2001/10/09 19:32:49
[session.c]
stat subsystem command before calling do_exec, and return error to client.
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.104 2001/10/09 10:12:08 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.105 2001/10/09 19:32:49 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1672,25 +1672,33 @@ session_pty_req(Session *s) static int session_subsystem_req(Session *s) { + struct stat st; u_int len; int success = 0; - char *subsys = packet_get_string(&len); + char *cmd, *subsys = packet_get_string(&len); int i; packet_done(); log("subsystem request for %s", subsys); for (i = 0; i < options.num_subsystems; i++) { - if(strcmp(subsys, options.subsystem_name[i]) == 0) { - debug("subsystem: exec() %s", options.subsystem_command[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, + strerror(errno)); + break; + } + debug("subsystem: exec() %s", cmd); s->is_subsystem = 1; - do_exec(s, options.subsystem_command[i]); + do_exec(s, cmd); success = 1; } } if (!success) - log("subsystem request for %s failed, subsystem not found", subsys); + log("subsystem request for %s failed, subsystem not found", + subsys); xfree(subsys); return success; |