From e82f212f34abee9e09383bd2908e98f7359f7ca9 Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Thu, 14 Jun 2018 11:59:27 +0900 Subject: [PATCH] sesman: accept full path for DefaultWindowManager Solves: #1143 Also, this idea is inspired by Fedora's patch [1]. Some distro wants to put all scripts in libexec directory due to SELinux. This enables distros to put such scripts anywhere. [1] https://src.fedoraproject.org/cgit/rpms/xrdp.git/tree/xrdp-0.9.6-scripts-libexec.patch?id=02f845c1b8cea781313cf3e9efcd6d7d50341824 --- sesman/config.c | 24 ++++++++++++++++++++---- sesman/config.h | 2 +- sesman/session.c | 3 +-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 8e5b096d..0fa8c86b 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -115,7 +115,7 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, cf->listen_port[0] = '\0'; cf->enable_user_wm = 0; cf->user_wm[0] = '\0'; - cf->default_wm[0] = '\0'; + cf->default_wm = 0; cf->auth_file_path = 0; file_read_section(file, SESMAN_CFG_GLOBALS, param_n, param_v); @@ -126,7 +126,7 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, if (0 == g_strcasecmp(buf, SESMAN_CFG_DEFWM)) { - g_strncpy(cf->default_wm, (char *)list_get_item(param_v, i), 31); + cf->default_wm = g_strdup((char *)list_get_item(param_v, i)); } else if (0 == g_strcasecmp(buf, SESMAN_CFG_USERWM)) { @@ -166,9 +166,24 @@ config_read_globals(int file, struct config_sesman *cf, struct list *param_n, cf->enable_user_wm = 0; } - if ('\0' == cf->default_wm[0]) + if (cf->default_wm == 0) { - g_strncpy(cf->default_wm, "startwm.sh", 11); + cf->default_wm = g_strdup("startwm.sh"); + } + else if (g_strlen(cf->default_wm) == 0) + { + g_free(cf->default_wm); + cf->default_wm = g_strdup("startwm.sh"); + } + + /* if default_wm doesn't begin with '/', it's a relative path from XRDP_CFG_PATH */ + if (cf->default_wm[0] != '/') + { + buf = (char *)g_malloc(1024, 0); + g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm); + g_free(g_cfg->default_wm); + g_cfg->default_wm = g_strdup(buf); + g_free(buf); } return 0; @@ -530,6 +545,7 @@ config_dump(struct config_sesman *config) void config_free(struct config_sesman *cs) { + g_free(cs->default_wm); 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 c7cb50fd..fc964a60 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -198,7 +198,7 @@ struct config_sesman * @var default_wm * @brief Default window manager */ - char default_wm[32]; + char *default_wm; /** * @var user_wm * @brief Default window manager diff --git a/sesman/session.c b/sesman/session.c index d33f2f5f..3c128ebb 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -575,8 +575,7 @@ session_start_fork(tbus data, tui8 type, struct SCP_CONNECTION *c, } /* if we're here something happened to g_execlp3 so we try running the default window manager */ - g_sprintf(text, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm); - g_execlp3(text, g_cfg->default_wm, 0); + g_execlp3(g_cfg->default_wm, g_cfg->default_wm, 0); log_message(LOG_LEVEL_ALWAYS, "error starting default " "wm for user %s - pid %d", s->username, g_getpid());