Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I have the following in my init.rc file:

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. I want SELinux to be completely disabled on boot. If not completely disabled then at least Permissive.

Any suggestions?

like image 731
Redson Avatar asked Mar 25 '15 14:03

Redson


People also ask

How do I disable SELinux on startup?

Using Kernel boot parameters to disable SELinuxEdit the /etc/grub. conf file and add the selinux=0 option to the booting option to disable SELinux at the booting. In this case the settings in /etc/sysconfig/selinux are ignored.

Which command is used to disable SELinux?

Check the current SELinux status, run: sestatus. To disable SELinux on CentOS 7 temporarily, run: sudo setenforce 0. Edit the /etc/selinux/config file and set the SELINUX to disabled.


1 Answers

Instead of putting in init.rc you can make it permissive by adding some parameters to kernel command line (BOARD_KERNEL_CMDLINE)

Ex: Add enforcing=0 androidboot.selinux=permissive in device/<manufacturer>/<target>/BoardConfig.mk

like image 85
Shailesh Avatar answered Sep 30 '22 05:09

Shailesh