How can I run a shell script on Android Things device at boot with root permissions?

独自空忆成欢 提交于 2020-01-05 04:54:11

问题


I've installed Android Things DP4 on a Raspberry Pi 3. Now I need to execute a ifconfig as root in order to set a static IP. Tried:

-installed an Android app in the /system/app folder with world executable perms

-installed an Android app in the /system/private-app folder with world executable perms

-created init.d with a executable shell script file (folder didn't exist before)

All this failed miserably...


回答1:


Android (and therefore Android Things) does not allow applications to run as the root user for security reasons. If you need this feature for your production apps, feel free to add any comments regarding your use case to the existing feature request in place for this.

Regarding the things you already tried:

-installed an Android app in the /system/app folder with world executable perms

-installed an Android app in the /system/private-app folder with world executable perms

Apps installed in Android's /system partition are allowed privileged access to various Android-level permissions, but this does not affect their Linux UIDs.

-created init.d with a executable shell script file (folder didn't exist before)

Android does not use the same init structure as other Linux distributions. Init instructions are located in various init.rc files on the root file system. In general, again for security reasons, even the processes spawned from init are not allowed to run as root and are given isolated SE contexts to run in.



来源:https://stackoverflow.com/questions/45065766/how-can-i-run-a-shell-script-on-android-things-device-at-boot-with-root-permissi

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