Android开启adb root 和 Console Root

文章目录

      • adb root 开启
      • Console root 开启

adb root 开启

    feat: Allow adb Root.
            Notice: need build bootimage then download boot.img

diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp
index 4721e2fbb4..ef3d7817f0 100644
--- a/system/core/adb/daemon/main.cpp
+++ b/system/core/adb/daemon/main.cpp
@@ -64,6 +64,7 @@ static void drop_capabilities_bounding_set_if_needed() {
 }
 
 static bool should_drop_privileges() {
+    return false;
 #if defined(ALLOW_ADBD_ROOT)
     char value[PROPERTY_VALUE_MAX];

生成的adbd 在 out 目录下 root/sbin/adbd 所以需要编译boot

Console root 开启

--- a/system/core/rootdir/init.rc
+++ b/system/core/rootdir/init.rc
@@ -666,9 +666,12 @@ service console /system/bin/sh
     class core
     console
     disabled
-    user shell
-    group shell log readproc
-    seclabel u:r:shell:s0
+#    user shell
+#    group shell log readproc
+#    seclabel u:r:shell:s0
+    user root
+    group root
+    seclabel u:r:su:s0
 
 on property:ro.debuggable=1
     # Give writes to anyone for the trace folder on debug builds.

init.rc会被拷贝到out 目录下 root/ 下, 所有需要编译 boot

你可能感兴趣的:(Android)