summaryrefslogtreecommitdiffstats
path: root/sesman
diff options
context:
space:
mode:
Diffstat (limited to 'sesman')
-rw-r--r--sesman/Makefile.am12
-rw-r--r--sesman/access.c2
-rw-r--r--sesman/chansrv/Makefile.am12
-rw-r--r--sesman/chansrv/chansrv_fuse.c19
-rw-r--r--sesman/chansrv/clipboard.c8
-rw-r--r--sesman/chansrv/clipboard_file.c3
-rw-r--r--sesman/chansrv/pulse/module-xrdp-sink.c2
-rw-r--r--sesman/chansrv/pulse/module-xrdp-source.c2
-rw-r--r--sesman/chansrv/rail.c2
-rw-r--r--sesman/env.c30
-rw-r--r--sesman/libscp/Makefile.am6
-rw-r--r--sesman/libscp/libscp_lock.c2
-rw-r--r--sesman/libscp/libscp_lock.h4
-rw-r--r--sesman/libscp/libscp_v1s.c7
-rw-r--r--sesman/lock.c121
-rw-r--r--sesman/lock.h104
-rw-r--r--sesman/scp.c10
-rw-r--r--sesman/scp_v0.c14
-rw-r--r--sesman/scp_v1.c2
-rw-r--r--sesman/sesman.c32
-rw-r--r--sesman/sesman.h3
-rw-r--r--sesman/session.c241
-rw-r--r--sesman/session.h9
-rw-r--r--sesman/sessvc/Makefile.am6
-rw-r--r--sesman/sessvc/sessvc.c2
-rw-r--r--sesman/thread.c173
-rw-r--r--sesman/thread.h56
-rw-r--r--sesman/tools/Makefile.am14
-rw-r--r--sesman/tools/config.c1
-rw-r--r--sesman/tools/sesadmin.c13
-rw-r--r--sesman/tools/sestest.c13
-rw-r--r--sesman/tools/xcon.c1
32 files changed, 175 insertions, 751 deletions
diff --git a/sesman/Makefile.am b/sesman/Makefile.am
index 516639f4..979f72d9 100644
--- a/sesman/Makefile.am
+++ b/sesman/Makefile.am
@@ -1,12 +1,12 @@
-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
-AM_CFLAGS = \
+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_CPPFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
-
-INCLUDES = \
+ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common \
-I$(top_srcdir)/sesman/libscp
@@ -44,8 +44,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/chansrv/Makefile.am b/sesman/chansrv/Makefile.am
index 755de786..45397b73 100644
--- a/sesman/chansrv/Makefile.am
+++ b/sesman/chansrv/Makefile.am
@@ -31,17 +31,17 @@ EXTRA_DEFINES += -DXRDP_OPUS
EXTRA_LIBS += -lopus
endif
-AM_CFLAGS = \
+AM_CPPFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
- $(EXTRA_DEFINES)
-
-INCLUDES = \
+ $(EXTRA_DEFINES) \
-I$(top_srcdir)/common \
$(EXTRA_INCLUDES)
+AM_CFLAGS = $(X_CFLAGS)
+
sbin_PROGRAMS = \
xrdp-chansrv
@@ -62,10 +62,10 @@ xrdp_chansrv_SOURCES = \
chansrv_common.c
xrdp_chansrv_LDFLAGS = \
+ $(X_LIBS) \
$(EXTRA_FLAGS)
xrdp_chansrv_LDADD = \
- -L/usr/X11R6/lib \
$(top_builddir)/common/libcommon.la \
- -lX11 -lXfixes -lXrandr \
+ $(X_PRE_LIBS) -lXfixes -lXrandr -lX11 $(X_EXTRA_LIBS) \
$(EXTRA_LIBS)
diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c
index b3499ad6..ed180454 100644
--- a/sesman/chansrv/chansrv_fuse.c
+++ b/sesman/chansrv/chansrv_fuse.c
@@ -62,8 +62,8 @@ char g_fuse_clipboard_path[256] = ""; /* for clipboard use */
#include "chansrv_fuse.h"
/* dummy calls when XRDP_FUSE is not defined */
-int xfuse_init() { return 0; }
-int xfuse_deinit() { return 0; }
+int xfuse_init(void) { return 0; }
+int xfuse_deinit(void) { return 0; }
int xfuse_check_wait_objs(void) { return 0; }
int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout) { return 0; }
int xfuse_clear_clip_dir(void) { return 0; }
@@ -74,7 +74,7 @@ int xfuse_create_share(tui32 device_id, char *dirname) { r
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {}
void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {}
void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {}
-int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {}
+int xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) { return 0; }
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) {}
void xfuse_devredir_cb_rmdir_or_file(void *vp, tui32 IoStatus) {}
void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus) {}
@@ -253,8 +253,8 @@ static int g_fd = 0;
static tintptr g_bufsize = 0;
/* forward declarations for internal access */
-static int xfuse_init_xrdp_fs();
-static int xfuse_deinit_xrdp_fs();
+static int xfuse_init_xrdp_fs(void);
+static int xfuse_deinit_xrdp_fs(void);
static int xfuse_init_lib(struct fuse_args *args);
static int xfuse_is_inode_valid(int ino);
@@ -264,7 +264,7 @@ static void xfuse_create_file(fuse_req_t req, fuse_ino_t parent,
const char *name, mode_t mode, int type);
#endif
-static void xfuse_dump_fs();
+static void xfuse_dump_fs(void);
static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino);
static tui32 xfuse_get_device_id_for_inode(tui32 ino, char *full_path);
static void fuse_reverse_pathname(char *full_path, char *reverse_path);
@@ -281,7 +281,7 @@ static int xfuse_delete_file(int parent, char *name);
static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode);
static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode);
static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode);
-static void xfuse_update_xrdpfs_size();
+static void xfuse_update_xrdpfs_size(void);
static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
off_t off, struct fuse_file_info *fi);
@@ -693,6 +693,11 @@ int xfuse_clear_clip_dir(void)
log_debug("entered");
+ if (g_xrdp_fs.inode_table == NULL)
+ {
+ return 0;
+ }
+
/* xinode for .clipboard */
xip = g_xrdp_fs.inode_table[2];
diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c
index 310e2093..11c37a16 100644
--- a/sesman/chansrv/clipboard.c
+++ b/sesman/chansrv/clipboard.c
@@ -176,6 +176,8 @@ x-special/gnome-copied-files
#define LOG_ERROR 0
#define LOG_INFO 1
#define LOG_DEBUG 2
+
+#undef LOG_LEVEL
#define LOG_LEVEL LOG_ERROR
#define log_error(_params...) \
@@ -271,7 +273,7 @@ static int g_cliprdr_flags = CB_USE_LONG_FORMAT_NAMES |
CB_FILECLIP_NO_FILE_PATHS;
/* from client to server */
-/* last recieved CLIPRDR_FORMAT_LIST(CLIPRDR_FORMAT_ANNOUNCE) */
+/* last received CLIPRDR_FORMAT_LIST(CLIPRDR_FORMAT_ANNOUNCE) */
static int g_formatIds[16];
static int g_num_formatIds = 0;
@@ -1547,7 +1549,7 @@ clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length,
{
log_error("aborting clipboard_data_in - clipboard has not "
"been initialized");
- /* we return 0 here to indicate no protocol problem occured */
+ /* we return 0 here to indicate no protocol problem occurred */
return 0;
}
@@ -1887,7 +1889,7 @@ clipboard_event_selection_notify(XEvent *xevent)
XDeleteProperty(g_display, lxevent->requestor, lxevent->property);
if (type == g_incr_atom)
{
- /* nothing more to do here, the data is comming in through
+ /* nothing more to do here, the data is coming in through
PropertyNotify */
log_debug("clipboard_event_selection_notify: type is INCR "
"data_size %d property name %s type %s", data_size,
diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c
index c1fb0909..4f3f1ade 100644
--- a/sesman/chansrv/clipboard_file.c
+++ b/sesman/chansrv/clipboard_file.c
@@ -22,6 +22,7 @@
* CLIPRDR_FILEDESCRIPTOR
* http://msdn.microsoft.com/en-us/library/ff362447%28prot.20%29.aspx */
+#include <sys/time.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xfixes.h>
@@ -553,7 +554,7 @@ clipboard_process_file_request(struct stream *s, int clip_msg_status,
}
/*****************************************************************************/
-/* server requested info about the file and this is the responce
+/* server requested info about the file and this is the response
it's either the file size or file data */
int APP_CC
clipboard_process_file_response(struct stream *s, int clip_msg_status,
diff --git a/sesman/chansrv/pulse/module-xrdp-sink.c b/sesman/chansrv/pulse/module-xrdp-sink.c
index 8606f412..5d6256d4 100644
--- a/sesman/chansrv/pulse/module-xrdp-sink.c
+++ b/sesman/chansrv/pulse/module-xrdp-sink.c
@@ -309,7 +309,7 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
s.sun_family = AF_UNIX;
bytes = sizeof(s.sun_path) - 1;
snprintf(s.sun_path, bytes, CHANSRV_PORT_STR, u->display_num);
- pa_log_debug("trying to conenct to %s", s.sun_path);
+ pa_log_debug("trying to connect to %s", s.sun_path);
if (connect(fd, (struct sockaddr *)&s,
sizeof(struct sockaddr_un)) != 0) {
u->failed_connect_time = pa_rtclock_now();
diff --git a/sesman/chansrv/pulse/module-xrdp-source.c b/sesman/chansrv/pulse/module-xrdp-source.c
index 37c0bb4e..52409606 100644
--- a/sesman/chansrv/pulse/module-xrdp-source.c
+++ b/sesman/chansrv/pulse/module-xrdp-source.c
@@ -313,7 +313,7 @@ static void thread_func(void *userdata) {
} else {
if (u->want_src_data)
{
- /* we dont want source data anymore */
+ /* we don't want source data anymore */
char buf[12];
buf[0] = 0;
diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c
index f3777970..f12d8e3f 100644
--- a/sesman/chansrv/rail.c
+++ b/sesman/chansrv/rail.c
@@ -1775,7 +1775,7 @@ rail_configure_window(XConfigureEvent *config)
/*****************************************************************************/
static int
-rail_desktop_resize(lxevent)
+rail_desktop_resize(XEvent *lxevent)
{
LOG(0, ("rail_desktop_resize:"));
return 0;
diff --git a/sesman/env.c b/sesman/env.c
index 863ada8f..b2f06160 100644
--- a/sesman/env.c
+++ b/sesman/env.c
@@ -34,25 +34,44 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
int DEFAULT_CC
-env_check_password_file(char *filename, char *password)
+env_check_password_file(char *filename, char *passwd)
{
char encryptedPasswd[16];
char key[24];
+ char passwd_hash[20];
+ char passwd_hash_text[40];
int fd;
- void* des;
+ int passwd_bytes;
+ void *des;
+ void *sha1;
+ /* create password hash from passowrd */
+ passwd_bytes = g_strlen(passwd);
+ sha1 = ssl_sha1_info_create();
+ ssl_sha1_transform(sha1, "xrdp_vnc", 8);
+ ssl_sha1_transform(sha1, passwd, passwd_bytes);
+ ssl_sha1_transform(sha1, passwd, passwd_bytes);
+ ssl_sha1_complete(sha1, passwd_hash);
+ ssl_sha1_info_delete(sha1);
+ g_snprintf(passwd_hash_text, 39, "%2.2x%2.2x%2.2x%2.2x",
+ (tui8)passwd_hash[0], (tui8)passwd_hash[1],
+ (tui8)passwd_hash[2], (tui8)passwd_hash[3]);
+ passwd_hash_text[39] = 0;
+ passwd = passwd_hash_text;
+
+ /* create file from password */
g_memset(encryptedPasswd, 0, sizeof(encryptedPasswd));
- g_strncpy(encryptedPasswd, password, 8);
+ g_strncpy(encryptedPasswd, passwd, 8);
g_memset(key, 0, sizeof(key));
g_mirror_memcpy(key, g_fixedkey, 8);
des = ssl_des3_encrypt_info_create(key, 0);
ssl_des3_encrypt(des, 8, encryptedPasswd, encryptedPasswd);
ssl_des3_info_delete(des);
- fd = g_file_open(filename);
+ fd = g_file_open_ex(filename, 0, 1, 1, 1);
if (fd == -1)
{
log_message(LOG_LEVEL_WARNING,
- "can't read vnc password file - %s",
+ "can't write vnc password hash file - %s",
filename);
return 1;
}
@@ -111,7 +130,6 @@ env_set_user(char *username, char *passwd_file, int display,
g_set_current_dir(pw_dir);
g_sprintf(text, ":%d.0", display);
g_setenv("DISPLAY", text, 1);
- g_setenv("LANG", "en_US.UTF-8", 1);
g_setenv("XRDP_SESSION", "1", 1);
if ((env_names != 0) && (env_values != 0) &&
(env_names->count == env_values->count))
diff --git a/sesman/libscp/Makefile.am b/sesman/libscp/Makefile.am
index eaf518a8..3172f2cb 100644
--- a/sesman/libscp/Makefile.am
+++ b/sesman/libscp/Makefile.am
@@ -1,13 +1,11 @@
EXTRA_DIST = libscp_connection.h libscp_commands.h libscp.h libscp_session.h libscp_types_mng.h libscp_v1c_mng.h libscp_vX.h libscp_commands_mng.h libscp_init.h libscp_tcp.h libscp_v0.h libscp_v1s.h libscp_lock.h \
libscp_types.h libscp_v1c.h libscp_v1s_mng.h
-AM_CFLAGS = \
+AM_CPPFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
-
-INCLUDES = \
+ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
lib_LTLIBRARIES = \
diff --git a/sesman/libscp/libscp_lock.c b/sesman/libscp/libscp_lock.c
index 4db05422..d35e3c9c 100644
--- a/sesman/libscp/libscp_lock.c
+++ b/sesman/libscp/libscp_lock.c
@@ -57,7 +57,7 @@ scp_lock_fork_request(void)
if (lock_fork_blockers_count == 0)
{
- /* if noone is blocking fork(), then we're allowed to fork */
+ /* if no one is blocking fork(), then we're allowed to fork */
sem_post(&lock_fork_req);
}
diff --git a/sesman/libscp/libscp_lock.h b/sesman/libscp/libscp_lock.h
index b4e93c52..ae2c361b 100644
--- a/sesman/libscp/libscp_lock.h
+++ b/sesman/libscp/libscp_lock.h
@@ -52,8 +52,8 @@ scp_lock_fork_release(void);
*
* @brief starts a section that is critical for forking
*
- * starts a section that is critical for forking, that is noone can fork()
- * while i'm in a critical section. But if someone wanted to fork we have
+ * starts a section that is critical for forking, that is no one can fork()
+ * while I'm in a critical section. But if someone wanted to fork we have
* to wait until he finishes with lock_fork_release()
*
* @return
diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c
index 69997ab2..fb137433 100644
--- a/sesman/libscp/libscp_v1s.c
+++ b/sesman/libscp/libscp_v1s.c
@@ -435,8 +435,11 @@ scp_v1s_list_sessions(struct SCP_CONNECTION *c, int sescnt, struct SCP_DISCONNEC
}
/* then we wait for client ack */
-#warning maybe this message could say if the session should be resized on
-#warning server side or client side
+
+ /*
+ * Maybe this message could say if the session should be resized on
+ * server side or client side.
+ */
init_stream(c->in_s, c->in_s->size);
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
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 ce528d46..efa9080c 100644
--- a/sesman/scp_v0.c
+++ b/sesman/scp_v0.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.
@@ -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)
{
@@ -55,7 +55,7 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
}
else
{
- scp_v0s_replyauthentication(c, 32+3); /* all first 32 are reserved for PAM errors */
+ scp_v0s_replyauthentication(c, 32 + 3); /* all first 32 are reserved for PAM errors */
log_message(LOG_LEVEL_INFO, "Username okey but group problem for "
"user: %s", s->username);
/* g_writeln("user password ok, but group problem"); */
@@ -128,11 +128,11 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XRDP,
s->domain, s->program, s->directory,
- s->client_ip);
- }
+ s->client_ip);
+ }
else if (SCP_SESSION_TYPE_XORG == s->type)
{
- /* type is SCP_SESSION_TYPE_XORG */
+ /* type is SCP_SESSION_TYPE_XORG */
log_message(LOG_LEVEL_INFO, "starting Xorg session...");
display = session_start(s->width, s->height, s->bpp, s->username,
s->password, data, SESMAN_SESSION_TYPE_XORG,
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 5185d738..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,30 +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;
-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;
+extern tbus g_term_event; /* in sesman.c */
/**
* Creates a string consisting of all parameters that is hosted in the param list
@@ -68,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);
@@ -100,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 */
@@ -119,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;
}
@@ -141,27 +119,9 @@ session_get_bydata(char *name, int width, int height, int bpp, int type, char *c
tmp->item->client_ip);
#endif
- if (type == SESMAN_SESSION_TYPE_XRDP)
- {
- /* only name and bpp need to match for X11rdp, it can resize */
- if (g_strncmp(name, tmp->item->name, 255) == 0 &&
- (!(policy & SESMAN_CFG_SESS_POLICY_D) ||
- (tmp->item->width == width && tmp->item->height == height)) &&
- (!(policy & SESMAN_CFG_SESS_POLICY_I) ||
- (g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
- (!(policy & SESMAN_CFG_SESS_POLICY_C) ||
- (g_strncmp(client_ip, tmp->item->client_ip, 255) == 0)) &&
- tmp->item->bpp == bpp &&
- tmp->item->type == type)
- {
- /*THREAD-FIX release chain lock */
- lock_chain_release();
- return tmp->item;
- }
- }
-
if (g_strncmp(name, tmp->item->name, 255) == 0 &&
- (tmp->item->width == width && tmp->item->height == height) &&
+ (!(policy & SESMAN_CFG_SESS_POLICY_D) ||
+ (tmp->item->width == width && tmp->item->height == height)) &&
(!(policy & SESMAN_CFG_SESS_POLICY_I) ||
(g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
(!(policy & SESMAN_CFG_SESS_POLICY_C) ||
@@ -169,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;
}
@@ -282,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);
@@ -324,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,
@@ -344,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++)
@@ -398,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)
{
@@ -406,7 +360,6 @@ session_get_aval_display_from_chain(void)
{
if (!x_server_running_check_ports(display))
{
- lock_chain_release();
return display;
}
}
@@ -414,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;
}
@@ -518,15 +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_sck);
- g_tcp_close(g_thread_sck);
g_sprintf(geometry, "%dx%d", width, height);
g_sprintf(depth, "%d", bpp);
g_sprintf(screen, ":%d", display);
@@ -566,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,
@@ -614,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",
@@ -632,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);
@@ -647,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
{
@@ -666,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)
{
}
@@ -697,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);
@@ -727,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,
@@ -753,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,
@@ -784,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);
@@ -797,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);
@@ -809,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;
@@ -833,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;
}
@@ -889,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);
}
/******************************************************************************/
@@ -923,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);
}
/******************************************************************************/
@@ -968,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;
@@ -992,8 +880,6 @@ session_kill(int pid)
prev->next = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return SESMAN_SESSION_KILL_NULLITEM;
}
@@ -1016,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;
}
@@ -1026,8 +910,6 @@ session_kill(int pid)
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
return SESMAN_SESSION_KILL_NOTFOUND;
}
@@ -1037,9 +919,6 @@ session_sigkill_all()
{
struct session_chain *tmp;
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
while (tmp != 0)
@@ -1057,9 +936,6 @@ session_sigkill_all()
/* go on */
tmp = tmp->next;
}
-
- /*THREAD-FIX release chain lock */
- lock_chain_release();
}
/******************************************************************************/
@@ -1077,9 +953,6 @@ session_get_bypid(int pid)
return 0;
}
- /*THREAD-FIX require chain lock */
- lock_chain_acquire();
-
tmp = g_sessions;
while (tmp != 0)
@@ -1088,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;
}
@@ -1107,8 +975,6 @@ session_get_bypid(int pid)
tmp = tmp->next;
}
- /*THREAD-FIX release chain lock */
- lock_chain_release();
g_free(dummy);
return 0;
}
@@ -1124,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)
@@ -1152,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;
}
@@ -1163,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;
}
@@ -1173,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)
@@ -1183,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;
@@ -1216,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/sessvc/Makefile.am b/sesman/sessvc/Makefile.am
index 8ba24abd..c2714b94 100644
--- a/sesman/sessvc/Makefile.am
+++ b/sesman/sessvc/Makefile.am
@@ -1,11 +1,9 @@
-AM_CFLAGS = \
+AM_CPPFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
-
-INCLUDES = \
+ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common
sbin_PROGRAMS = \
diff --git a/sesman/sessvc/sessvc.c b/sesman/sessvc/sessvc.c
index b3e42178..ce62cb47 100644
--- a/sesman/sessvc/sessvc.c
+++ b/sesman/sessvc/sessvc.c
@@ -101,7 +101,7 @@ main(int argc, char **argv)
wm_pid = g_atoi(argv[2]);
g_writeln("xrdp-sessvc: waiting for X (pid %d) and WM (pid %d)",
x_pid, wm_pid);
- /* run xrdp-chansrv as a seperate process */
+ /* run xrdp-chansrv as a separate process */
chansrv_pid = g_fork();
if (chansrv_pid == -1)
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
diff --git a/sesman/tools/Makefile.am b/sesman/tools/Makefile.am
index 140c6820..066039b0 100644
--- a/sesman/tools/Makefile.am
+++ b/sesman/tools/Makefile.am
@@ -1,16 +1,16 @@
EXTRA_DIST = tcp.h
-AM_CFLAGS = \
+AM_CPPFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
- -DXRDP_PID_PATH=\"${localstatedir}/run\"
-
-INCLUDES = \
+ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-I$(top_srcdir)/common \
-I$(top_srcdir)/sesman/libscp \
-I$(top_srcdir)/sesman
+AM_CFLAGS = $(X_CFLAGS)
+
bin_PROGRAMS = \
xrdp-sesrun \
xrdp-sesadmin \
@@ -48,6 +48,8 @@ xrdp_sesadmin_LDADD = \
$(top_builddir)/common/libcommon.la \
$(top_builddir)/sesman/libscp/libscp.la
+xrdp_xcon_LDFLAGS = \
+ $(X_LIBS)
+
xrdp_xcon_LDADD = \
- -L/usr/X11R6/lib \
- -lX11
+ $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
diff --git a/sesman/tools/config.c b/sesman/tools/config.c
new file mode 100644
index 00000000..0f1399cc
--- /dev/null
+++ b/sesman/tools/config.c
@@ -0,0 +1 @@
+#include "../config.c"
diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c
index 32789c6d..203bc023 100644
--- a/sesman/tools/sesadmin.c
+++ b/sesman/tools/sesadmin.c
@@ -2,6 +2,19 @@
* sesadmin.c - an sesman administration tool
* (c) 2008 Simone Fedele
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "arch.h"
diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c
index d42b31de..cf28f803 100644
--- a/sesman/tools/sestest.c
+++ b/sesman/tools/sestest.c
@@ -2,6 +2,19 @@
* sestest.c - an scp_v1 testing tool
* (c) 2008 Simone Fedele
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "arch.h"
diff --git a/sesman/tools/xcon.c b/sesman/tools/xcon.c
index 80832276..4150d6af 100644
--- a/sesman/tools/xcon.c
+++ b/sesman/tools/xcon.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include <X11/Xlib.h>
Display *g_display = 0;