Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling SELinux in Android 5.0.1

I am trying to identify the configuration file where SELinux is set to Enforcing mode in Android Framework.

Please do not reply just saying

adb shell su 0 setenforce permissive

I need the system to boot in permissive mode or have SELinux completely disabled at boot time.

Thanks

like image 215
Giuseppe Avatar asked Mar 24 '15 21:03

Giuseppe


People also ask

How do I disable SELinux on Android?

Change the SELINUX value to SELINUX=disabled in the file /etc/selinux/config. Reboot the server. Reboot the server.

What happens if I disable SELinux?

The main difference between "Permissive" mode and disabling SELinux is that you will not get AVC log messages anymore and that SELinux will not keep files label up-to-date so you will need to relabel your files before enabling it again.

Is it safe to disable SELinux?

Disabling SELinux is not a recommended course of action as it is not actually addressing security issues directly. Disabling SELinux is often done as an easy solution instead of correctly working with SELinux contexts.


Video Answer


1 Answers

There are two ways that enforcing mode is set. On user builds, it will always be in enforcing. On eng or userdebug, you can control it. You can control it in the standard selinux way, by setting enforcing=1/0 on the kernel command line as outlined in Dan Walsh's blog:

http://danwalsh.livejournal.com/10972.html

The Android centric way is to set the kernel command line to androidboot.selinux=permissive

You can control the kernel command line by editing your BoardConfig.mk and adding this:

BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive

The Android centric way is enforced by init, if you look in system/core/init/init.cpp look at the selinux_initialize() routine that is called from main().

like image 143
William Roberts Avatar answered Sep 28 '22 18:09

William Roberts