Handle getlogin failure in PTY.spawn
getlogin is only called if USER environment variable is not set, but if getlogin returns NULL in that case, then do not call getpwnam, and assume /bin/sh as shell. Mentioned in comment to bug 20586.
This commit is contained in:
parent
ae886e0c83
commit
a3f5a043fa
Notes:
git
2024-08-22 02:21:06 +00:00
@ -215,9 +215,13 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
|
||||
else {
|
||||
#if defined HAVE_PWD_H
|
||||
const char *username = getenv("USER");
|
||||
struct passwd *pwent = getpwnam(username ? username : getlogin());
|
||||
if (pwent && pwent->pw_shell)
|
||||
shellname = pwent->pw_shell;
|
||||
if (username == NULL)
|
||||
username = getlogin();
|
||||
if (username != NULL) {
|
||||
struct passwd *pwent = getpwnam(username);
|
||||
if (pwent && pwent->pw_shell)
|
||||
shellname = pwent->pw_shell;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
v = rb_str_new2(shellname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user