summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/session.c b/session.c
index a31ff85d8..17227c9ff 100644
--- a/session.c
+++ b/session.c
@@ -56,6 +56,8 @@ RCSID("$OpenBSD: session.c,v 1.128 2002/02/16 00:51:44 markus Exp $");
56#include "serverloop.h" 56#include "serverloop.h"
57#include "canohost.h" 57#include "canohost.h"
58#include "session.h" 58#include "session.h"
59#include "monitor.h"
60#include "monitor_wrap.h"
59 61
60#ifdef HAVE_CYGWIN 62#ifdef HAVE_CYGWIN
61#include <windows.h> 63#include <windows.h>
@@ -63,39 +65,15 @@ RCSID("$OpenBSD: session.c,v 1.128 2002/02/16 00:51:44 markus Exp $");
63#define is_winnt (GetVersion() < 0x80000000) 65#define is_winnt (GetVersion() < 0x80000000)
64#endif 66#endif
65 67
66/* types */ 68/* Imports */
67 69extern int use_privsep;
68#define TTYSZ 64 70extern int mm_recvfd;
69typedef struct Session Session;
70struct Session {
71 int used;
72 int self;
73 struct passwd *pw;
74 Authctxt *authctxt;
75 pid_t pid;
76 /* tty */
77 char *term;
78 int ptyfd, ttyfd, ptymaster;
79 int row, col, xpixel, ypixel;
80 char tty[TTYSZ];
81 /* X11 */
82 int display_number;
83 char *display;
84 int screen;
85 char *auth_display;
86 char *auth_proto;
87 char *auth_data;
88 int single_connection;
89 /* proto 2 */
90 int chanid;
91 int is_subsystem;
92};
93 71
94/* func */ 72/* func */
95 73
96Session *session_new(void); 74Session *session_new(void);
97void session_set_fds(Session *, int, int, int); 75void session_set_fds(Session *, int, int, int);
98static void session_pty_cleanup(void *); 76void session_pty_cleanup(void *);
99void session_proctitle(Session *); 77void session_proctitle(Session *);
100int session_setup_x11fwd(Session *); 78int session_setup_x11fwd(Session *);
101void do_exec_pty(Session *, const char *); 79void do_exec_pty(Session *, const char *);
@@ -112,7 +90,6 @@ int check_quietlogin(Session *, const char *);
112static void do_authenticated1(Authctxt *); 90static void do_authenticated1(Authctxt *);
113static void do_authenticated2(Authctxt *); 91static void do_authenticated2(Authctxt *);
114 92
115static void session_close(Session *);
116static int session_pty_req(Session *); 93static int session_pty_req(Session *);
117 94
118/* import */ 95/* import */
@@ -1448,7 +1425,8 @@ session_pty_req(Session *s)
1448{ 1425{
1449 u_int len; 1426 u_int len;
1450 int n_bytes; 1427 int n_bytes;
1451 1428 int res;
1429
1452 if (no_pty_flag) { 1430 if (no_pty_flag) {
1453 debug("Allocating a pty not permitted for this authentication."); 1431 debug("Allocating a pty not permitted for this authentication.");
1454 return 0; 1432 return 0;
@@ -1477,7 +1455,15 @@ session_pty_req(Session *s)
1477 1455
1478 /* Allocate a pty and open it. */ 1456 /* Allocate a pty and open it. */
1479 debug("Allocating pty."); 1457 debug("Allocating pty.");
1480 if (!pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty))) { 1458 if (!use_privsep) {
1459 res = pty_allocate(&s->ptyfd, &s->ttyfd, s->tty,
1460 sizeof(s->tty));
1461 if (res)
1462 pty_setowner(s->pw, s->tty);
1463 } else
1464 res = mm_pty_allocown(mm_recvfd,
1465 &s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty));
1466 if (!res) {
1481 if (s->term) 1467 if (s->term)
1482 xfree(s->term); 1468 xfree(s->term);
1483 s->term = NULL; 1469 s->term = NULL;
@@ -1498,7 +1484,6 @@ session_pty_req(Session *s)
1498 * time in case we call fatal() (e.g., the connection gets closed). 1484 * time in case we call fatal() (e.g., the connection gets closed).
1499 */ 1485 */
1500 fatal_add_cleanup(session_pty_cleanup, (void *)s); 1486 fatal_add_cleanup(session_pty_cleanup, (void *)s);
1501 pty_setowner(s->pw, s->tty);
1502 1487
1503 /* Set window size from the packet. */ 1488 /* Set window size from the packet. */
1504 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); 1489 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);
@@ -1661,7 +1646,7 @@ session_set_fds(Session *s, int fdin, int fdout, int fderr)
1661 * Function to perform pty cleanup. Also called if we get aborted abnormally 1646 * Function to perform pty cleanup. Also called if we get aborted abnormally
1662 * (e.g., due to a dropped connection). 1647 * (e.g., due to a dropped connection).
1663 */ 1648 */
1664static void 1649void
1665session_pty_cleanup(void *session) 1650session_pty_cleanup(void *session)
1666{ 1651{
1667 Session *s = session; 1652 Session *s = session;
@@ -1739,7 +1724,7 @@ session_exit_message(Session *s, int status)
1739 s->chanid = -1; 1724 s->chanid = -1;
1740} 1725}
1741 1726
1742static void 1727void
1743session_close(Session *s) 1728session_close(Session *s)
1744{ 1729{
1745 debug("session_close: session %d pid %d", s->self, s->pid); 1730 debug("session_close: session %d pid %d", s->self, s->pid);