我想在 Android L 或 5 的启动时禁用 SELinux。原因是因为 SELinux 问题,我的守护进程没有在应该在启动时开始执行。我的 init.rc 文件中有以下内容:
su 0 setenforce 0
service my_daemon /system/bin/my_daemon
class main # Also tried: class core (but it didn't make a difference)
user root
group root
但是,在启动时,我使用 adb shell 检查 SELinux 是否被禁用(使用 getenforce
)并返回 Enforcing
。我希望在启动时完全禁用 SELinux。如果没有完全禁用,则至少 Permissive
。
有什么建议吗?
最佳答案
嗯,我想您可以为您的“my_daemon”创建一个新的域策略。例如,您可以在 AOSP 的 device/manufacturer/device-name/sepolicy/创建 mydomain.te 文件,内容如下,
# mydomain policy here
type mydomain, domain;
permissive mydomain;
type mydomain_exec, exec_type, file_type;
init_daemon_domain(mydomain)
现在将以下行添加到设备/制造商/设备名称/sepolicy/file_contexts:
/system/bin/my_daemon u:object_r:mydomain_exec:s0
这是你的 init.rc 文件:
service my_daemon /system/bin/my_daemon
class core
所以这里的好处是只有 mydomain 是允许的,系统的其余部分将强制执行,因此您可以让您的守护进程毫无问题地运行,并仍然保持系统安全。
关于android - 如何在 init.rc 文件中完全禁用 Android L 中的 SELinux?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29258366/