summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/session.c b/session.c
index d1925334d..800f21127 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.63 2001/03/20 19:21:21 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.64 2001/03/20 19:35:29 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -100,7 +100,6 @@ typedef struct Session Session;
100struct Session { 100struct Session {
101 int used; 101 int used;
102 int self; 102 int self;
103 int extended;
104 struct passwd *pw; 103 struct passwd *pw;
105 pid_t pid; 104 pid_t pid;
106 /* tty */ 105 /* tty */
@@ -116,6 +115,7 @@ struct Session {
116 int single_connection; 115 int single_connection;
117 /* proto 2 */ 116 /* proto 2 */
118 int chanid; 117 int chanid;
118 int is_subsystem;
119}; 119};
120 120
121/* func */ 121/* func */
@@ -555,11 +555,11 @@ do_exec_no_pty(Session *s, const char *command)
555 close(perr[1]); 555 close(perr[1]);
556 556
557 if (compat20) { 557 if (compat20) {
558 session_set_fds(s, pin[1], pout[0], s->extended ? perr[0] : -1); 558 session_set_fds(s, pin[1], pout[0], s->is_subsystem ? -1 : perr[0]);
559 } else { 559 } else {
560 /* Enter the interactive session. */ 560 /* Enter the interactive session. */
561 server_loop(pid, pin[1], pout[0], perr[0]); 561 server_loop(pid, pin[1], pout[0], perr[0]);
562 /* server_loop has closed pin[1], pout[1], and perr[1]. */ 562 /* server_loop has closed pin[1], pout[0], and perr[0]. */
563 } 563 }
564#else /* USE_PIPES */ 564#else /* USE_PIPES */
565 /* We are the parent. Close the child sides of the socket pairs. */ 565 /* We are the parent. Close the child sides of the socket pairs. */
@@ -571,7 +571,7 @@ do_exec_no_pty(Session *s, const char *command)
571 * handle the case that fdin and fdout are the same. 571 * handle the case that fdin and fdout are the same.
572 */ 572 */
573 if (compat20) { 573 if (compat20) {
574 session_set_fds(s, inout[1], inout[1], s->extended ? err[1] : -1); 574 session_set_fds(s, inout[1], inout[1], s->is_subsystem ? -1 : err[1]);
575 } else { 575 } else {
576 server_loop(pid, inout[1], inout[1], err[1]); 576 server_loop(pid, inout[1], inout[1], err[1]);
577 /* server_loop has closed inout[1] and err[1]. */ 577 /* server_loop has closed inout[1] and err[1]. */
@@ -1504,7 +1504,7 @@ session_new(void)
1504 Session *s = &sessions[i]; 1504 Session *s = &sessions[i];
1505 if (! s->used) { 1505 if (! s->used) {
1506 s->pid = 0; 1506 s->pid = 0;
1507 s->extended = 0; 1507 s->is_subsystem = 0;
1508 s->chanid = -1; 1508 s->chanid = -1;
1509 s->ptyfd = -1; 1509 s->ptyfd = -1;
1510 s->ttyfd = -1; 1510 s->ttyfd = -1;
@@ -1661,6 +1661,7 @@ session_subsystem_req(Session *s)
1661 for (i = 0; i < options.num_subsystems; i++) { 1661 for (i = 0; i < options.num_subsystems; i++) {
1662 if(strcmp(subsys, options.subsystem_name[i]) == 0) { 1662 if(strcmp(subsys, options.subsystem_name[i]) == 0) {
1663 debug("subsystem: exec() %s", options.subsystem_command[i]); 1663 debug("subsystem: exec() %s", options.subsystem_command[i]);
1664 s->is_subsystem = 1;
1664 do_exec_no_pty(s, options.subsystem_command[i]); 1665 do_exec_no_pty(s, options.subsystem_command[i]);
1665 success = 1; 1666 success = 1;
1666 } 1667 }
@@ -1735,7 +1736,6 @@ session_shell_req(Session *s)
1735 /* if forced_command == NULL, the shell is execed */ 1736 /* if forced_command == NULL, the shell is execed */
1736 char *shell = forced_command; 1737 char *shell = forced_command;
1737 packet_done(); 1738 packet_done();
1738 s->extended = 1;
1739 if (s->ttyfd == -1) 1739 if (s->ttyfd == -1)
1740 do_exec_no_pty(s, shell); 1740 do_exec_no_pty(s, shell);
1741 else 1741 else
@@ -1754,7 +1754,6 @@ session_exec_req(Session *s)
1754 command = forced_command; 1754 command = forced_command;
1755 debug("Forced command '%.500s'", forced_command); 1755 debug("Forced command '%.500s'", forced_command);
1756 } 1756 }
1757 s->extended = 1;
1758 if (s->ttyfd == -1) 1757 if (s->ttyfd == -1)
1759 do_exec_no_pty(s, command); 1758 do_exec_no_pty(s, command);
1760 else 1759 else
@@ -1805,8 +1804,8 @@ session_input_channel_req(int id, void *arg)
1805 s->self, id, rtype, reply); 1804 s->self, id, rtype, reply);
1806 1805
1807 /* 1806 /*
1808 * a session is in LARVAL state until a shell 1807 * a session is in LARVAL state until a shell, a command
1809 * or programm is executed 1808 * or a subsystem is executed
1810 */ 1809 */
1811 if (c->type == SSH_CHANNEL_LARVAL) { 1810 if (c->type == SSH_CHANNEL_LARVAL) {
1812 if (strcmp(rtype, "shell") == 0) { 1811 if (strcmp(rtype, "shell") == 0) {