summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2015-12-11 20:41:17 -0800
committerJay Sorg <jay.sorg@gmail.com>2015-12-11 20:41:17 -0800
commit4e0d0f3ba06028c27f80b47dacbd8a7d323e7a93 (patch)
tree4fc02867a31074a1ab57ce8b8587af05a425b8e3
parent4f128c530c6b7bfd014f23878f83bcd2369f793f (diff)
downloadxrdp-proprietary-4e0d0f3ba06028c27f80b47dacbd8a7d323e7a93.tar.gz
xrdp-proprietary-4e0d0f3ba06028c27f80b47dacbd8a7d323e7a93.zip
sesman: remove the thread
-rw-r--r--sesman/Makefile.am6
-rw-r--r--sesman/access.c2
-rw-r--r--sesman/lock.c121
-rw-r--r--sesman/lock.h104
-rw-r--r--sesman/scp.c10
-rw-r--r--sesman/scp_v0.c4
-rw-r--r--sesman/scp_v1.c2
-rw-r--r--sesman/sesman.c32
-rw-r--r--sesman/sesman.h3
-rw-r--r--sesman/session.c220
-rw-r--r--sesman/session.h9
-rw-r--r--sesman/thread.c173
-rw-r--r--sesman/thread.h56
13 files changed, 63 insertions, 679 deletions
diff --git a/sesman/Makefile.am b/sesman/Makefile.am
index 516639f4..55056031 100644
--- a/sesman/Makefile.am
+++ b/sesman/Makefile.am
@@ -1,4 +1,6 @@
-EXTRA_DIST = sesman.ini startwm.sh sesman.h access.h auth.h config.h env.h lock.h scp.h scp_v0.h scp_v1.h scp_v1_mng.h session.h sig.h thread.h
+
+EXTRA_DIST = sesman.ini startwm.sh sesman.h access.h auth.h config.h env.h \
+scp.h scp_v0.h scp_v1.h scp_v1_mng.h session.h sig.h
AM_CFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
@@ -44,8 +46,6 @@ xrdp_sesman_SOURCES = \
sesman.c \
session.c \
sig.c \
- thread.c \
- lock.c \
access.c \
config.c \
env.c \
diff --git a/sesman/access.c b/sesman/access.c
index 1ba22df4..269b9e77 100644
--- a/sesman/access.c
+++ b/sesman/access.c
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2013
+ * Copyright (C) Jay Sorg 2004-2015
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sesman/lock.c b/sesman/lock.c
deleted file mode 100644
index 6337a541..00000000
--- a/sesman/lock.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2013
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * session manager
- * linux only
- */
-
-#include "sesman.h"
-
-extern struct config_sesman *g_cfg; /* in sesman.c */
-
-static tbus g_sync_mutex = 0;
-static tbus g_lock_chain = 0;
-static tbus g_sync_sem = 0;
-static tbus g_lock_socket = 0;
-
-/******************************************************************************/
-void APP_CC
-lock_init(void)
-{
- g_sync_mutex = tc_mutex_create();
- g_lock_chain = tc_mutex_create();
- g_sync_sem = tc_sem_create(0);
- g_lock_socket = tc_sem_create(1);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_deinit(void)
-{
- tc_mutex_delete(g_sync_mutex);
- tc_mutex_delete(g_lock_chain);
- tc_sem_delete(g_sync_sem);
- tc_sem_delete(g_lock_socket);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_chain_acquire(void)
-{
- /* lock the chain */
- LOG_DBG("lock_chain_acquire()");
- tc_mutex_lock(g_lock_chain);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_chain_release(void)
-{
- /* unlock the chain */
- LOG_DBG("lock_chain_release()");
- tc_mutex_unlock(g_lock_chain);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_socket_acquire(void)
-{
- /* lock socket variable */
- LOG_DBG("lock_socket_acquire()");
- tc_sem_dec(g_lock_socket);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_socket_release(void)
-{
- /* unlock socket variable */
- LOG_DBG("lock_socket_release()");
- tc_sem_inc(g_lock_socket);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_sync_acquire(void)
-{
- /* lock sync variable */
- LOG_DBG("lock_sync_acquire()");
- tc_mutex_lock(g_sync_mutex);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_sync_release(void)
-{
- /* unlock socket variable */
- LOG_DBG("lock_sync_release()");
- tc_mutex_unlock(g_sync_mutex);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_sync_sem_acquire(void)
-{
- /* dec sem */
- LOG_DBG("lock_sync_sem_acquire()");
- tc_sem_dec(g_sync_sem);
-}
-
-/******************************************************************************/
-void APP_CC
-lock_sync_sem_release(void)
-{
- /* inc sem */
- LOG_DBG("lock_sync_sem_release()");
- tc_sem_inc(g_sync_sem);
-}
diff --git a/sesman/lock.h b/sesman/lock.h
deleted file mode 100644
index 1fd968ef..00000000
--- a/sesman/lock.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2013
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LOCK_H
-#define LOCK_H
-
-#include "sesman.h"
-
-/**
- *
- * @brief initializes all the locks
- *
- */
-void APP_CC
-lock_init(void);
-
-/**
- *
- * @brief cleanup all the locks
- *
- */
-void APP_CC
-lock_deinit(void);
-
-/**
- *
- * @brief acquires the lock for the session chain
- *
- */
-void APP_CC
-lock_chain_acquire(void);
-
-/**
- *
- * @brief releases the session chain lock
- *
- */
-void APP_CC
-lock_chain_release(void);
-
-/**
- *
- * @brief request the socket lock
- *
- */
-void APP_CC
-lock_socket_acquire(void);
-
-/**
- *
- * @brief releases the socket lock
- *
- */
-void APP_CC
-lock_socket_release(void);
-
-/**
- *
- * @brief request the main sync lock
- *
- */
-void APP_CC
-lock_sync_acquire(void);
-
-/**
- *
- * @brief releases the main sync lock
- *
- */
-void APP_CC
-lock_sync_release(void);
-
-/**
- *
- * @brief request the sync sem lock
- *
- */
-void APP_CC
-lock_sync_sem_acquire(void);
-
-/**
- *
- * @brief releases the sync sem lock
- *
- */
-void APP_CC
-lock_sync_sem_release(void);
-
-#endif
diff --git a/sesman/scp.c b/sesman/scp.c
index 076d57b2..fdb81a04 100644
--- a/sesman/scp.c
+++ b/sesman/scp.c
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2013
+ * Copyright (C) Jay Sorg 2004-2015
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@
#include "sesman.h"
-extern int g_thread_sck; /* in thread.c */
extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
@@ -39,14 +38,9 @@ scp_process_start(void *sck)
struct SCP_CONNECTION scon;
struct SCP_SESSION *sdata;
- /* making a local copy of the socket (it's on the stack) */
- /* probably this is just paranoia */
- scon.in_sck = g_thread_sck;
+ scon.in_sck = (int)(tintptr)sck;
LOG_DBG("started scp thread on socket %d", scon.in_sck);
- /* unlocking g_thread_sck */
- lock_socket_release();
-
make_stream(scon.in_s);
make_stream(scon.out_s);
diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c
index 7ffdb1e2..efa9080c 100644
--- a/sesman/scp_v0.c
+++ b/sesman/scp_v0.c
@@ -35,9 +35,9 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
int display = 0;
tbus data;
struct session_item *s_item;
- int errorcode = 0 ;
+ int errorcode = 0;
- data = auth_userpass(s->username, s->password,&errorcode);
+ data = auth_userpass(s->username, s->password, &errorcode);
if (s->type == SCP_GW_AUTHENTICATION)
{
diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c
index 2324b750..a0fff6d9 100644
--- a/sesman/scp_v1.c
+++ b/sesman/scp_v1.c
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2013
+ * Copyright (C) Jay Sorg 2004-2015
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sesman/sesman.c b/sesman/sesman.c
index 9a3e915e..924a7ae8 100644
--- a/sesman/sesman.c
+++ b/sesman/sesman.c
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2013
+ * Copyright (C) Jay Sorg 2004-2015
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,10 +31,7 @@ int g_pid;
unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 };
struct config_sesman *g_cfg; /* defined in config.h */
-tbus g_term_event = 0;
-tbus g_sync_event = 0;
-
-extern int g_thread_sck; /* in thread.c */
+tintptr g_term_event = 0;
/******************************************************************************/
/**
@@ -49,6 +46,7 @@ sesman_main_loop(void)
int error;
int robjs_count;
int cont;
+ int pid;
tbus sck_obj;
tbus robjs[8];
@@ -80,7 +78,6 @@ sesman_main_loop(void)
robjs_count = 0;
robjs[robjs_count++] = sck_obj;
robjs[robjs_count++] = g_term_event;
- robjs[robjs_count++] = g_sync_event;
/* wait */
if (g_obj_wait(robjs, robjs_count, 0, 0, -1) != 0)
@@ -94,12 +91,6 @@ sesman_main_loop(void)
break;
}
- if (g_is_wait_obj_set(g_sync_event)) /* sync */
- {
- g_reset_wait_obj(g_sync_event);
- session_sync_start();
- }
-
if (g_is_wait_obj_set(sck_obj)) /* incoming connection */
{
in_sck = g_tcp_accept(g_sck);
@@ -118,8 +109,8 @@ sesman_main_loop(void)
{
/* we've got a connection, so we pass it to scp code */
LOG_DBG("new connection");
- thread_scp_start(in_sck);
- /* todo, do we have to wait here ? */
+ scp_process_start((void*)(tintptr)in_sck);
+ g_sck_close(in_sck);
}
}
}
@@ -138,9 +129,7 @@ sesman_main_loop(void)
"port '%s': %d (%s)", g_cfg->listen_port,
g_get_errno(), g_get_strerror());
}
-
- if (g_sck != -1)
- g_tcp_close(g_sck);
+ g_tcp_close(g_sck);
}
/******************************************************************************/
@@ -292,6 +281,9 @@ main(int argc, char **argv)
g_writeln("error opening log file [%s]. quitting.",
getLogFile(text, 255));
break;
+ default:
+ g_writeln("error");
+ break;
}
g_deinit();
@@ -329,9 +321,6 @@ main(int argc, char **argv)
}
}
- /* initializing locks */
- lock_init();
-
/* signal handling */
g_pid = g_getpid();
/* old style signal handling is now managed synchronously by a
@@ -387,8 +376,6 @@ main(int argc, char **argv)
g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_term", g_pid);
g_term_event = g_create_wait_obj(text);
- g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_sync", g_pid);
- g_sync_event = g_create_wait_obj(text);
sesman_main_loop();
@@ -399,7 +386,6 @@ main(int argc, char **argv)
}
g_delete_wait_obj(g_term_event);
- g_delete_wait_obj(g_sync_event);
if (!daemon)
{
diff --git a/sesman/sesman.h b/sesman/sesman.h
index e80f85d1..09b781bc 100644
--- a/sesman/sesman.h
+++ b/sesman/sesman.h
@@ -42,9 +42,6 @@
#include "session.h"
#include "access.h"
#include "scp.h"
-#include "thread.h"
-#include "lock.h"
-#include "thread_calls.h"
#include "libscp.h"
diff --git a/sesman/session.c b/sesman/session.c
index 643e3521..8c3ccc17 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
- * Copyright (C) Jay Sorg 2004-2013
+ * Copyright (C) Jay Sorg 2004-2015
*
* BSD process grouping by:
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland.
@@ -32,33 +32,13 @@
#include "sesman.h"
#include "libscp_types.h"
-#include <errno.h>
-//#include <time.h>
-
-extern tbus g_sync_event;
extern unsigned char g_fixedkey[8];
extern struct config_sesman *g_cfg; /* in sesman.c */
extern int g_sck; /* in sesman.c */
-extern int g_thread_sck; /* in thread.c */
struct session_chain *g_sessions;
int g_session_count;
extern tbus g_term_event; /* in sesman.c */
-extern tbus g_sync_event; /* in sesman.c */
-
-static int g_sync_width;
-static int g_sync_height;
-static int g_sync_bpp;
-static char *g_sync_username;
-static char *g_sync_password;
-static char *g_sync_domain;
-static char *g_sync_program;
-static char *g_sync_directory;
-static char *g_sync_client_ip;
-static tbus g_sync_data;
-static tui8 g_sync_type;
-static int g_sync_result;
-static int g_sync_cmd;
/**
* Creates a string consisting of all parameters that is hosted in the param list
@@ -71,7 +51,6 @@ char *APP_CC
dumpItemsToString(struct list *self, char *outstr, int len)
{
int index;
- tbus item;
int totalLen = 0;
g_memset(outstr, 0, len);
@@ -103,9 +82,6 @@ session_get_bydata(char *name, int width, int height, int bpp, int type, char *c
struct session_chain *tmp;
enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
/* convert from SCP_SESSION_TYPE namespace to SESMAN_SESSION_TYPE namespace */
@@ -122,7 +98,6 @@ session_get_bydata(char *name, int width, int height, int bpp, int type, char *c
type = SESMAN_SESSION_TYPE_XORG;
break;
default:
- lock_chain_release();
return 0;
}
@@ -154,16 +129,12 @@ session_get_bydata(char *name, int width, int height, int bpp, int type, char *c
tmp->item->bpp == bpp &&
tmp->item->type == type)
{
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return tmp->item;
}
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return 0;
}
@@ -267,7 +238,6 @@ x_server_running(int display)
{
char text[256];
int x_running;
- int sck;
g_sprintf(text, "/tmp/.X11-unix/X%d", display);
x_running = g_file_exist(text);
@@ -309,9 +279,9 @@ session_start_sessvc(int xpid, int wmpid, long data, char *username, int display
/* building parameters */
g_snprintf(exe_path, 261, "%s/xrdp-sessvc", XRDP_SBIN_PATH);
- list_add_item(sessvc_params, (long)g_strdup(exe_path));
- list_add_item(sessvc_params, (long)g_strdup(xpid_str));
- list_add_item(sessvc_params, (long)g_strdup(wmpid_str));
+ list_add_item(sessvc_params, (tintptr)g_strdup(exe_path));
+ list_add_item(sessvc_params, (tintptr)g_strdup(xpid_str));
+ list_add_item(sessvc_params, (tintptr)g_strdup(wmpid_str));
list_add_item(sessvc_params, 0); /* mandatory */
env_set_user(username, 0, display,
@@ -329,7 +299,7 @@ session_start_sessvc(int xpid, int wmpid, long data, char *username, int display
/* no problem calling strerror for thread safety: other threads
are blocked */
log_message(LOG_LEVEL_DEBUG, "errno: %d, description: %s",
- errno, g_get_strerror());
+ g_get_errno(), g_get_strerror());
log_message(LOG_LEVEL_DEBUG, "execve parameter list:");
for (i = 0; i < (sessvc_params->count); i++)
@@ -383,7 +353,6 @@ session_get_aval_display_from_chain(void)
int display;
display = g_cfg->sess.x11_display_offset;
- lock_chain_acquire();
while ((display - g_cfg->sess.x11_display_offset) <= g_cfg->sess.max_sessions)
{
@@ -391,7 +360,6 @@ session_get_aval_display_from_chain(void)
{
if (!x_server_running_check_ports(display))
{
- lock_chain_release();
return display;
}
}
@@ -399,7 +367,6 @@ session_get_aval_display_from_chain(void)
display++;
}
- lock_chain_release();
log_message(LOG_LEVEL_ERROR, "X server -- no display in range is available");
return 0;
}
@@ -503,17 +470,16 @@ session_start_fork(int width, int height, int bpp, char *username,
return 0;
}
- pid = g_fork();
+ pid = g_fork(); /* parent is fork from tcp accpet,
+ child forks X and wm, then becomes scp */
if (pid == -1)
{
}
- else if (pid == 0) /* child sesman */
+ else if (pid == 0)
{
g_tcp_close(g_term_event);
- g_tcp_close(g_sync_event);
g_tcp_close(g_sck);
- g_tcp_close(g_thread_sck);
g_sprintf(geometry, "%dx%d", width, height);
g_sprintf(depth, "%d", bpp);
g_sprintf(screen, ":%d", display);
@@ -553,19 +519,21 @@ session_start_fork(int width, int height, int bpp, char *username,
g_waitpid(bsdsespid);
#endif
- wmpid = g_fork();
+ wmpid = g_fork(); /* parent becomes X,
+ child forks wm, and waits, todo */
if (wmpid == -1)
{
}
- else if (wmpid == 0) /* child (child sesman) xserver */
+ else if (wmpid == 0)
{
wait_for_xserver(display);
auth_start_session(data, display);
- pampid = g_fork();
+ pampid = g_fork(); /* parent waits, todo
+ child becomes wm */
if (pampid == -1)
{
}
- else if (pampid == 0) /* child: X11/client */
+ else if (pampid == 0)
{
env_set_user(username, 0, display,
g_cfg->session_variables1,
@@ -601,7 +569,7 @@ session_start_fork(int width, int height, int bpp, char *username,
"wm for user %s - pid %d", username, g_getpid());
/* logging parameters */
log_message(LOG_LEVEL_DEBUG, "errno: %d, "
- "description: %s", errno, g_get_strerror());
+ "description: %s", g_get_errno(), g_get_strerror());
log_message(LOG_LEVEL_DEBUG, "execlp3 parameter "
"list:");
log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
@@ -619,7 +587,7 @@ session_start_fork(int width, int height, int bpp, char *username,
"wm for user %s - pid %d", username, g_getpid());
/* logging parameters */
log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
- "%s", errno, g_get_strerror());
+ "%s", g_get_errno(), g_get_strerror());
log_message(LOG_LEVEL_DEBUG, "execlp3 parameter list:");
log_message(LOG_LEVEL_DEBUG, " argv[0] = %s",
text);
@@ -634,7 +602,7 @@ session_start_fork(int width, int height, int bpp, char *username,
"for user %s - pid %d", username, g_getpid());
/* logging parameters */
log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
- "%s", errno, g_get_strerror());
+ "%s", g_get_errno(), g_get_strerror());
}
else
{
@@ -653,10 +621,10 @@ session_start_fork(int width, int height, int bpp, char *username,
g_exit(0);
}
}
- else /* parent (child sesman) */
+ else
{
- xpid = g_fork();
-
+ xpid = g_fork(); /* parent becomes scp,
+ child becomes X */
if (xpid == -1)
{
}
@@ -684,8 +652,8 @@ session_start_fork(int width, int height, int bpp, char *username,
xserver_params->auto_free = 1;
/* these are the must have parameters */
- list_add_item(xserver_params, (long) g_strdup("Xorg"));
- list_add_item(xserver_params, (long) g_strdup(screen));
+ list_add_item(xserver_params, (tintptr) g_strdup("Xorg"));
+ list_add_item(xserver_params, (tintptr) g_strdup(screen));
/* additional parameters from sesman.ini file */
list_append_list_strdup(g_cfg->xorg_params, xserver_params, 0);
@@ -714,14 +682,14 @@ session_start_fork(int width, int height, int bpp, char *username,
xserver_params->auto_free = 1;
/* these are the must have parameters */
- list_add_item(xserver_params, (long)g_strdup("Xvnc"));
- list_add_item(xserver_params, (long)g_strdup(screen));
- list_add_item(xserver_params, (long)g_strdup("-geometry"));
- list_add_item(xserver_params, (long)g_strdup(geometry));
- list_add_item(xserver_params, (long)g_strdup("-depth"));
- list_add_item(xserver_params, (long)g_strdup(depth));
- list_add_item(xserver_params, (long)g_strdup("-rfbauth"));
- list_add_item(xserver_params, (long)g_strdup(passwd_file));
+ list_add_item(xserver_params, (tintptr)g_strdup("Xvnc"));
+ list_add_item(xserver_params, (tintptr)g_strdup(screen));
+ list_add_item(xserver_params, (tintptr)g_strdup("-geometry"));
+ list_add_item(xserver_params, (tintptr)g_strdup(geometry));
+ list_add_item(xserver_params, (tintptr)g_strdup("-depth"));
+ list_add_item(xserver_params, (tintptr)g_strdup(depth));
+ list_add_item(xserver_params, (tintptr)g_strdup("-rfbauth"));
+ list_add_item(xserver_params, (tintptr)g_strdup(passwd_file));
/* additional parameters from sesman.ini file */
//config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC,
@@ -740,12 +708,12 @@ session_start_fork(int width, int height, int bpp, char *username,
xserver_params->auto_free = 1;
/* these are the must have parameters */
- list_add_item(xserver_params, (long)g_strdup("X11rdp"));
- list_add_item(xserver_params, (long)g_strdup(screen));
- list_add_item(xserver_params, (long)g_strdup("-geometry"));
- list_add_item(xserver_params, (long)g_strdup(geometry));
- list_add_item(xserver_params, (long)g_strdup("-depth"));
- list_add_item(xserver_params, (long)g_strdup(depth));
+ list_add_item(xserver_params, (tintptr)g_strdup("X11rdp"));
+ list_add_item(xserver_params, (tintptr)g_strdup(screen));
+ list_add_item(xserver_params, (tintptr)g_strdup("-geometry"));
+ list_add_item(xserver_params, (tintptr)g_strdup(geometry));
+ list_add_item(xserver_params, (tintptr)g_strdup("-depth"));
+ list_add_item(xserver_params, (tintptr)g_strdup(depth));
/* additional parameters from sesman.ini file */
//config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP,
@@ -771,7 +739,7 @@ session_start_fork(int width, int height, int bpp, char *username,
/* logging parameters */
log_message(LOG_LEVEL_DEBUG, "errno: %d, description: "
- "%s", errno, g_get_strerror());
+ "%s", g_get_errno(), g_get_strerror());
log_message(LOG_LEVEL_DEBUG, "execve parameter list size: "
"%d", (xserver_params)->count);
@@ -784,7 +752,7 @@ session_start_fork(int width, int height, int bpp, char *username,
list_delete(xserver_params);
g_exit(1);
}
- else /* parent (child sesman)*/
+ else
{
wait_for_xserver(display);
g_snprintf(text, 255, "%d", display);
@@ -796,7 +764,7 @@ session_start_fork(int width, int height, int bpp, char *username,
}
}
}
- else /* parent sesman process */
+ else
{
temp->item->pid = pid;
temp->item->display = display;
@@ -820,16 +788,10 @@ session_start_fork(int width, int height, int bpp, char *username,
temp->item->type = type;
temp->item->status = SESMAN_SESSION_STATUS_ACTIVE;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
temp->next = g_sessions;
g_sessions = temp;
g_session_count++;
- /*THREAD-FIX release chain lock */
- lock_chain_release();
-
return display;
}
@@ -876,32 +838,9 @@ session_start(int width, int height, int bpp, char *username, char *password,
long data, tui8 type, char *domain, char *program,
char *directory, char *client_ip)
{
- int display;
-
- /* lock mutex */
- lock_sync_acquire();
- /* set shared vars */
- g_sync_cmd = 0;
- g_sync_width = width;
- g_sync_height = height;
- g_sync_bpp = bpp;
- g_sync_username = username;
- g_sync_password = password;
- g_sync_domain = domain;
- g_sync_program = program;
- g_sync_directory = directory;
- g_sync_client_ip = client_ip;
- g_sync_data = data;
- g_sync_type = type;
- /* set event for main thread to see */
- g_set_wait_obj(g_sync_event);
- /* wait for main thread to get done */
- lock_sync_sem_acquire();
- /* read result(display) from shared var */
- display = g_sync_result;
- /* unlock mutex */
- lock_sync_release();
- return display;
+ return session_start_fork(width, height, bpp, username,
+ password, data, type, domain,
+ program, directory, client_ip);
}
/******************************************************************************/
@@ -910,42 +849,7 @@ session_start(int width, int height, int bpp, char *username, char *password,
int DEFAULT_CC
session_reconnect(int display, char *username)
{
- /* lock mutex */
- lock_sync_acquire();
- /* set shared vars */
- g_sync_cmd = 1;
- g_sync_width = display;
- g_sync_username = username;
- /* set event for main thread to see */
- g_set_wait_obj(g_sync_event);
- /* wait for main thread to get done */
- lock_sync_sem_acquire();
- /* unlock mutex */
- lock_sync_release();
- return 0;
-}
-
-/******************************************************************************/
-/* called with the main thread */
-int APP_CC
-session_sync_start(void)
-{
- if (g_sync_cmd == 0)
- {
- g_sync_result = session_start_fork(g_sync_width, g_sync_height, g_sync_bpp,
- g_sync_username, g_sync_password,
- g_sync_data, g_sync_type, g_sync_domain,
- g_sync_program, g_sync_directory,
- g_sync_client_ip);
- }
- else
- {
- /* g_sync_width is really display */
- g_sync_result = session_reconnect_fork(g_sync_width, g_sync_username);
- }
-
- lock_sync_sem_release();
- return 0;
+ return session_reconnect_fork(display, username);
}
/******************************************************************************/
@@ -955,9 +859,6 @@ session_kill(int pid)
struct session_chain *tmp;
struct session_chain *prev;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
prev = 0;
@@ -979,8 +880,6 @@ session_kill(int pid)
prev->next = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return SESMAN_SESSION_KILL_NULLITEM;
}
@@ -1003,8 +902,6 @@ session_kill(int pid)
g_free(tmp);
g_session_count--;
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return SESMAN_SESSION_KILL_OK;
}
@@ -1013,8 +910,6 @@ session_kill(int pid)
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return SESMAN_SESSION_KILL_NOTFOUND;
}
@@ -1024,9 +919,6 @@ session_sigkill_all()
{
struct session_chain *tmp;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
while (tmp != 0)
@@ -1044,9 +936,6 @@ session_sigkill_all()
/* go on */
tmp = tmp->next;
}
-
- /*THREAD-FIX release chain lock */
- lock_chain_release();
}
/******************************************************************************/
@@ -1064,9 +953,6 @@ session_get_bypid(int pid)
return 0;
}
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
while (tmp != 0)
@@ -1075,18 +961,13 @@ session_get_bypid(int pid)
{
log_message(LOG_LEVEL_ERROR, "session descriptor for "
"pid %d is null!", pid);
- /*THREAD-FIX release chain lock */
- lock_chain_release();
g_free(dummy);
return 0;
}
if (tmp->item->pid == pid)
{
- /*THREAD-FIX release chain lock */
g_memcpy(dummy, tmp->item, sizeof(struct session_item));
- lock_chain_release();
- /*return tmp->item;*/
return dummy;
}
@@ -1094,8 +975,6 @@ session_get_bypid(int pid)
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
g_free(dummy);
return 0;
}
@@ -1111,9 +990,6 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
count = 0;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
while (tmp != 0)
@@ -1139,8 +1015,6 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
if (count == 0)
{
(*cnt) = 0;
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return 0;
}
@@ -1150,8 +1024,6 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
if (sess == 0)
{
(*cnt) = 0;
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return 0;
}
@@ -1160,7 +1032,7 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
while (tmp != 0)
{
-#warning FIXME: we should get only disconnected sessions!
+/* #warning FIXME: we should get only disconnected sessions! */
if ((NULL == user) || (!g_strncasecmp(user, tmp->item->name, 256)))
{
if ((tmp->item->status) & flags)
@@ -1170,7 +1042,7 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
(sess[index]).height = tmp->item->height;
(sess[index]).width = tmp->item->width;
(sess[index]).bpp = tmp->item->bpp;
-#warning FIXME: setting idle times and such
+/* #warning FIXME: setting idle times and such */
/*(sess[index]).connect_time.year = tmp->item->connect_time.year;
(sess[index]).connect_time.month = tmp->item->connect_time.month;
(sess[index]).connect_time.day = tmp->item->connect_time.day;
@@ -1203,8 +1075,6 @@ session_get_byuser(char *user, int *cnt, unsigned char flags)
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
(*cnt) = count;
return sess;
}
diff --git a/sesman/session.h b/sesman/session.h
index 05e3b3a9..7bd8c8f8 100644
--- a/sesman/session.h
+++ b/sesman/session.h
@@ -112,15 +112,6 @@ session_reconnect(int display, char* username);
/**
*
- * @brief starts a session
- * @return error
- *
- */
-int APP_CC
-session_sync_start(void);
-
-/**
- *
* @brief kills a session
* @param pid the pid of the session to be killed
* @return
diff --git a/sesman/thread.c b/sesman/thread.c
deleted file mode 100644
index 0ed1182a..00000000
--- a/sesman/thread.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2013
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- *
- * @file thread.c
- * @brief thread stuff...
- * @author Simone Fedele
- *
- */
-
-#include "sesman.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <pthread.h>
-
-extern struct config_sesman *g_cfg; /* in sesman.c */
-
-static pthread_t g_thread_sighandler;
-//static pthread_t g_thread_updater;
-
-/* a variable to pass the socket of s connection to a thread */
-int g_thread_sck;
-
-/******************************************************************************/
-int DEFAULT_CC
-thread_sighandler_start(void)
-{
- int ret;
- sigset_t sigmask;
- sigset_t oldmask;
- sigset_t waitmask;
-
- /* mask signals to be able to wait for them... */
- sigfillset(&sigmask);
- pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
-
- /* unblock some signals... */
- sigemptyset(&waitmask);
-
- /* it is a good idea not to block SIGILL SIGSEGV */
- /* SIGFPE -- see sigaction(2) NOTES */
- sigaddset(&waitmask, SIGILL);
- sigaddset(&waitmask, SIGSEGV);
- sigaddset(&waitmask, SIGFPE);
- pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL);
-
- log_message(LOG_LEVEL_INFO, "starting signal handling thread...");
-
- ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, "");
- pthread_detach(g_thread_sighandler);
-
- if (ret == 0)
- {
- log_message(LOG_LEVEL_INFO, "signal handler thread started successfully");
- return 0;
- }
-
- /* if something happened while starting a new thread... */
- switch (ret)
- {
- case EINVAL:
- log_message(LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)");
- break;
- case EAGAIN:
- log_message(LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)");
- break;
- case EPERM:
- log_message(LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)");
- break;
- default:
- log_message(LOG_LEVEL_ERROR, "unknown error starting signal handling thread");
- }
-
- return 1;
-}
-
-#ifdef JUST_TO_AVOID_COMPILER_ERRORS
-/******************************************************************************/
-int DEFAULT_CC
-thread_session_update_start(void)
-{
- int ret;
- //starts the session update thread
- //that checks for idle time, destroys sessions, ecc...
-
-#warning this thread should always request lock_fork before read or write
-#warning (so we can Fork() In Peace)
- ret = pthread_create(&g_thread_updater, NULL, , "");
- pthread_detach(g_thread_updater);
-
- if (ret == 0)
- {
- log_message(&(g_cfg->log), LOG_LEVEL_INFO, "session update thread started successfully");
- return 0;
- }
-
- /* if something happened while starting a new thread... */
- switch (ret)
- {
- case EINVAL:
- log_message(LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)");
- break;
- case EAGAIN:
- log_message(LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)");
- break;
- case EPERM:
- log_message(LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)");
- break;
- default:
- log_message(LOG_LEVEL_ERROR, "unknown error starting session update thread");
- }
-
- return 1;
-}
-#endif
-
-/******************************************************************************/
-int DEFAULT_CC
-thread_scp_start(int skt)
-{
- int ret;
- pthread_t th;
-
- /* blocking the use of thread_skt */
- lock_socket_acquire();
- g_thread_sck = skt;
-
- /* start a thread that processes a connection */
- ret = pthread_create(&th, NULL, scp_process_start, "");
- //ret = pthread_create(&th, NULL, scp_process_start, (void*) (&g_thread_sck));
- pthread_detach(th);
-
- if (ret == 0)
- {
- log_message(LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt);
- return 0;
- }
-
- /* if something happened while starting a new thread... */
- switch (ret)
- {
- case EINVAL:
- log_message(LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt);
- break;
- case EAGAIN:
- log_message(LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt);
- break;
- case EPERM:
- log_message(LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt);
- break;
- default:
- log_message(LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d");
- }
-
- return 1;
-}
diff --git a/sesman/thread.h b/sesman/thread.h
deleted file mode 100644
index 83a4b63d..00000000
--- a/sesman/thread.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * xrdp: A Remote Desktop Protocol server.
- *
- * Copyright (C) Jay Sorg 2004-2013
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- *
- * @file thread.h
- * @brief thread stuff...
- * @author Simone Fedele
- *
- */
-
-#ifndef THREAD_H
-#define THREAD_H
-
-/**
- *
- * @brief Starts the signal handling thread
- * @retval 0 on success
- * @retval 1 on error
- *
- */
-int DEFAULT_CC
-thread_sighandler_start(void);
-
-/**
- *
- * @brief Starts the session update thread
- *
- */
-int DEFAULT_CC
-thread_session_update_start(void);
-
-/**
- *
- * @brief Starts a thread to handle an incoming connection
- *
- */
-int DEFAULT_CC
-thread_scp_start(int skt);
-
-#endif