• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Révisiond28cb2befd083eb0a9b0435cf5c8e768d08f94c7 (tree)
l'heure2016-09-04 08:47:14
AuteurSteve Kondik <steve@cyng...>
CommiterSteve Kondik

Message de Log

adb: Check for alternate shell paths

  • Check for persist.sys.adb.shell first
  • Check for /sbin/sh (recovery)

Change-Id: I191b9289b176809ef754d7a8126acfd355ab009f

Change Summary

Modification

--- a/adb/shell_service.cpp
+++ b/adb/shell_service.cpp
@@ -85,6 +85,7 @@
8585 #include <pty.h>
8686 #include <pwd.h>
8787 #include <sys/select.h>
88+#include <sys/stat.h>
8889 #include <termios.h>
8990
9091 #include <memory>
@@ -103,6 +104,8 @@
103104 #include "adb_utils.h"
104105 #include "security_log_tags.h"
105106
107+#include "cutils/properties.h"
108+
106109 namespace {
107110
108111 void init_subproc_child()
@@ -228,6 +231,7 @@ bool Subprocess::ForkAndExec(std::string* error) {
228231 ScopedFd child_stdinout_sfd, child_stderr_sfd;
229232 ScopedFd parent_error_sfd, child_error_sfd;
230233 char pts_name[PATH_MAX];
234+ char propbuf[PATH_MAX];
231235
232236 if (command_.empty()) {
233237 __android_log_security_bswrite(SEC_TAG_ADB_SHELL_INTERACTIVE, "");
@@ -334,12 +338,25 @@ bool Subprocess::ForkAndExec(std::string* error) {
334338 parent_error_sfd.Reset();
335339 close_on_exec(child_error_sfd.fd());
336340
341+ std::string shell_command;
342+ struct stat st;
343+ property_get("persist.sys.adb.shell", propbuf, "");
344+ if (propbuf[0] != '\0' && stat(propbuf, &st) == 0) {
345+ shell_command = propbuf;
346+ } else if (stat(_PATH_BSHELL2, &st) == 0) {
347+ shell_command = _PATH_BSHELL2;
348+ } else {
349+ shell_command = _PATH_BSHELL;
350+ }
351+
337352 if (command_.empty()) {
338- execle(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr, cenv.data());
353+ execle(shell_command.c_str(), shell_command.c_str(), "-", nullptr, cenv.data());
339354 } else {
340- execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data());
355+ execle(shell_command.c_str(), shell_command.c_str(), "-c", command_.c_str(), nullptr, cenv.data());
341356 }
342- WriteFdExactly(child_error_sfd.fd(), "exec '" _PATH_BSHELL "' failed: ");
357+
358+ std::string errmsg = "exec '" + shell_command + "' failed: ";
359+ WriteFdExactly(child_error_sfd.fd(), errmsg.c_str());
343360 WriteFdExactly(child_error_sfd.fd(), strerror(errno));
344361 child_error_sfd.Reset();
345362 _Exit(1);