summaryrefslogtreecommitdiffstats
path: root/sesman/session.c
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineering.com>2019-03-02 19:09:07 -0600
committerTimothy Pearson <tpearson@raptorengineering.com>2019-03-02 19:18:32 -0600
commit58e06a0aa7db8e0762b31304ead0c3e0df5a7be4 (patch)
tree8f4dc9b6a69b5d34ad7e4bcb99e6aafeb052e6b7 /sesman/session.c
parent4ff3578d7aa8116b19ac4d34c5459f61205e8bfa (diff)
downloadxrdp-proprietary-58e06a0aa7db8e0762b31304ead0c3e0df5a7be4.tar.gz
xrdp-proprietary-58e06a0aa7db8e0762b31304ead0c3e0df5a7be4.zip
Add preliminary Raptor session management
Raptorsmiface pulled from latest old master, changelog merged down to single commit Due to the latest raptorsmiface code being used, this will not compile (yet)
Diffstat (limited to 'sesman/session.c')
-rw-r--r--sesman/session.c45
1 files changed, 43 insertions, 2 deletions
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)
{