Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ff7cc13 authored by Koushik K. Dutta's avatar Koushik K. Dutta Committed by Koushik Dutta
Browse files

Squashed adb fixes.

fix up adb to prefer /sbin/sh if it exists

allow always insecure

Change-Id: I5c15731c95d123488e90aaeac5b497f556b53363

Conflicts:

	adb/Android.mk
parent 4a253908
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DANDROID_GADGET=1
endif

ifeq ($(BOARD_ALWAYS_INSECURE),true)
	LOCAL_CFLAGS += -DBOARD_ALWAYS_INSECURE
endif

LOCAL_MODULE := adbd

LOCAL_FORCE_STATIC_EXECUTABLE := true
+2 −0
Original line number Diff line number Diff line
@@ -874,7 +874,9 @@ int adb_main(int is_daemon, int server_port)
        property_get("ro.secure", value, "1");
        if (strcmp(value, "1") == 0) {
            // don't run as root if ro.secure is set...
#ifndef BOARD_ALWAYS_INSECURE
            secure = 1;
#endif

            // ... except we allow running as root in userdebug builds if the
            // service.adb.root property has been set by the "adb root" command
+13 −2
Original line number Diff line number Diff line
@@ -343,8 +343,10 @@ static int create_subprocess(const char *cmd, const char *arg0, const char *arg1

#if ADB_HOST
#define SHELL_COMMAND "/bin/sh"
#define ALTERNATE_SHELL_COMMAND ""
#else
#define SHELL_COMMAND "/system/bin/sh"
#define ALTERNATE_SHELL_COMMAND "/sbin/sh"
#endif

#if !ADB_HOST
@@ -386,10 +388,19 @@ static int create_subproc_thread(const char *name)
    adb_thread_t t;
    int ret_fd;
    pid_t pid;
    const char* shell_command;
    struct stat filecheck;
    if (stat(ALTERNATE_SHELL_COMMAND, &filecheck) == 0) {
        shell_command = ALTERNATE_SHELL_COMMAND;
    }
    else {
        shell_command = SHELL_COMMAND;
    }
    
    if(name) {
        ret_fd = create_subprocess(SHELL_COMMAND, "-c", name, &pid);
        ret_fd = create_subprocess(shell_command, "-c", name, &pid);
    } else {
        ret_fd = create_subprocess(SHELL_COMMAND, "-", 0, &pid);
        ret_fd = create_subprocess(shell_command, "-", 0, &pid);
    }
    D("create_subprocess() ret_fd=%d pid=%d\n", ret_fd, pid);