android - 如何在启动时使用 root 权限在 Android Things 设备上运行 shell 脚本?

标签 android linux shell android-things

我已经在 Raspberry Pi 3 上安装了 Android Things DP4。现在我需要以 root 身份执行 ifconfig 以设置静态 IP。尝试过:

-在具有世界可执行权限的/system/app文件夹中安装了一个Android应用

-在具有世界可执行权限的/system/private-app 文件夹中安装了一个Android 应用

-用一个可执行的 shell 脚本文件创建了 init.d(文件夹之前不存在)

这一切都惨遭失败...

最佳答案

出于安全原因,Android(以及 Android Things)不允许应用程序以根用户身份运行。如果您的生产应用程序需要此功能,请随时将有关您的用例的任何评论添加到 existing feature request为此。

关于您已经尝试过的事情:

-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

安装在 Android 的 /system 分区中的应用程序可以特权访问各种 Android 级别的权限,但这不会影响它们的 Linux UID。

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

Android 不使用与其他 Linux 发行版相同的 init 结构。 Init 指令位于根文件系统上的各种 init.rc 文件中。通常,再次出于安全原因,即使是从 init 派生的进程也不允许以 root 身份运行,并且被赋予隔离的 SE 上下文以在其中运行。

关于android - 如何在启动时使用 root 权限在 Android Things 设备上运行 shell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45065766/

相关文章:

android - 无法打开编辑器。 Android XML 编辑器无法处理此输入

android:gravity ="center"没有按预期工作

linux - ssh,如何指定另一台机器上的 key 文件?

string - shell 脚本 : How to check if variable is null or no

python - 如何在 python 解释器 shell 中重复最后一个命令?

linux - 在 .cshrc 中设置 PATH 无效

android - Android中线程加载的Web图像

java - 静态 "DELETE"对象的用途是什么?

我可以在 Linux 上使用 Visual C 编译 C 吗?

linux - Git Install Script 如何输入shell命令