summaryrefslogtreecommitdiffstats
path: root/sesman
diff options
context:
space:
mode:
Diffstat (limited to 'sesman')
-rw-r--r--sesman/Makefile.am4
-rw-r--r--sesman/chansrv/Makefile.am4
-rw-r--r--sesman/chansrv/chansrv.c36
-rw-r--r--sesman/sesman.ini.in2
-rw-r--r--sesman/session.c45
5 files changed, 86 insertions, 5 deletions
diff --git a/sesman/Makefile.am b/sesman/Makefile.am
index 50425e63..50a9fafc 100644
--- a/sesman/Makefile.am
+++ b/sesman/Makefile.am
@@ -9,7 +9,8 @@ AM_CPPFLAGS = \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common \
- -I$(top_srcdir)/sesman/libscp
+ -I$(top_srcdir)/sesman/libscp \
+ -I$(top_srcdir)/raptorsmiface
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
@@ -70,6 +71,7 @@ xrdp_sesman_SOURCES = \
xrdp_sesman_LDADD = \
$(top_builddir)/common/libcommon.la \
$(top_builddir)/sesman/libscp/libscp.la \
+ $(top_builddir)/raptorsmiface/libraptorsmiface.la \
$(AUTH_LIB) \
-lpthread
diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am
index 05007757..2b22312c 100644
--- a/sesman/chansrv/Makefile.am
+++ b/sesman/chansrv/Makefile.am
@@ -9,7 +9,8 @@ AM_CPPFLAGS = \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
- -I$(top_srcdir)/common
+ -I$(top_srcdir)/common \
+ -I$(top_srcdir)/raptorsmiface
if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG
@@ -77,5 +78,6 @@ xrdp_chansrv_LDFLAGS = \
xrdp_chansrv_LDADD = \
$(top_builddir)/common/libcommon.la \
+ $(top_builddir)/raptorsmiface/libraptorsmiface.la \
$(X_PRE_LIBS) -lXfixes -lXrandr -lX11 $(X_EXTRA_LIBS) \
$(CHANSRV_EXTRA_LIBS)
diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c
index 7a0de556..12614f51 100644
--- a/sesman/chansrv/chansrv.c
+++ b/sesman/chansrv/chansrv.c
@@ -1,6 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
+ * Copyright (C) Timothy Pearson 2012-2019
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Laxmikant Rashinkar 2009-2012
*
@@ -38,6 +39,8 @@
#include "chansrv_fuse.h"
#include "xrdp_sockets.h"
+#include "libraptorsmiface.h"
+
static struct trans *g_lis_trans = 0;
static struct trans *g_con_trans = 0;
static struct trans *g_api_lis_trans = 0;
@@ -60,6 +63,32 @@ int g_rdpsnd_chan_id = -1; /* rdpsnd */
int g_rdpdr_chan_id = -1; /* rdpdr */
int g_rail_chan_id = -1; /* rail */
+#if 0
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+void dprint(const char *fmt, ...)
+{
+ va_list argp;
+ va_start(argp, fmt);
+ char debug[1024];
+ vsprintf(debug, fmt, argp);
+ FILE *fp = fopen("/chansrv.debug", "a");
+ if (fp != NULL)
+ {
+ fputs(debug, fp);
+ fclose(fp);
+ }
+ va_end(argp);
+}
+#undef LOG
+#define LOG(_a, _params) \
+{ \
+ dprint _params; \
+ dprint("\n"); \
+}
+#endif
+
char *g_exec_name;
tbus g_exec_event;
tbus g_exec_mutex;
@@ -414,6 +443,8 @@ process_message_channel_setup(struct stream *s)
rail_init();
}
+ // Use the display number to mark session connected in the Raptor session management database
+ raptor_sm_set_session_state(g_display_num, SM_STATUS_CONNECTED);
return rv;
}
@@ -1435,6 +1466,9 @@ channel_thread_loop(void *in_val)
/* delete g_con_trans */
trans_delete(g_con_trans);
g_con_trans = 0;
+ /* use the display number to mark session disconnected in the Raptor session management database */
+ raptor_sm_set_session_state(g_display_num, SM_STATUS_RUNNING);
+ exit(0); // RAPTOR session management
/* create new listener */
error = setup_listen();
@@ -1904,6 +1938,8 @@ main(int argc, char **argv)
}
}
+ /* use the display number to mark session disconnected in the Raptor session management database */
+ raptor_sm_set_session_state(g_display_num, SM_STATUS_RUNNING);
/* cleanup */
main_cleanup();
LOGM((LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid));
diff --git a/sesman/sesman.ini.in b/sesman/sesman.ini.in
index 9af7a100..d8d8ea94 100644
--- a/sesman/sesman.ini.in
+++ b/sesman/sesman.ini.in
@@ -29,7 +29,7 @@ X11DisplayOffset=10
;; MaxSessions - maximum number of connections to an xrdp server
; Type: integer
; Default: 0
-MaxSessions=50
+MaxSessions=1000000
;; KillDisconnected - kill disconnected sessions
; Type: boolean
diff --git a/sesman/session.c b/sesman/session.c
index 0d9fdc70..6fa63c3a 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -42,6 +42,8 @@
#include "xauth.h"
#include "xrdp_sockets.h"
+#include "libraptorsmiface.h"
+
#ifndef PR_SET_NO_NEW_PRIVS
#define PR_SET_NO_NEW_PRIVS 38
#endif
@@ -448,7 +450,21 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
return 0;
}
- display = session_get_avail_display_from_chain();
+ char session_was_already_running = 0;
+ int allocdisplay = raptor_sm_get_display_for_username(s->username);
+ if (allocdisplay >= 0) {
+ session_was_already_running = 1;
+ display = allocdisplay;
+ }
+ else {
+ int allocdisplay = raptor_sm_get_new_unique_display(g_cfg->sess.x11_display_offset, g_cfg->sess.max_sessions);
+ if (allocdisplay < 0) {
+ display = 0;
+ }
+ else {
+ display = allocdisplay;
+ }
+ }
if (display == 0)
{
@@ -533,6 +549,9 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
display,
g_cfg->env_names,
g_cfg->env_values);
+ if (session_was_already_running) {
+ g_exit(0);
+ }
if (x_server_running(display))
{
auth_set_env(data);
@@ -705,7 +724,29 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
g_setenv("XRDP_START_HEIGHT", geometry, 1);
/* fire up Xorg */
- g_execvp(xserver, pp1);
+ pid_t serverpid;
+ serverpid = raptor_sm_run_remote_server(s->username, pp1);
+
+ if (serverpid >= 0) {
+ if (!session_was_already_running) {
+ char *friendlyscreen = g_strdup(screen);
+ friendlyscreen[0] = ' ';
+ raptor_sm_server_started(s->username, serverpid, atoi(friendlyscreen));
+ g_free(friendlyscreen);
+
+ // Wait for PID exit and remove information from the session database
+ raptor_sm_wait_for_pid_exit(s->username, serverpid);
+ raptor_sm_session_terminated(s->username);
+ }
+ }
+ else {
+ raptor_sm_session_terminated(s->username);
+ log_message(LOG_LEVEL_WARNING, "max concurrent session limit "
+ "exceeded in group. login for user %s denied", s->username);
+ g_exit(1);
+ }
+
+ g_exit(0);
}
else if (type == SESMAN_SESSION_TYPE_XVNC)
{