1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

pty.c: user shell

* ext/pty/pty.c (establishShell): honor USER environment variable
  and login name over uid, one pid can be shared by some login
  names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-04-30 01:09:07 +00:00
parent 3908b3da22
commit 00a2285917
3 changed files with 15 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Sat Apr 30 10:09:04 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (establishShell): honor USER environment variable
and login name over uid, one pid can be shared by some login
names.
Fri Apr 29 22:40:28 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* doc/maintainers.rdoc (ext/io/nonblock): still maintained, as

View file

@ -9,6 +9,7 @@ if /mswin|mingw|bccwin|nacl/ !~ RUBY_PLATFORM
have_header("libutil.h")
have_header("util.h") # OpenBSD openpty
have_header("pty.h")
have_header("pwd.h")
have_library("util", "openpty")
if have_func("posix_openpt") or
have_func("openpty") or

View file

@ -9,7 +9,9 @@
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
@ -157,7 +159,6 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
int master, slave, status = 0;
rb_pid_t pid;
char *p, *getenv();
struct passwd *pwent;
VALUE v;
struct child_info carg;
char errbuf[32];
@ -169,11 +170,16 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
shellname = p;
}
else {
pwent = getpwuid(getuid());
#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;
else
shellname = "/bin/sh";
#else
shellname = "/bin/sh";
#endif
}
v = rb_str_new2(shellname);
argc = 1;