adb root works Runtime.GetRuntime().Exec(“su”); does not

点点圈 提交于 2020-01-02 07:02:33

问题


I am running android 7.1.1 on a custom device with the AOSP compiled from source in the 'userdebug' configuration, which gives root access and debug.

I can connect to the device using the android device bridge.

adb root
adb shell
device_name:/ # su

All of these commands work fine and I can make changes as a super user. The problem I am having is running the same "su" command from an app

Java.Lang.Process suProcess = Runtime.GetRuntime().Exec("su");

The error I am receiving is:

Java.IO.IOException: Cannot run program "su": error=13, Permission denied

Is there a difference between the adb root/ shell su commands and the commands run from within an app?


回答1:


It looks like both linux DAC and SE-Android are blocking your application's process from accessing the 'su' executable.

Check if your system is running in enforced mode, meaning that SE-Android is enabled. If this is indeed the case, you can temporarily disable it by running:

adb root

adb shell setenfoerce 0

This will disable SE-Android and will not block the apps process from executing 'su'.

Additionally, your app might not have the DAC permissions necessary to launch 'su' as root. You can execute the following command:

adb shell ps

For a list of all running processes on your device. locate your app (by searching for its package name), and check its group and uid. Most probably neither are root.

Please note that building a custom userdebug image is not quite like rooting a standard Android device. The debug version is meant to allow access to the device's internals while still simulating a real functioning device with all of its default security mechanisms enabled.



来源:https://stackoverflow.com/questions/45995962/adb-root-works-runtime-getruntime-execsu-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!