diff options
author | Elliott Hughes <enh@google.com> | 2015-11-02 22:05:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-11-02 22:05:07 +0000 |
commit | 36d7af4cf635816ecbcb9bd300f4c9d60cb012d4 (patch) | |
tree | e97c68be2cb87d23c2ca78a70f8679901f3d4fff /adb | |
parent | 6e699df21e1b08aa2e9eb18ef1c44788549ae8ed (diff) | |
parent | fbe4332e373208637dd928edf06a0da6cba92feb (diff) | |
download | core-36d7af4cf635816ecbcb9bd300f4c9d60cb012d4.tar.gz core-36d7af4cf635816ecbcb9bd300f4c9d60cb012d4.tar.bz2 core-36d7af4cf635816ecbcb9bd300f4c9d60cb012d4.zip |
Merge "Set HOME, LOGNAME, SHELL, and USER from adbd."
Diffstat (limited to 'adb')
-rw-r--r-- | adb/shell_service.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp index 544afcebb..be5921d8e 100644 --- a/adb/shell_service.cpp +++ b/adb/shell_service.cpp @@ -83,6 +83,7 @@ #include <errno.h> #include <pty.h> +#include <pwd.h> #include <sys/select.h> #include <termios.h> @@ -281,6 +282,15 @@ bool Subprocess::ForkAndExec() { parent_error_sfd.Reset(); close_on_exec(child_error_sfd.fd()); + // TODO: $HOSTNAME? Normally bash automatically sets that, but mksh doesn't. + passwd* pw = getpwuid(getuid()); + if (pw != nullptr) { + setenv("HOME", pw->pw_dir, 1); + setenv("LOGNAME", pw->pw_name, 1); + setenv("SHELL", pw->pw_shell, 1); + setenv("USER", pw->pw_name, 1); + } + if (is_interactive()) { execl(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr); } else { |