From 8f7ff94762b029203fb3751573a5729a5c642370 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 21 Mar 2018 18:06:20 -0700 Subject: [PATCH] adbd: spawn login shell when run without a command. Match openssh's behavior with regards to login shells. Bug: http://b/76116378 Test: `adb shell -T set -o` vs `ssh localhost -T set -o` Test: `adb shell -tt set -o` vs `ssh localhost -tt set -o` Test: `echo set -o | adb shell -T` vs `echo set -o | ssh localhost -T` Test: `echo set -o | adb shell -tt` vs `echo set -o | ssh localhost -tt` Change-Id: I6ed69b43e2ac79c947c242948b5617ece08a713e --- adb/daemon/shell_service.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adb/daemon/shell_service.cpp b/adb/daemon/shell_service.cpp index c04ceafa7..bb6597780 100644 --- a/adb/daemon/shell_service.cpp +++ b/adb/daemon/shell_service.cpp @@ -335,7 +335,8 @@ bool Subprocess::ForkAndExec(std::string* error) { signal(SIGPIPE, SIG_DFL); if (command_.empty()) { - execle(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr, cenv.data()); + // Spawn a login shell if we don't have a command. + execle(_PATH_BSHELL, "-" _PATH_BSHELL, nullptr, cenv.data()); } else { execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data()); }