如何解决启动后在 Android 中运行自定义脚本
我有一个脚本,我想在 Android 启动一段时间后运行它。我进行了以下更改:
在 init.rc 中
service bootscript /system/bin/sh /system/bin/bootscript
class late_start
user root
group root
oneshot
在生成文件中:
PRODUCT_COPY_FILES += \
device/qcom/msm8953_32/bootscript:system/bin/bootscript
在那之后,当我构建和刷新时,我在 dmesg 中遇到以下错误,
[ 59.243265] init: service bootscript does not have a SELinux domain defined
在系统/sepolicy/private/file_contexts
/system/bin/bootscript -- u:object_r:shell_exec:s0
我仍然收到这个错误,我还要补充什么?我试过在网上找,I found steps where they add it init_daemon_domain(),是不是一样的东西?因为我在那里没有看到任何 PRODUCT_COPY_FILES 步骤,所以我很困惑。
解决方法
你不应该用 shell_exec 标记引导脚本。没有规则init_daemon_domain(shell)。
所以你应该关注the example。
- 定义一个新域,并添加初始化转换规则。
type foo,domain;
type foo_exec,exec_type,file_type;
init_daemon_domain(foo)
- 用新标签标记您的文件。
/system/bin/bootscript -- u:object_r:foo_exec:s0
init_daemon_domain(foo) 表示带有 foo_exec 标签的文件将从 init 转换为 foo 域。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。