summaryrefslogtreecommitdiffstats
path: root/sesman
diff options
context:
space:
mode:
Diffstat (limited to 'sesman')
-rw-r--r--sesman/chansrv/chansrv_fuse.c47
-rw-r--r--sesman/chansrv/pulse/module-xrdp-sink.c9
-rw-r--r--sesman/chansrv/pulse/module-xrdp-source.c12
-rw-r--r--sesman/config.c72
-rw-r--r--sesman/config.h51
-rw-r--r--sesman/libscp/libscp_session.c8
-rw-r--r--sesman/libscp/libscp_types.h2
-rw-r--r--sesman/libscp/libscp_v0.c18
-rw-r--r--sesman/scp_v0.c13
-rw-r--r--sesman/sesman.ini46
-rw-r--r--sesman/session.c81
-rw-r--r--sesman/session.h9
12 files changed, 339 insertions, 29 deletions
diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c
index 2eb78ea0..3ec00b6e 100644
--- a/sesman/chansrv/chansrv_fuse.c
+++ b/sesman/chansrv/chansrv_fuse.c
@@ -39,6 +39,8 @@
//#define USE_SYNC_FLAG
+static char g_fuse_mount_name[256] = "xrdp_client";
+
/* FUSE mount point */
char g_fuse_root_path[256] = "";
char g_fuse_clipboard_path[256] = ""; /* for clipboard use */
@@ -369,6 +371,37 @@ int clipboard_request_file_data(int stream_id, int lindex, int offset,
static void xfuse_mark_as_stale(int pinode);
static void xfuse_delete_stale_entries(int pinode);
+/*****************************************************************************/
+int APP_CC
+load_fuse_config(void)
+{
+ int index;
+ char cfg_file[256];
+ struct list *items;
+ struct list *values;
+ char *item;
+ char *value;
+
+ items = list_create();
+ items->auto_free = 1;
+ values = list_create();
+ values->auto_free = 1;
+ g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
+ file_by_name_read_section(cfg_file, "Chansrv", items, values);
+ for (index = 0; index < items->count; index++)
+ {
+ item = (char *)list_get_item(items, index);
+ value = (char *)list_get_item(values, index);
+ if (g_strcasecmp(item, "FuseMountName") == 0)
+ {
+ g_strncpy(g_fuse_mount_name, value, 255);
+ }
+ }
+ list_delete(items);
+ list_delete(values);
+ return 0;
+}
+
/*****************************************************************************
** **
** public functions - can be called from any code path **
@@ -381,7 +414,8 @@ static void xfuse_delete_stale_entries(int pinode);
* @return 0 on success, -1 on failure
*****************************************************************************/
-int xfuse_init()
+int APP_CC
+xfuse_init(void)
{
struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
@@ -398,8 +432,10 @@ int xfuse_init()
return -1;
}
- /* define FUSE mount point to ~/xrdp_client */
- g_snprintf(g_fuse_root_path, 255, "%s/xrdp_client", g_getenv("HOME"));
+ load_fuse_config();
+
+ /* define FUSE mount point to ~/xrdp_client, ~/thinclient_drives */
+ g_snprintf(g_fuse_root_path, 255, "%s/%s", g_getenv("HOME"), g_fuse_mount_name);
g_snprintf(g_fuse_clipboard_path, 255, "%s/.clipboard", g_fuse_root_path);
/* if FUSE mount point does not exist, create it */
@@ -460,7 +496,8 @@ int xfuse_init()
* @return 0 on success, -1 on failure
*****************************************************************************/
-int xfuse_deinit()
+int APP_CC
+xfuse_deinit(void)
{
xfuse_deinit_xrdp_fs();
fifo_deinit(&g_fifo_opendir);
@@ -1987,7 +2024,7 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
return;
}
- di = (struct dir_info *) fi->fh;
+ di = (struct dir_info *) (tintptr) (fi->fh);
if (di == NULL)
{
/* something seriously wrong somewhere! */
diff --git a/sesman/chansrv/pulse/module-xrdp-sink.c b/sesman/chansrv/pulse/module-xrdp-sink.c
index d56a4883..d072c0d4 100644
--- a/sesman/chansrv/pulse/module-xrdp-sink.c
+++ b/sesman/chansrv/pulse/module-xrdp-sink.c
@@ -58,6 +58,15 @@
#include <pulsecore/thread-mq.h>
#include <pulsecore/rtpoll.h>
+/* defined in pulse/version.h */
+#if PA_PROTOCOL_VERSION > 28
+/* these used to be defined in pulsecore/macro.h */
+typedef bool pa_bool_t;
+#define FALSE ((pa_bool_t) 0)
+#define TRUE (!FALSE)
+#else
+#endif
+
#include "module-xrdp-sink-symdef.h"
PA_MODULE_AUTHOR("Jay Sorg");
diff --git a/sesman/chansrv/pulse/module-xrdp-source.c b/sesman/chansrv/pulse/module-xrdp-source.c
index 2d7ec4fa..95465c65 100644
--- a/sesman/chansrv/pulse/module-xrdp-source.c
+++ b/sesman/chansrv/pulse/module-xrdp-source.c
@@ -45,6 +45,15 @@
#include <pulsecore/thread-mq.h>
#include <pulsecore/thread.h>
+/* defined in pulse/version.h */
+#if PA_PROTOCOL_VERSION > 28
+/* these used to be defined in pulsecore/macro.h */
+typedef bool pa_bool_t;
+#define FALSE ((pa_bool_t) 0)
+#define TRUE (!FALSE)
+#else
+#endif
+
#include "module-xrdp-source-symdef.h"
PA_MODULE_AUTHOR("Laxmikant Rashinkar");
@@ -329,8 +338,7 @@ int pa__init(pa_module *m) {
pa_source_new_data_set_name(&data, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME));
pa_source_new_data_set_sample_spec(&data, &ss);
pa_source_new_data_set_channel_map(&data, &map);
- //pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "Null Input"));
- pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "xrdp Input"));
+ pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "xrdp source"));
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "abstract");
u->source = pa_source_new(m->core, &data, PA_SOURCE_LATENCY | PA_SOURCE_DYNAMIC_LATENCY);
diff --git a/sesman/config.c b/sesman/config.c
index 877a949c..8fa6e86a 100644
--- a/sesman/config.c
+++ b/sesman/config.c
@@ -74,9 +74,10 @@ config_read(struct config_sesman *cfg)
/* read global config */
config_read_globals(fd, cfg, param_n, param_v);
- /* read Xvnc/X11rdp parameter list */
+ /* read Xvnc/X11rdp/XOrg parameter list */
config_read_vnc_params(fd, cfg, param_n, param_v);
config_read_rdp_params(fd, cfg, param_n, param_v);
+ config_read_xorg_params(fd, cfg, param_n, param_v);
/* read logging config */
// config_read_logging(fd, &(cfg->log), param_n, param_v);
@@ -336,6 +337,7 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
se->max_idle_time = 0;
se->max_disc_time = 0;
se->kill_disconnected = 0;
+ se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v);
@@ -367,15 +369,49 @@ config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
{
se->max_disc_time = g_atoi((char *)list_get_item(param_v, i));
}
+
+ if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_POLICY_S))
+ {
+ char *value = (char *)list_get_item(param_v, i);
+ if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_DFLT_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
+ }
+ else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBD_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_UBD;
+ }
+ else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBI_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_UBI;
+ }
+ else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBC_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_UBC;
+ }
+ else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBDI_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_UBDI;
+ }
+ else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBDC_S))
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_UBDC;
+ }
+ else /* silently ignore typos */
+ {
+ se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
+ }
+ }
}
- /* printing security config */
+ /* printing session config */
g_printf("session configuration:\r\n");
g_printf("\tMaxSessions: %i\r\n", se->max_sessions);
g_printf("\tX11DisplayOffset: %i\r\n", se->x11_display_offset);
g_printf("\tKillDisconnected: %i\r\n", se->kill_disconnected);
g_printf("\tIdleTimeLimit: %i\r\n", se->max_idle_time);
g_printf("\tDisconnectedTimeLimit: %i\r\n", se->max_idle_time);
+ g_printf("\tPolicy: %i\r\n", se->policy);
return 0;
}
@@ -412,6 +448,38 @@ config_read_rdp_params(int file, struct config_sesman *cs, struct list *param_n,
/******************************************************************************/
int DEFAULT_CC
+config_read_xorg_params(int file, struct config_sesman *cs,
+ struct list *param_n, struct list *param_v)
+{
+ int i;
+
+ list_clear(param_v);
+ list_clear(param_n);
+
+ cs->xorg_params = list_create();
+
+ file_read_section(file, SESMAN_CFG_XORG_PARAMS, param_n, param_v);
+
+ for (i = 0; i < param_n->count; i++)
+ {
+ list_add_item(cs->xorg_params,
+ (long) g_strdup((char *) list_get_item(param_v, i)));
+ }
+
+ /* printing security config */
+ g_printf("XOrg parameters:\r\n");
+
+ for (i = 0; i < cs->xorg_params->count; i++)
+ {
+ g_printf("\tParameter %02d %s\r\n",
+ i, (char *) list_get_item(cs->xorg_params, i));
+ }
+
+ return 0;
+}
+
+/******************************************************************************/
+int DEFAULT_CC
config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
struct list *param_v)
{
diff --git a/sesman/config.h b/sesman/config.h
index b011ca9b..31ac7256 100644
--- a/sesman/config.h
+++ b/sesman/config.h
@@ -42,6 +42,7 @@
#define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath"
#define SESMAN_CFG_RDP_PARAMS "X11rdp"
+#define SESMAN_CFG_XORG_PARAMS "Xorg"
#define SESMAN_CFG_VNC_PARAMS "Xvnc"
/*
@@ -64,6 +65,29 @@
#define SESMAN_CFG_SESS_IDLE_LIMIT "IdleTimeLimit"
#define SESMAN_CFG_SESS_DISC_LIMIT "DisconnectedTimeLimit"
+#define SESMAN_CFG_SESS_POLICY_S "Policy"
+#define SESMAN_CFG_SESS_POLICY_DFLT_S "Default"
+#define SESMAN_CFG_SESS_POLICY_UBD_S "UBD"
+#define SESMAN_CFG_SESS_POLICY_UBI_S "UBI"
+#define SESMAN_CFG_SESS_POLICY_UBC_S "UBC"
+#define SESMAN_CFG_SESS_POLICY_UBDI_S "UBDI"
+#define SESMAN_CFG_SESS_POLICY_UBDC_S "UBDC"
+
+enum SESMAN_CFG_SESS_POLICY_BITS {
+ SESMAN_CFG_SESS_POLICY_D = 0x01,
+ SESMAN_CFG_SESS_POLICY_I = 0x02,
+ SESMAN_CFG_SESS_POLICY_C = 0x04
+};
+
+enum SESMAN_CFG_SESS_POLICY {
+ SESMAN_CFG_SESS_POLICY_DFLT = 0,
+ SESMAN_CFG_SESS_POLICY_UBD = SESMAN_CFG_SESS_POLICY_D,
+ SESMAN_CFG_SESS_POLICY_UBI = SESMAN_CFG_SESS_POLICY_I,
+ SESMAN_CFG_SESS_POLICY_UBC = SESMAN_CFG_SESS_POLICY_C,
+ SESMAN_CFG_SESS_POLICY_UBDI = SESMAN_CFG_SESS_POLICY_D | SESMAN_CFG_SESS_POLICY_I,
+ SESMAN_CFG_SESS_POLICY_UBDC = SESMAN_CFG_SESS_POLICY_D | SESMAN_CFG_SESS_POLICY_C
+};
+
/**
*
* @struct config_security
@@ -134,6 +158,11 @@ struct config_sessions
* @brief enables automatic killing of disconnected session
*/
int kill_disconnected;
+ /**
+ * @var policy
+ * @brief session allocation policy
+ */
+ enum SESMAN_CFG_SESS_POLICY policy;
};
/**
@@ -192,6 +221,13 @@ struct config_sesman
* @var log
* @brief Log configuration struct
*/
+
+ struct list* xorg_params;
+ /**
+ * @var log
+ * @brief Log configuration struct
+ */
+
//struct log_config log;
/**
* @var sec
@@ -285,7 +321,20 @@ int DEFAULT_CC
config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
struct list* param_v);
-
+/**
+ *
+ * @brief Reads sesman [XOrg] configuration section
+ * @param file configuration file descriptor
+ * @param cs pointer to a config_sesman struct
+ * @param param_n parameter name list
+ * @param param_v parameter value list
+ * @return 0 on success, 1 on failure
+ *
+ */
+int DEFAULT_CC
+config_read_xorg_params(int file, struct config_sesman* cs, struct list* param_n,
+ struct list* param_v);
+
/**
*
* @brief Reads sesman [Xvnc] configuration section
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c
index 4c389655..8f5841a5 100644
--- a/sesman/libscp/libscp_session.c
+++ b/sesman/libscp/libscp_session.c
@@ -58,12 +58,19 @@ scp_session_set_type(struct SCP_SESSION *s, tui8 type)
case SCP_SESSION_TYPE_XVNC:
s->type = SCP_SESSION_TYPE_XVNC;
break;
+
case SCP_SESSION_TYPE_XRDP:
s->type = SCP_SESSION_TYPE_XRDP;
break;
+
+ case SCP_SESSION_TYPE_XORG:
+ s->type = SCP_SESSION_TYPE_XORG;
+ break;
+
case SCP_GW_AUTHENTICATION:
s->type = SCP_GW_AUTHENTICATION;
break;
+
case SCP_SESSION_TYPE_MANAGE:
s->type = SCP_SESSION_TYPE_MANAGE;
s->mng = (struct SCP_MNG_DATA *)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
@@ -75,6 +82,7 @@ scp_session_set_type(struct SCP_SESSION *s, tui8 type)
}
break;
+
default:
log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
return 1;
diff --git a/sesman/libscp/libscp_types.h b/sesman/libscp/libscp_types.h
index 2140eced..de851867 100644
--- a/sesman/libscp/libscp_types.h
+++ b/sesman/libscp/libscp_types.h
@@ -41,6 +41,8 @@
#define SCP_SESSION_TYPE_XVNC 0x00
#define SCP_SESSION_TYPE_XRDP 0x01
#define SCP_SESSION_TYPE_MANAGE 0x02
+#define SCP_SESSION_TYPE_XORG 0x03
+
/* SCP_GW_AUTHENTICATION can be used when XRDP + sesman act as a gateway
* XRDP sends this command to let sesman verify if the user is allowed
* to use the gateway */
diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c
index afa09bd8..eab616ff 100644
--- a/sesman/libscp/libscp_v0.c
+++ b/sesman/libscp/libscp_v0.c
@@ -56,6 +56,10 @@ scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
{
out_uint16_be(c->out_s, 10);
}
+ else if (s->type == SCP_SESSION_TYPE_XORG)
+ {
+ out_uint16_be(c->out_s, 20);
+ }
else
{
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
@@ -191,7 +195,7 @@ scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk)
in_uint16_be(c->in_s, code);
- if (code == 0 || code == 10)
+ if (code == 0 || code == 10 || code == 20)
{
session = scp_session_create();
@@ -207,10 +211,20 @@ scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk)
{
scp_session_set_type(session, SCP_SESSION_TYPE_XVNC);
}
- else
+ else if (code == 10)
{
scp_session_set_type(session, SCP_SESSION_TYPE_XRDP);
}
+ else if (code == 20)
+ {
+ scp_session_set_type(session, SCP_SESSION_TYPE_XORG);
+ }
+ else
+ {
+ log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: "
+ "invalid code in xrdp.ini file: code=%d", __LINE__, code);
+ return SCP_SERVER_STATE_INTERNAL_ERR;
+ }
/* reading username */
in_uint16_be(c->in_s, sz);
diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c
index aeaa22ee..ce528d46 100644
--- a/sesman/scp_v0.c
+++ b/sesman/scp_v0.c
@@ -74,7 +74,7 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
else if (data)
{
s_item = session_get_bydata(s->username, s->width, s->height,
- s->bpp, s->type);
+ s->bpp, s->type, s->client_ip);
if (s_item != 0)
{
@@ -122,12 +122,21 @@ scp_v0_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
s->domain, s->program, s->directory,
s->client_ip);
}
- else
+ else if (SCP_SESSION_TYPE_XRDP == s->type)
{
log_message(LOG_LEVEL_INFO, "starting X11rdp session...");
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);
+ }
+ else if (SCP_SESSION_TYPE_XORG == s->type)
+ {
+ /* 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,
+ s->domain, s->program, s->directory,
s->client_ip);
}
}
diff --git a/sesman/sesman.ini b/sesman/sesman.ini
index 5ee0b4cd..4241bd32 100644
--- a/sesman/sesman.ini
+++ b/sesman/sesman.ini
@@ -10,22 +10,52 @@ AllowRootLogin=1
MaxLoginRetry=4
TerminalServerUsers=tsusers
TerminalServerAdmins=tsadmins
-# When AlwaysGroupCheck = false access will be permitted
+# When AlwaysGroupCheck = false access will be permitted
# if the group TerminalServerUsers is not defined.
AlwaysGroupCheck = false
[Sessions]
+
+## X11DisplayOffset - x11 display number offset
+# Type: integer
+# Default: 10
X11DisplayOffset=10
+
+## MaxSessions - maximum number of connections to an xrdp server
+# Type: integer
+# Default: 0
MaxSessions=50
+
+## KillDisconnected - kill disconnected sessions
+# Type: integer
+# Default: 0
# if 1, true, or yes, kill session after 60 seconds
KillDisconnected=0
+
+## IdleTimeLimit - when to disconnect idle sessions
+# Type: integer
+# Default: 0
# if not zero, the seconds without mouse or keyboard input before disconnect
# not complete yet
IdleTimeLimit=0
+
+## DisconnectedTimeLimit - when to kill idle sessions
+# Type: integer
+# Default: 0
# if not zero, the seconds before a disconnected session is killed
# min 60 seconds
DisconnectedTimeLimit=0
+## Policy - session allocation policy
+# Type: enum [ "Default" | "UBD" | "UBI" | "UBC" | "UBDI" | "UBDC" ]
+# Default: Xrdp:<User,BitPerPixel> and Xvnc:<User,BitPerPixel,DisplaySize>
+# "UBD" session per <User,BitPerPixel,DisplaySize>
+# "UBI" session per <User,BitPerPixel,IPAddr>
+# "UBC" session per <User,BitPerPixel,Connection>
+# "UBDI" session per <User,BitPerPixel,DisplaySize,IPAddr>
+# "UBDC" session per <User,BitPerPixel,DisplaySize,Connection>
+Policy=Default
+
[Logging]
LogFile=xrdp-sesman.log
LogLevel=DEBUG
@@ -47,3 +77,17 @@ param4=tcp
param5=-localhost
param6=-dpi
param7=96
+
+[Xorg]
+param1=-config
+param2=xrdp/xorg.conf
+param3=-logfile
+param4=/dev/null
+param5=-noreset
+param6=-ac
+param7=-nolisten
+param8=tcp
+
+[Chansrv]
+# drive redirection, defaults to xrdp_client if not set
+FuseMountName=thinclient_drives
diff --git a/sesman/session.c b/sesman/session.c
index 665d1138..6b49a3fb 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -90,9 +90,10 @@ dumpItemsToString(struct list *self, char *outstr, int len)
/******************************************************************************/
struct session_item *DEFAULT_CC
-session_get_bydata(char *name, int width, int height, int bpp, int type)
+session_get_bydata(char *name, int width, int height, int bpp, int type, char *client_ip)
{
struct session_chain *tmp;
+ enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
/*THREAD-FIX require chain lock */
lock_chain_acquire();
@@ -104,23 +105,49 @@ session_get_bydata(char *name, int width, int height, int bpp, int type)
{
case SCP_SESSION_TYPE_XVNC: /* 0 */
type = SESMAN_SESSION_TYPE_XVNC; /* 2 */
+ policy |= SESMAN_CFG_SESS_POLICY_D; /* Xvnc cannot resize */
break;
case SCP_SESSION_TYPE_XRDP: /* 1 */
type = SESMAN_SESSION_TYPE_XRDP; /* 1 */
break;
+ case SCP_SESSION_TYPE_XORG:
+ type = SESMAN_SESSION_TYPE_XORG;
+ break;
default:
lock_chain_release();
return 0;
}
+#if 0
+ log_message(LOG_LEVEL_INFO,
+ "session_get_bydata: search policy %d U %s W %d H %d bpp %d T %d IP %s",
+ policy, name, width, height, bpp, type, client_ip);
+#endif
+
while (tmp != 0)
{
+#if 0
+ log_message(LOG_LEVEL_INFO,
+ "session_get_bydata: try %p U %s W %d H %d bpp %d T %d IP %s",
+ tmp->item,
+ tmp->item->name,
+ tmp->item->width, tmp->item->height,
+ tmp->item->bpp, tmp->item->type,
+ 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 &&
- tmp->item->bpp == bpp &&
- tmp->item->type == type)
+ (!(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();
@@ -129,10 +156,13 @@ session_get_bydata(char *name, int width, int height, int bpp, int type)
}
if (g_strncmp(name, tmp->item->name, 255) == 0 &&
- tmp->item->width == width &&
- tmp->item->height == height &&
- tmp->item->bpp == bpp &&
- tmp->item->type == type)
+ (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();
@@ -574,10 +604,40 @@ session_start_fork(int width, int height, int bpp, char *username,
g_snprintf(text, 255, "%d", g_cfg->sess.kill_disconnected);
g_setenv("XRDP_SESMAN_KILL_DISCONNECTED", text, 1);
- if (type == SESMAN_SESSION_TYPE_XVNC)
+ if (type == SESMAN_SESSION_TYPE_XORG)
+ {
+ xserver_params = list_create();
+ xserver_params->auto_free = 1;
+
+ /* these are the must have parameters */
+ list_add_item(xserver_params, (long) g_strdup("/usr/bin/Xorg"));
+ list_add_item(xserver_params, (long) g_strdup(screen));
+
+ /* additional parameters from sesman.ini file */
+ list_append_list_strdup(g_cfg->xorg_params, xserver_params, 0);
+
+ /* make sure it ends with a zero */
+ list_add_item(xserver_params, 0);
+
+ pp1 = (char **) xserver_params->items;
+
+ log_message(LOG_LEVEL_INFO, "%s", dumpItemsToString(xserver_params, execvpparams, 2048));
+
+ /* some args are passed via env vars */
+ g_sprintf(geometry, "%d", width);
+ g_setenv("XRDP_START_WIDTH", geometry, 1);
+
+ g_sprintf(geometry, "%d", height);
+ g_setenv("XRDP_START_HEIGHT", geometry, 1);
+
+ /* fire up Xorg */
+ g_execvp("/usr/bin/Xorg", pp1);
+ }
+ else if (type == SESMAN_SESSION_TYPE_XVNC)
{
xserver_params = list_create();
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));
@@ -596,13 +656,14 @@ session_start_fork(int width, int height, int bpp, char *username,
/* make sure it ends with a zero */
list_add_item(xserver_params, 0);
pp1 = (char **)xserver_params->items;
- log_message(LOG_LEVEL_INFO, "Xvnc start:%s", dumpItemsToString(xserver_params, execvpparams, 2048));
+ log_message(LOG_LEVEL_INFO, "%s", dumpItemsToString(xserver_params, execvpparams, 2048));
g_execvp("Xvnc", pp1);
}
else if (type == SESMAN_SESSION_TYPE_XRDP)
{
xserver_params = list_create();
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));
@@ -619,7 +680,7 @@ session_start_fork(int width, int height, int bpp, char *username,
/* make sure it ends with a zero */
list_add_item(xserver_params, 0);
pp1 = (char **)xserver_params->items;
- log_message(LOG_LEVEL_INFO, "X11rdp start:%s", dumpItemsToString(xserver_params, execvpparams, 2048));
+ log_message(LOG_LEVEL_INFO, "%s", dumpItemsToString(xserver_params, execvpparams, 2048));
g_execvp("X11rdp", pp1);
}
else
diff --git a/sesman/session.h b/sesman/session.h
index 4329df12..05e3b3a9 100644
--- a/sesman/session.h
+++ b/sesman/session.h
@@ -30,8 +30,9 @@
#include "libscp_types.h"
-#define SESMAN_SESSION_TYPE_XRDP 1
-#define SESMAN_SESSION_TYPE_XVNC 2
+#define SESMAN_SESSION_TYPE_XRDP 1
+#define SESMAN_SESSION_TYPE_XVNC 2
+#define SESMAN_SESSION_TYPE_XORG 3
#define SESMAN_SESSION_STATUS_ACTIVE 0x01
#define SESMAN_SESSION_STATUS_IDLE 0x02
@@ -90,9 +91,9 @@ struct session_chain
*
*/
struct session_item* DEFAULT_CC
-session_get_bydata(char* name, int width, int height, int bpp, int type);
+session_get_bydata(char* name, int width, int height, int bpp, int type, char *client_ip);
#ifndef session_find_item
- #define session_find_item(a, b, c, d, e) session_get_bydata(a, b, c, d, e);
+ #define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif
/**