Loading adb/daemon/shell_service.cpp +18 −3 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ #include <pty.h> #include <pwd.h> #include <sys/select.h> #include <sys/stat.h> #include <termios.h> #include <memory> Loading Loading @@ -113,6 +114,17 @@ namespace { static std::string GetShellPath() { std::string shell = android::base::GetProperty("persist.sys.adb.shell", ""); struct stat st; if (!shell.empty() && stat(shell.c_str(), &st) != -1) { return shell; } return _PATH_BSHELL; } // Reads from |fd| until close or failure. std::string ReadAll(int fd) { char buffer[512]; Loading Loading @@ -360,13 +372,16 @@ bool Subprocess::ForkAndExec(std::string* error) { } #endif std::string sh_path = GetShellPath(); if (command_.empty()) { // Spawn a login shell if we don't have a command. execle(_PATH_BSHELL, "-" _PATH_BSHELL, nullptr, cenv.data()); execle(sh_path.c_str(), sh_path.c_str(), "-", nullptr, cenv.data()); } else { execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data()); execle(sh_path.c_str(), sh_path.c_str(), "-c", command_.c_str(), nullptr, cenv.data()); } WriteFdExactly(child_error_sfd, "exec '" _PATH_BSHELL "' failed: "); WriteFdExactly(child_error_sfd, android::base::StringPrintf("Exec '%s' failed: ", sh_path.c_str()).c_str()); WriteFdExactly(child_error_sfd, strerror(errno)); child_error_sfd.reset(-1); _Exit(1); Loading Loading
adb/daemon/shell_service.cpp +18 −3 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ #include <pty.h> #include <pwd.h> #include <sys/select.h> #include <sys/stat.h> #include <termios.h> #include <memory> Loading Loading @@ -113,6 +114,17 @@ namespace { static std::string GetShellPath() { std::string shell = android::base::GetProperty("persist.sys.adb.shell", ""); struct stat st; if (!shell.empty() && stat(shell.c_str(), &st) != -1) { return shell; } return _PATH_BSHELL; } // Reads from |fd| until close or failure. std::string ReadAll(int fd) { char buffer[512]; Loading Loading @@ -360,13 +372,16 @@ bool Subprocess::ForkAndExec(std::string* error) { } #endif std::string sh_path = GetShellPath(); if (command_.empty()) { // Spawn a login shell if we don't have a command. execle(_PATH_BSHELL, "-" _PATH_BSHELL, nullptr, cenv.data()); execle(sh_path.c_str(), sh_path.c_str(), "-", nullptr, cenv.data()); } else { execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data()); execle(sh_path.c_str(), sh_path.c_str(), "-c", command_.c_str(), nullptr, cenv.data()); } WriteFdExactly(child_error_sfd, "exec '" _PATH_BSHELL "' failed: "); WriteFdExactly(child_error_sfd, android::base::StringPrintf("Exec '%s' failed: ", sh_path.c_str()).c_str()); WriteFdExactly(child_error_sfd, strerror(errno)); child_error_sfd.reset(-1); _Exit(1); Loading