简体   繁体   English

如何在init.rc文件中完全禁用Android L中的SELinux?

[英]How to completely disable SELinux in Android L in the init.rc file?

I want to disable SELinux at boot time for Android L or 5. The reason is because my daemon is not begin executed on boot when it should due to SELinux problems. 我想在启动时为Android L或5禁用SELinux。原因是因为SELinux问题,我的守护程序在启动时不会开始执行。 I have the following in my init.rc file: 我在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

However, on boot, I use adb shell to check if SELinux is disabled (using getenforce ) and it returns Enforcing . 但是,在启动时,我使用adb shell来检查SELinux是否被禁用(使用getenforce )并返回Enforcing I want SELinux to be completely disabled on boot. 我希望SELinux在启动时完全禁用。 If not completely disabled then at least Permissive . 如果没有完全禁用那么至少是Permissive

Any suggestions? 有什么建议?

Instead of putting in init.rc you can make it permissive by adding some parameters to kernel command line (BOARD_KERNEL_CMDLINE) 而不是放入init.rc,你可以通过向内核命令行添加一些参数(BOARD_KERNEL_CMDLINE)来实现它

Ex: Add enforcing=0 androidboot.selinux=permissive in device/<manufacturer>/<target>/BoardConfig.mk 例如:在device/<manufacturer>/<target>/BoardConfig.mk添加enforcing=0 androidboot.selinux=permissive

Well I guess you could create a new domain policy for your "my_daemon". 好吧,我猜你可以为你的“my_daemon”创建一个新的域策略。 For example, you can create mydomain.te file at device/manufacturer/device-name/sepolicy/ of your AOSP, with the following contents, 例如,您可以在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)

Now Add the following line to device/manufacturer/device-name/sepolicy/file_contexts: 现在将以下行添加到device / manufacturer / device-name / sepolicy / file_contexts:

/system/bin/my_daemon   u:object_r:mydomain_exec:s0

Here is your init.rc file: 这是你的init.rc文件:

service my_daemon /system/bin/my_daemon
    class core

So the good thing here is that only mydomain will be permissive and rest of the system will be enforcing, thus you can have your daemon running without any problems and still maintaining the system security. 所以这里的好处是只有mydomain才会允许,并且系统的其余部分都会强制执行,因此你可以让你的守护进程运行没有任何问题并且仍然保持系统安全性。

After

setenforce 0 setenforce 0

the enforce attribute will be Permissive imeddiately. enforce属性将是imissivediately。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM