1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

uxpty: handle $SHELL not being set.

This is unlikely in most situations, but 'psusan' in particular is
intended to be run in a lot of weird environments where things aren't
properly set up yet. I just found out that if you use a Cygwin-built
psusan as the proxy process for Windows PuTTY (to get a local Cygwin
xterm) then it starts up with SHELL unset, and uxpty's forked
subprocess segfaults when it tries to exec a null pointer.
This commit is contained in:
Simon Tatham 2020-03-21 14:45:03 +00:00
parent 4fc5d7a5f5
commit 9fc8320fc3

View File

@ -1208,16 +1208,18 @@ Backend *pty_backend_create(
execl(shell, shell, "-c", cmd, (void *)NULL);
}
} else {
char *shell = getenv("SHELL");
const char *shell = getenv("SHELL");
if (!shell)
shell = "/bin/sh";
char *shellname;
if (conf_get_bool(conf, CONF_login_shell)) {
char *p = strrchr(shell, '/');
const char *p = strrchr(shell, '/');
shellname = snewn(2+strlen(shell), char);
p = p ? p+1 : shell;
sprintf(shellname, "-%s", p);
} else
shellname = shell;
execl(getenv("SHELL"), shellname, (void *)NULL);
shellname = (char *)shell;
execl(shell, shellname, (void *)NULL);
}
/*