summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineering.com>2019-03-02 19:53:57 -0600
committerTimothy Pearson <tpearson@raptorengineering.com>2019-03-02 19:53:57 -0600
commit6189a340b0528dfdf5fcb78317aaf259aaa5984d (patch)
treebe7802fa157a55e749ef47f0076bf476c3685ba5
parent315b8914c853078d8bb04a7d16e47d19128ca318 (diff)
downloadxrdp-proprietary-6189a340b0528dfdf5fcb78317aaf259aaa5984d.tar.gz
xrdp-proprietary-6189a340b0528dfdf5fcb78317aaf259aaa5984d.zip
Add master node session recovery support
-rw-r--r--sesman/scp_v0.c2
-rw-r--r--sesman/scp_v1.c2
-rw-r--r--sesman/session.c37
3 files changed, 32 insertions, 9 deletions
diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c
index 13a1bfc8..d610041f 100644
--- a/sesman/scp_v0.c
+++ b/sesman/scp_v0.c
@@ -82,7 +82,7 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
s->bpp, s->type, s->client_ip);
// RAPTOR session management
- pid_t serverpid = raptor_sm_get_pid_for_username(s->username);
+ pid_t serverpid = raptor_sm_get_pid_for_username(s->username, RAPTOR_SM_SERVER_PID_FIELD);
if (serverpid < 0) {
// Session NOT already running
if (s_item != 0) {
diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c
index 607aeca5..c2b3a7bb 100644
--- a/sesman/scp_v1.c
+++ b/sesman/scp_v1.c
@@ -112,7 +112,7 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
slist = session_get_byuser(s->username, &scount, SESMAN_SESSION_STATUS_DISCONNECTED);
// RAPTOR session management
- pid_t serverpid = raptor_sm_get_pid_for_username(s->username);
+ pid_t serverpid = raptor_sm_get_pid_for_username(s->username, RAPTOR_SM_SERVER_PID_FIELD);
if (serverpid < 0) {
// Session NOT already running
scount = 0;
diff --git a/sesman/session.c b/sesman/session.c
index 7a6173bf..8a3453dc 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -681,9 +681,6 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
}
else if (window_manager_pid == 0)
{
- if (session_was_already_running) {
- g_exit(0);
- }
char* remote_server = wait_for_remote_hostname(s->username);
wait_for_remote_xserver(remote_server, display);
env_set_user(s->username,
@@ -696,8 +693,34 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
{
g_free(remote_server);
- // RAPTOR session management
- raptor_sm_run_remote_desktop(s->username, display, "/opt/trinity/bin/starttde");
+// // RAPTOR session management
+// raptor_sm_run_remote_desktop(s->username, display, "/opt/trinity/bin/starttde");
+// g_exit(0);
+
+ struct list * wm_params = (struct list *)NULL;
+ char ** pp2 = (char **)NULL;
+ wm_params = list_create();
+ wm_params->auto_free = 1;
+ /* these are the must have parameters */
+ list_add_item(wm_params, (long)g_strdup("/opt/trinity/bin/starttde"));
+
+ /* make sure it ends with a zero */
+ list_add_item(wm_params, 0);
+ pp2 = (char**)wm_params->items;
+
+ pid_t wmpid;
+ wmpid = raptor_sm_run_remote_server(s->username, pp2, RAPTOR_SM_WM_PID_FIELD, display);
+ log_message(LOG_LEVEL_ALWAYS, "new window manager pid code was %d for user %s", wmpid, s->username);
+
+ if (wmpid >= 0) {
+ raptor_sm_wm_started(s->username, wmpid, RAPTOR_SM_WM_PID_FIELD);
+
+ // Wait for PID exit and remove information from the session database
+ raptor_sm_wait_for_pid_exit(s->username, wmpid);
+ raptor_sm_wm_terminated(s->username);
+ raptor_sm_terminate_server(s->username);
+ }
+
g_exit(0);
auth_set_env(data);
@@ -872,14 +895,14 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c,
/* fire up Xorg */
pid_t serverpid;
- serverpid = raptor_sm_run_remote_server(s->username, pp1);
+ serverpid = raptor_sm_run_remote_server(s->username, pp1, RAPTOR_SM_SERVER_PID_FIELD, -1);
log_message(LOG_LEVEL_ALWAYS, "new server pid code was %d during login for user %s", serverpid, s->username);
if (serverpid >= 0) {
if (!session_was_already_running) {
char *friendlyscreen = g_strdup(screen);
friendlyscreen[0] = ' ';
- raptor_sm_server_started(s->username, serverpid, atoi(friendlyscreen));
+ raptor_sm_server_started(s->username, serverpid, atoi(friendlyscreen), RAPTOR_SM_SERVER_PID_FIELD);
g_free(friendlyscreen);
// Wait for PID exit and remove information from the session database