[GUIDE][SELinux][CM13] How to Set and Keep SELinux on Permissive

Search This thread

mobiusm

Senior Member
Nov 19, 2014
727
2,037
Jerusalem
OnePlus 8 Pro
DISCLAIMER:

I am not responsible to anything going wrong with your device.
You are responsible to what you are doing with your phone, not me.
If you blame me, I will laugh in your face and I'll go grab a beer.



SELinux is set to Enforcing by default on CM 13. Using an app to change the policy one is able to change it to Permissive, but on reboot, it is changed back to Enforcing. Permissive SELinux policy is need if one wants to install ViPER4Android for example.


With a few simple steps, we are able to change it so on boot the policy will be set to Permissive:

Step 1:

SuperSU needs to be installed in order for this to work. This means replacing the stock root that comes with CM 13.

1. Download and the latest systemless SuperSU from HERE.
2. Flash the ZIP file from your recovery and reboot to system. Booting might take a while.
3. Remember to disable the built in root in developers options.

Step 2:

Use a terminal emulator or ADB to type these commands:

su
mount -o remount,rw /system
mkdir /system/su.d
echo "#!/system/bin/sh" > /system/su.d/permissive.sh
echo "setenforce 0" > /system/su.d/permissive.sh
echo "0" > /sys/fs/selinux/enforce
chmod 755 /system/su.d/permissive.sh

NOTE: each line needs to be entered separately by pressing enter after each line.

Step 3:

REBOOT


Now that you have completed the above steps, the SELinux policy should be set to Permissive and stay like that after any reboots.



Thank you @Chainfire for the amazing SuperSU app.
 
Last edited:

Paentherax

Member
May 1, 2016
7
1
Whenever I type this into my terminal after I type the last line (I did it correctly) its pop up with a bunch of text telling me how to use chmod755 and that I can't change something I don't own and I have to change the permissions of something? What do I do? I'm on LG G2 ls980 on CM13 and I can't flash superSU because apparently I have SU setting in my developer mode options so I can only use that or if I flash a supersu latest version my device soft bricks and I have to restore from a backup or completely restore the phone using windows software? Thanks please help
 

mobiusm

Senior Member
Nov 19, 2014
727
2,037
Jerusalem
OnePlus 8 Pro
Whenever I type this into my terminal after I type the last line (I did it correctly) its pop up with a bunch of text telling me how to use chmod755 and that I can't change something I don't own and I have to change the permissions of something? What do I do? I'm on LG G2 ls980 on CM13 and I can't flash superSU because apparently I have SU setting in my developer mode options so I can only use that or if I flash a supersu latest version my device soft bricks and I have to restore from a backup or completely restore the phone using windows software? Thanks please help

Well as I'm sure you've read, you need to flash SuperSU to use this method.. but a quick search on Google should yield other methods of changing SELinux to Permissive...
 
  • Like
Reactions: Paentherax

chrcol

Senior Member
Jan 17, 2012
1,064
165
UK
I modified the IRRC file a bit and i made this flashable zip that changes SELinux to permissive... You can try it, or someone with more skills or Nikita itself can check this if it's something wrong with that!
On my phone worked perfect though.. :) :good:

I think you should warn people this is a kernel, I just installed this thinking it was only a script to disable selinux not to overwrite my kernel.
 
  • Like
Reactions: The Analog Kid

Perpatoura

Senior Member
Dec 2, 2013
58
9
Weird. It's Enforcing SELinux that breaks Viper4Android, not Permissive.
Are you sure that SELinux broke it?

Sent from my LG G2 Mini using XDA Labs

Viper wasn't working before, so SELinux didn't broke anything. But it won't work neither, that's why I'm asking how to undo this, no reason to have permissive then.
 

joseph.hsu

Senior Member
Oct 9, 2009
120
31
Thank you AntonPanos~
i'm flash your permissive zip!it's working on viper 2.4.0.1
my phone is Note Edge 5.1.1 on Stock Rom!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 27
    DISCLAIMER:

    I am not responsible to anything going wrong with your device.
    You are responsible to what you are doing with your phone, not me.
    If you blame me, I will laugh in your face and I'll go grab a beer.



    SELinux is set to Enforcing by default on CM 13. Using an app to change the policy one is able to change it to Permissive, but on reboot, it is changed back to Enforcing. Permissive SELinux policy is need if one wants to install ViPER4Android for example.


    With a few simple steps, we are able to change it so on boot the policy will be set to Permissive:

    Step 1:

    SuperSU needs to be installed in order for this to work. This means replacing the stock root that comes with CM 13.

    1. Download and the latest systemless SuperSU from HERE.
    2. Flash the ZIP file from your recovery and reboot to system. Booting might take a while.
    3. Remember to disable the built in root in developers options.

    Step 2:

    Use a terminal emulator or ADB to type these commands:

    su
    mount -o remount,rw /system
    mkdir /system/su.d
    echo "#!/system/bin/sh" > /system/su.d/permissive.sh
    echo "setenforce 0" > /system/su.d/permissive.sh
    echo "0" > /sys/fs/selinux/enforce
    chmod 755 /system/su.d/permissive.sh

    NOTE: each line needs to be entered separately by pressing enter after each line.

    Step 3:

    REBOOT


    Now that you have completed the above steps, the SELinux policy should be set to Permissive and stay like that after any reboots.



    Thank you @Chainfire for the amazing SuperSU app.
    11
    I modified the IRRC file a bit and i made this flashable zip that changes SELinux to permissive... You can try it, or someone with more skills or Nikita itself can check this if it's something wrong with that!
    On my phone worked perfect though.. :) :good:
    4
    If someone already posted this, excuse me. There is an app you can get on Fdroid called SELinuxModeChanger that will allow you to set Permissive and toggle back again by tapping Enforcing. Nice app, works very well. :good:
    The SELinuxModeChanger hasn't been updated or supported for a few years now.

    There's an app that is a Reboot of the SELinuxModeChanger called the SELinuxToggler.

    The link to it is located here:

    [APP][TOOL][4.2+]SELinuxToggler

    Just a recommendation...


    Sent on my Communicator [SCH-I535] from the Bridge of the U.S.S. Enterprise...
    3
    I tried everything not working.
    Does it work with Nougat 7.1.1?
    OnePlus 3T Resurrection Remix

    On Resurrection Remix you have an option to toggle selinux.
    Settings>Configurations>miscellaneous>selinux mode
    2
    I think you should warn people this is a kernel, I just installed this thinking it was only a script to disable selinux not to overwrite my kernel.
    It doesn't overwrite the whole kernel, only cmdline ;)

    Sent from my LG G2 Mini using XDA Labs