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

727 posts
Thanks Meter: 2,039
 
By mobiusm, Senior Member on 5th March 2016, 05:57 PM
Post Reply Email Thread
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:

Quote:

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.
The Following 27 Users Say Thank You to mobiusm For This Useful Post: [ View ] Gift mobiusm Ad-Free
6th March 2016, 05:40 PM |#2  
AntonPanos's Avatar
Senior Member
Flag Herakleio
Thanks Meter: 106
 
More
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..
Attached Files
File Type: zip SELinux-Perm.zip - [Click for QR Code] (904.2 KB, 6620 views)
The Following 11 Users Say Thank You to AntonPanos For This Useful Post: [ View ] Gift AntonPanos Ad-Free
14th March 2016, 03:26 PM |#3  
Member
Thanks Meter: 4
 
More
I installed ViPER4Android with SELinux set on Enforcing...
14th March 2016, 05:00 PM |#4  
mobiusm's Avatar
OP Senior Member
Flag Jerusalem
Thanks Meter: 2,039
 
Donate to Me
More
Quote:
Originally Posted by Enigma.

I installed ViPER4Android with SELinux set on Enforcing...

Installing is easy, but does it work for you? And are you sure you are on an Enforcing system?
The Following User Says Thank You to mobiusm For This Useful Post: [ View ] Gift mobiusm Ad-Free
15th March 2016, 06:49 AM |#5  
Member
Thanks Meter: 4
 
More
Quote:
Originally Posted by mobiusm

Installing is easy, but does it work for you? And are you sure you are on an Enforcing system?

Absolutely, and I'm sure I'm on an Enforcing. I just want to ask if there is any particular reason I should set selinux on permissive, maybe some app like viper or something...?
17th March 2016, 09:30 PM |#6  
mobiusm's Avatar
OP Senior Member
Flag Jerusalem
Thanks Meter: 2,039
 
Donate to Me
More
Quote:
Originally Posted by Enigma.

Absolutely, and I'm sure I'm on an Enforcing. I just want to ask if there is any particular reason I should set selinux on permissive, maybe some app like viper or something...?

You told me you already installed viper
The Following User Says Thank You to mobiusm For This Useful Post: [ View ] Gift mobiusm Ad-Free
18th March 2016, 09:49 AM |#7  
Member
Thanks Meter: 4
 
More
Quote:
Originally Posted by mobiusm

You told me you already installed viper

I did, but I'm just interested in what else I can do with permissive mode... But nvm, thanks for help anyway
19th May 2016, 05:17 AM |#8  
Junior Member
Thanks Meter: 1
 
More
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
19th May 2016, 07:15 AM |#9  
mobiusm's Avatar
OP Senior Member
Flag Jerusalem
Thanks Meter: 2,039
 
Donate to Me
More
Quote:
Originally Posted by Paentherax

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...
The Following User Says Thank You to mobiusm For This Useful Post: [ View ] Gift mobiusm Ad-Free
4th June 2016, 08:17 AM |#10  
Senior Member
Thanks Meter: 32
 
More
i have a CM13 based custom Rom but my Selinux is disabled by default ... please tell me how i can enable it ???

Sent from my Lenovo a6000 using XDA-Developers mobile app
4th June 2016, 12:44 PM |#11  
Vagelis1608's Avatar
Senior Member
Flag Athens
Thanks Meter: 844
 
More
Quote:
Originally Posted by zishukkc

i have a CM13 based custom Rom but my Selinux is disabled by default ... please tell me how i can enable it ???

Is it "Permissive" or "Disabled"?
There is a huge difference.

Sent from my LG G2 Mini using XDA Labs
Post Reply Subscribe to Thread

Tags
enforcing, permissive, policy, root, selinux

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes