summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-10-10 15:08:06 +1000
committerDamien Miller <djm@mindrot.org>2001-10-10 15:08:06 +1000
commitae45246696fed011e1a9941d33b89669c74b3198 (patch)
tree6f6be5c9b623c09b2e1df73473b1fc4d3dc92e72 /session.c
parent139d4cd9087bb3eaf751406016bc2223d7d0d7b1 (diff)
- 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.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/session.c b/session.c
index 0e3e933f9..c1305da6a 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.104 2001/10/09 10:12:08 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.105 2001/10/09 19:32:49 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -1672,25 +1672,33 @@ session_pty_req(Session *s)
1672static int 1672static int
1673session_subsystem_req(Session *s) 1673session_subsystem_req(Session *s)
1674{ 1674{
1675 struct stat st;
1675 u_int len; 1676 u_int len;
1676 int success = 0; 1677 int success = 0;
1677 char *subsys = packet_get_string(&len); 1678 char *cmd, *subsys = packet_get_string(&len);
1678 int i; 1679 int i;
1679 1680
1680 packet_done(); 1681 packet_done();
1681 log("subsystem request for %s", subsys); 1682 log("subsystem request for %s", subsys);
1682 1683
1683 for (i = 0; i < options.num_subsystems; i++) { 1684 for (i = 0; i < options.num_subsystems; i++) {
1684 if(strcmp(subsys, options.subsystem_name[i]) == 0) { 1685 if (strcmp(subsys, options.subsystem_name[i]) == 0) {
1685 debug("subsystem: exec() %s", options.subsystem_command[i]); 1686 cmd = options.subsystem_command[i];
1687 if (stat(cmd, &st) < 0) {
1688 error("subsystem: cannot stat %s: %s", cmd,
1689 strerror(errno));
1690 break;
1691 }
1692 debug("subsystem: exec() %s", cmd);
1686 s->is_subsystem = 1; 1693 s->is_subsystem = 1;
1687 do_exec(s, options.subsystem_command[i]); 1694 do_exec(s, cmd);
1688 success = 1; 1695 success = 1;
1689 } 1696 }
1690 } 1697 }
1691 1698
1692 if (!success) 1699 if (!success)
1693 log("subsystem request for %s failed, subsystem not found", subsys); 1700 log("subsystem request for %s failed, subsystem not found",
1701 subsys);
1694 1702
1695 xfree(subsys); 1703 xfree(subsys);
1696 return success; 1704 return success;