[sesexec] pass_shell_as_env only if user sets a shell

set environment variable only if the user actually requests a specific
shell.
This commit is contained in:
akarl10
2026-01-01 15:08:11 +01:00
parent c7b83c47b3
commit c1ed8b8eb6
+26 -24
View File
@@ -255,38 +255,40 @@ start_window_manager(const struct login_info *login_info,
}
}
if (g_cfg->sec.allow_alternate_shell &&
g_cfg->sec.pass_shell_as_env != NULL &&
g_cfg->sec.pass_shell_as_env[0] != '0')
if (s->shell[0] != '\0')
{
// Pass the shell in to the standard startwm scripts
// in an environment variable
LOG(LOG_LEVEL_INFO,
"Setting variable '%s' to the specified shell of '%s'",
g_cfg->sec.pass_shell_as_env,
s->shell);
g_setenv_log(g_cfg->sec.pass_shell_as_env, s->shell, 1);
}
else if (s->shell[0] != '\0')
{
// Try to execute the shell directly (if permitted)
if (g_cfg->sec.allow_alternate_shell)
{
if (g_strchr(s->shell, ' ') != 0 || g_strchr(s->shell, '\t') != 0)
if (g_cfg->sec.pass_shell_as_env != NULL &&
g_cfg->sec.pass_shell_as_env[0] != '\0')
{
// Pass the shell in to the standard startwm scripts
// in an environment variable
LOG(LOG_LEVEL_INFO,
"Using user requested window manager on "
"display %u with embedded arguments using a shell: %s",
s->display, s->shell);
const char *argv[] = {"sh", "-c", s->shell, NULL};
g_execvp("/bin/sh", (char **)argv);
"Setting variable '%s' to the specified shell of '%s'",
g_cfg->sec.pass_shell_as_env,
s->shell);
g_setenv_log(g_cfg->sec.pass_shell_as_env, s->shell, 1);
}
else
{
LOG(LOG_LEVEL_INFO,
"Using user requested window manager on "
"display %d: %s", s->display, s->shell);
g_execlp3(s->shell, s->shell, 0);
// Try to execute the shell directly (if permitted)
if (g_strchr(s->shell, ' ') != 0 || g_strchr(s->shell, '\t') != 0)
{
LOG(LOG_LEVEL_INFO,
"Using user requested window manager on "
"display %u with embedded arguments using a shell: %s",
s->display, s->shell);
const char *argv[] = {"sh", "-c", s->shell, NULL};
g_execvp("/bin/sh", (char **)argv);
}
else
{
LOG(LOG_LEVEL_INFO,
"Using user requested window manager on "
"display %d: %s", s->display, s->shell);
g_execlp3(s->shell, s->shell, 0);
}
}
}
else