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:
parent
4fc5d7a5f5
commit
9fc8320fc3
10
unix/uxpty.c
10
unix/uxpty.c
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user