Skip to content

Instantly share code, notes, and snippets.

@ganadist
Created April 1, 2014 02:34
Show Gist options
  • Save ganadist/9906642 to your computer and use it in GitHub Desktop.
Save ganadist/9906642 to your computer and use it in GitHub Desktop.
system/core: run adb as root on product build
diff --git a/adb/Android.mk b/adb/Android.mk
index 721b48d..fef1bef 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -123,6 +123,7 @@ LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
endif
+LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
LOCAL_MODULE := adbd
diff --git a/adb/adb.c b/adb/adb.c
index 72b7484..c10b23c 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -1194,7 +1194,7 @@ static void drop_capabilities_bounding_set_if_needed() {
#ifdef ALLOW_ADBD_ROOT
char value[PROPERTY_VALUE_MAX];
property_get("ro.debuggable", value, "");
- if (strcmp(value, "1") == 0) {
+ if (1 || strcmp(value, "1") == 0) {
return;
}
#endif
@@ -1235,7 +1235,7 @@ static int should_drop_privileges() {
// ... except we allow running as root in userdebug builds if the
// service.adb.root property has been set by the "adb root" command
property_get("ro.debuggable", value, "");
- if (strcmp(value, "1") == 0) {
+ if (1 || strcmp(value, "1") == 0) {
property_get("service.adb.root", value, "");
if (strcmp(value, "1") == 0) {
secure = 0;
diff --git a/adb/services.c b/adb/services.c
index 951048e..cc1793d 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -68,7 +68,7 @@ void restart_root_service(int fd, void *cookie)
adb_close(fd);
} else {
property_get("ro.debuggable", value, "");
- if (strcmp(value, "1") != 0) {
+ if (0 && strcmp(value, "1") != 0) {
snprintf(buf, sizeof(buf), "adbd cannot run as root in production builds\n");
writex(fd, buf, strlen(buf));
adb_close(fd);
@charlieporth1
Copy link

charlieporth1 commented Nov 23, 2017

how do you install this file? And if possible without root?

@anonymous2ch
Copy link

how do you install this file? And if possible without root?

You just patch system/core/adb/daemon/main.cpp, build adb & send it to your device. It requires your own rom to have been built and solves not the problem with root (which you obviously have with your own rom), but with adb root, which is required for some specific hardware-oriented software to work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment