From e83b4c43f55ee3fcabf71dbf18a39e856d45e675 Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Sat, 24 Apr 2010 06:41:55 +0000 Subject: [PATCH] added X11DisplayOffset sesman option --- docs/man/sesman.ini.5 | 5 +++++ sesman/config.c | 6 ++++++ sesman/config.h | 6 ++++++ sesman/sesman.ini | 1 + sesman/session.c | 4 ++-- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/man/sesman.ini.5 b/docs/man/sesman.ini.5 index e6fd0ada..ebefd120 100644 --- a/docs/man/sesman.ini.5 +++ b/docs/man/sesman.ini.5 @@ -104,6 +104,11 @@ The following parameters can be used in the \fB[Sessions]\fR section: .br .TP +\fBX11DisplayOffset\fR=\fI\fR +Specifies the first X display number available for sesman(8). This prevents sesman from interfering with real X11 servers. The default is 10. +.br + +.TP \fBMaxSessions\fR=\fI\fR Sets the maximum number of simultaneous session on terminal server. .br diff --git a/sesman/config.c b/sesman/config.c index 102d58e1..35f93f57 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -330,6 +330,7 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n, list_clear(param_n); /* setting defaults */ + se->x11_display_offset=10; se->max_sessions=0; se->max_idle_time=0; se->max_disc_time=0; @@ -339,6 +340,10 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n, for (i = 0; i < param_n->count; i++) { buf = (char*)list_get_item(param_n, i); + if (0 == g_strcasecmp(buf, SESMAN_CFG_X11DISPLAYOFFSET)) + { + se->x11_display_offset = g_atoi((char*)list_get_item(param_v, i)); + } if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_MAX)) { se->max_sessions = g_atoi((char*)list_get_item(param_v, i)); @@ -360,6 +365,7 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n, /* printing security 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); diff --git a/sesman/config.h b/sesman/config.h index cfe7c65e..aad360ff 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -38,6 +38,7 @@ #define SESMAN_CFG_PORT "ListenPort" #define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager" #define SESMAN_CFG_USERWM "UserWindowManager" +#define SESMAN_CFG_X11DISPLAYOFFSET "X11DisplayOffset" #define SESMAN_CFG_MAX_SESSION "MaxSessions" #define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath" @@ -102,6 +103,11 @@ struct config_security */ struct config_sessions { + /** + * @var x11_display_offset + * @brief X11 TCP port offset. default value: 10 + */ + int x11_display_offset; /** * @var max_sessions * @brief maximum number of allowed sessions. 0 for unlimited diff --git a/sesman/sesman.ini b/sesman/sesman.ini index 35c88450..35db5d1f 100644 --- a/sesman/sesman.ini +++ b/sesman/sesman.ini @@ -12,6 +12,7 @@ TerminalServerUsers=tsusers TerminalServerAdmins=tsadmins [Sessions] +X11DisplayOffset=10 MaxSessions=10 KillDisconnected=0 IdleTimeLimit=0 diff --git a/sesman/session.c b/sesman/session.c index 1d487424..6edee0fd 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -252,9 +252,9 @@ session_get_aval_display_from_chain(void) { int display; - display = 10; + display = g_cfg->sess.x11_display_offset; lock_chain_acquire(); - while ((display - 10) <= g_cfg->sess.max_sessions) + while ((display - g_cfg->sess.x11_display_offset) <= g_cfg->sess.max_sessions) { if (!session_is_display_in_chain(display)) {