A40I 平台支持 app 调用“su”获取 root 权限,默认情况下该功能为未启用状态,启用方法如下: 系统开机后启用: 1、打开设置,点击”关于平板电脑”,连续点击“版本号”,底部会有提示“您现在处于开发者模式”。 2、点击“系统”-> "高级" ->"开发者选项"。 3、打开 root 授权选项:将选项打开。 4、App 获取 root 权限测试。 源码启用,patch如下: diff --git a/base/cmds/app_process/app_main.cpp b/base/cmds/app_process/app_main.cpp index 3668b90b..bd4a302e 100755 --- a/base/cmds/app_process/app_main.cpp +++ b/base/cmds/app_process/app_main.cpp @@ -203,6 +203,7 @@ static const char ABI_LIST_PROPERTY[] = "ro.product.cpu.abilist32"; static const char ZYGOTE_NICE_NAME[] = "zygote"; #endif
+/* static int root_access(){ char enabled[PROPERTY_VALUE_MAX]={0};
@@ -210,11 +211,12 @@ static int root_access(){
return atoi(enabled); } +*/
int main(int argc, char* const argv[]) { setpriority(PRIO_PROCESS,0,-20); - + /* if (root_access() == 0){ if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) { // Older kernels don't understand PR_SET_NO_NEW_PRIVS and return @@ -225,6 +227,7 @@ int main(int argc, char* const argv[]) } } } + */
AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv)); // Process command line arguments diff --git a/base/core/jni/com_android_internal_os_Zygote.cpp b/base/core/jni/com_android_internal_os_Zygote.cpp index 46b99e9f..75cb9f96 100755 --- a/base/core/jni/com_android_internal_os_Zygote.cpp +++ b/base/core/jni/com_android_internal_os_Zygote.cpp @@ -234,7 +234,9 @@ static int root_access(){ } static void DropCapabilitiesBoundingSet(JNIEnv* env) { + if (root_access() == 0){ +/* for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) { int rc = prctl(PR_CAPBSET_DROP, i, 0, 0, 0); if (rc == -1) { @@ -246,7 +248,9 @@ static void DropCapabilitiesBoundingSet(JNIEnv* env) { } } } + */ } + } static void SetCapabilities(JNIEnv* env, int64_t permitted, int64_t effective) { diff --git a/core/init/init.cpp b/core/init/init.cpp index 9fffcc0..4ca72be 100755 --- a/core/init/init.cpp +++ b/core/init/init.cpp @@ -527,6 +527,7 @@ static bool selinux_is_disabled(void) static bool selinux_is_enforcing(void) { + return false; if (ALLOW_PERMISSIVE_SELINUX) { return selinux_status_from_cmdline() == SELINUX_ENFORCING; } diff --git a/extras/su/su.c b/extras/su/su.c index fad31e7..9045bc3 100755 --- a/extras/su/su.c +++ b/extras/su/su.c @@ -89,11 +89,11 @@ void extract_uidgids(const char* uidgids, uid_t* uid, gid_t* gid, gid_t* gids, i } int main(int argc, char** argv) { - uid_t current_uid = getuid(); + //uid_t current_uid = getuid(); //if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed"); - if (!root_access()) - if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed"); + // if (!root_access()) + // if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed"); // Handle -h and --help. |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-22 10:35
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.