sesman: make the path of reconnect script configurable

This commit is contained in:
Koichiro IWAO 2018-06-14 15:31:12 +09:00
parent e82f212f34
commit a39b413746
No known key found for this signature in database
GPG Key ID: 9F72CDBC01BF10EB
4 changed files with 35 additions and 4 deletions

View File

@ -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);

View File

@ -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

View File

@ -4,6 +4,7 @@ ListenPort=3350
EnableUserWindowManager=true
UserWindowManager=startwm.sh
DefaultWindowManager=startwm.sh
ReconnectScript=reconnectwm.sh
[Security]
AllowRootLogin=true

View File

@ -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);