From a39b4137463841c364f8a08d8b9b28fc80a69739 Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Thu, 14 Jun 2018 15:31:12 +0900 Subject: [PATCH] sesman: make the path of reconnect script configurable --- sesman/config.c | 26 ++++++++++++++++++++++++++ sesman/config.h | 6 ++++++ sesman/sesman.ini.in | 1 + sesman/session.c | 6 ++---- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 0fa8c86b..28b66cda 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -117,6 +117,7 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, cf->user_wm[0] = '\0'; cf->default_wm = 0; cf->auth_file_path = 0; + cf->reconnect_sh = 0; file_read_section(file, SESMAN_CFG_GLOBALS, param_n, param_v); @@ -148,6 +149,10 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, { cf->auth_file_path = g_strdup((char *)list_get_item(param_v, i)); } + else if (g_strcasecmp(buf, SESMAN_CFG_RECONNECT_SH) == 0) + { + cf->reconnect_sh = g_strdup((char *)list_get_item(param_v, i)); + } } /* checking for missing required parameters */ @@ -186,6 +191,25 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, g_free(buf); } + if (cf->reconnect_sh == 0) + { + cf->reconnect_sh = g_strdup("reconnectwm.sh"); + } + else if (g_strlen(cf->reconnect_sh) == 0) + { + g_free(cf->reconnect_sh); + cf->reconnect_sh = g_strdup("reconnectwm.sh"); + } + if (cf->reconnect_sh[0] != '/') + { + buf = (char *)g_malloc(1024, 0); + g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, g_cfg->reconnect_sh); + g_free(g_cfg->reconnect_sh); + g_cfg->reconnect_sh = g_strdup(buf); + g_free(buf); + } + + return 0; } @@ -451,6 +475,7 @@ config_dump(struct config_sesman *config) g_writeln(" EnableUserWindowManager: %d", config->enable_user_wm); g_writeln(" UserWindowManager: %s", config->user_wm); g_writeln(" DefaultWindowManager: %s", config->default_wm); + g_writeln(" ReconnectScript: %s", config->reconnect_sh); g_writeln(" AuthFilePath: %s", ((config->auth_file_path) ? (config->auth_file_path) : ("disabled"))); @@ -546,6 +571,7 @@ void config_free(struct config_sesman *cs) { g_free(cs->default_wm); + g_free(cs->reconnect_sh); g_free(cs->auth_file_path); list_delete(cs->rdp_params); list_delete(cs->vnc_params); diff --git a/sesman/config.h b/sesman/config.h index fc964a60..6e63fcef 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -39,6 +39,7 @@ #define SESMAN_CFG_USERWM "UserWindowManager" #define SESMAN_CFG_MAX_SESSION "MaxSessions" #define SESMAN_CFG_AUTH_FILE_PATH "AuthFilePath" +#define SESMAN_CFG_RECONNECT_SH "ReconnectScript" #define SESMAN_CFG_RDP_PARAMS "X11rdp" #define SESMAN_CFG_XORG_PARAMS "Xorg" @@ -204,6 +205,11 @@ struct config_sesman * @brief Default window manager */ char user_wm[32]; + /** + * @var reconnect_sh + * @brief Script executed when reconnected + */ + char *reconnect_sh; /** * @var auth_file_path * @brief Auth file path diff --git a/sesman/sesman.ini.in b/sesman/sesman.ini.in index e3609da2..f3cdc7f7 100644 --- a/sesman/sesman.ini.in +++ b/sesman/sesman.ini.in @@ -4,6 +4,7 @@ ListenPort=3350 EnableUserWindowManager=true UserWindowManager=startwm.sh DefaultWindowManager=startwm.sh +ReconnectScript=reconnectwm.sh [Security] AllowRootLogin=true diff --git a/sesman/session.c b/sesman/session.c index 3c128ebb..0877c542 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -862,7 +862,6 @@ static int session_reconnect_fork(int display, char *username, long data) { int pid; - char text[256]; pid = g_fork(); @@ -877,11 +876,10 @@ session_reconnect_fork(int display, char *username, long data) g_cfg->env_names, g_cfg->env_values); auth_set_env(data); - g_snprintf(text, 255, "%s/%s", XRDP_CFG_PATH, "reconnectwm.sh"); - if (g_file_exist(text)) + if (g_file_exist(g_cfg->reconnect_sh)) { - g_execlp3(text, g_cfg->default_wm, 0); + g_execlp3(g_cfg->reconnect_sh, g_cfg->reconnect_sh, 0); } g_exit(0);