How to Fix Viper4Android SELinux Policy Issues on Lollipop

Viper4Android has had trouble with SELinux enforcing mode introduced on Lollipop, and so far we’ve been trying to run it under the permissive mode by changing the SELinux policy, but thanks to maximumentropy over at XDA, you can now use Viper4Android without changing SELinux from enforcing to permissive.

The fix involves pushing a few ADB commands to the device on which you want to run Viper4Android and also make sure you’ve SuperSU as your superuser management app for it to work. Check out the original post by the user below:

This requires that you are using SuperSU on your system, as it provides both the su.d startup directory support and the supolicy binary. Execute these commands in a terminal on your Android device to create the startup script. It should execute at boot time, starting with your next reboot.

If case you’re scared of ADB commands, then thankfully we also have a recovery flashable zip for the same.

[ADB method] How to apply Viper4Android SELinux fix

  1. Setup ADB and Fastboot on your PC.
  2. Enable USB debugging on your device from developer options and connect it to the PC with a USB cable.
  3. Open a command prompt window on the PC and issue the following commands:
    su
    mount -o rw,remount /system
    cd /system/su.d
    echo '#! /system/bin/sh' > 50viper.sh
    echo '/system/xbin/supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"' >> 50viper.sh
    chown root.root 50viper.sh
    chmod 755 50viper.sh
    cd /
    mount -o ro,remount /system
    exit
  4. Reboot your device.

[Recovery Flashable zip] Viper4Android SELinux fix

For folks who prefer to stay away from ADB or just don’t have access to PC. Here’s recovery flashable zip file to apply the fix.

[icon name=”download” class=”” unprefixed_class=””] Download Viper4Android SELinux Policy fix

To install, just boot into a custom recovery (TWRP, preferably), flash the zip file and reboot. Nothing else.

via XDA

Posted by
Shivam Malani

Shivam is our resident designer and web developer who also enjoys writing. He loves to meditate, drive on the freeways and hunt for snipers during his Call Of Duty playtime. Email: [email protected]

54 Comments

  1. […] Viper4Android for a number of devices. However, only recently we posted of a working method to get Viper4Android working on Lollipop with enforcing mode, and it seems the method also works on Galaxy S6 […]

  2. Works on S4!!

  3. Works on S4!!

  4. All I ever wanted to run on my droid was Viper4android. Been rooted for a while struggling with SE enforcing mode. Thanks so much for this fix!

    I have a verizon galaxy s4.

  5. All I ever wanted to run on my droid was Viper4android. Been rooted for a while struggling with SE enforcing mode. Thanks so much for this fix!

    I have a verizon galaxy s4.

  6. Hi and thanks for this quick guide.
    I have a couple of questions though:
    – what happens if one day a new viper4android version ships without the selinux problem and I install it? Will it conflict with this change?
    – would at that point be enough to just delete the 50viper.sh bash script ?
    – is there something like an automated way to keep track of all small changes like this one and revert them at anytime?
    Thanks!

  7. Hi and thanks for this quick guide.
    I have a couple of questions though:
    – what happens if one day a new viper4android version ships without the selinux problem and I install it? Will it conflict with this change?
    – would at that point be enough to just delete the 50viper.sh bash script ?
    – is there something like an automated way to keep track of all small changes like this one and revert them at anytime?
    Thanks!

  8. […] It has only been a couple of days since Marshmallow released for Nexus 5, but some of you may already be missing the sound boost from Viper4Android on Lollipop. […]

  9. […] mother of all the sound MODs available for Android devices. However, getting it installed can be tricky on Lollipop and Marshmallow running devices, and even more tricky on the Nexus 6P and 5X […]

  10. thx work on S5 g900h lollipop

  11. thx work on S5 g900h lollipop

  12. […] TWRP and root as per jcadduono’s thread then visit this link, have a read then downloading the file from the Dropbox link provided. Install the latest […]

  13. Tq… Worked on S5 g900f lollipop 5.0

  14. Tq… Worked on S5 g900f lollipop 5.0

  15. I don’t have /system/su.d. I check SuperSu and it says I am running SuperSu in systemless root mode. It isn’t possible to do a system install in through SuperSu. How do I get around this?

    1. I had the same problem. I’m not familiar with SuperSU but I guess the ‘systemless’ part involves to not modify the /system partition. I found that the su configuration folder and the supolicy executable are both located in /su on my phone (a Honor 5C running Android 6.0). I could make it work by adapting the original commands:

      su
      mount -o rw,remount /su
      cd /su/su.d
      echo ‘#! /system/bin/sh’ > 50viper.sh
      echo ‘/su/bin/supolicy –live “allow mediaserver mediaserver_tmpfs:file { read write execute };”‘ >> 50viper.sh
      chown root.root 50viper.sh
      chmod 755 50viper.sh
      cd /
      mount -o ro,remount /su
      exit

      BTW for the OP: since the commands are invoked as root I’m pretty sure the chown command isn’t necessary. And thanks a lot for this workaround!

  16. I don’t have /system/su.d. I check SuperSu and it says I am running SuperSu in systemless root mode. It isn’t possible to do a system install in through SuperSu. How do I get around this?

    1. I had the same problem. I’m not familiar with SuperSU but I guess the ‘systemless’ part involves to not modify the /system partition. I found that the su configuration folder and the supolicy executable are both located in /su on my phone (a Honor 5C running Android 6.0). I could make it work by adapting the original commands:

      su
      mount -o rw,remount /su
      cd /su/su.d
      echo ‘#! /system/bin/sh’ > 50viper.sh
      echo ‘/su/bin/supolicy –live “allow mediaserver mediaserver_tmpfs:file { read write execute };”‘ >> 50viper.sh
      chown root.root 50viper.sh
      chmod 755 50viper.sh
      cd /
      mount -o ro,remount /su
      exit

      BTW for the OP: since the commands are invoked as root I’m pretty sure the chown command isn’t necessary. And thanks a lot for this workaround!

  17. Works using TWRP 3.0.2.0 on my Sprint Galaxy Note 4 running stock rooted Android 6.0.1 (N910PVPS4DPD1) and now the Driver Status finally shows NORMAL instead of Abnormal!

  18. Works using TWRP 3.0.2.0 on my Sprint Galaxy Note 4 running stock rooted Android 6.0.1 (N910PVPS4DPD1) and now the Driver Status finally shows NORMAL instead of Abnormal!

  19. Works on HTC 10 also! I used audio_effect.conf from Samsung. Rename the original file from Htc: htc_audio_effect.conf to htc_audio_effect.bak in case you want to go back. Rename the Samsung file to htc_audio_effect.conf Reboot the device and have fun!

  20. Works on HTC 10 also! I used audio_effect.conf from Samsung. Rename the original file from Htc: htc_audio_effect.conf to htc_audio_effect.bak in case you want to go back. Rename the Samsung file to htc_audio_effect.conf Reboot the device and have fun!

  21. I installed viper4android selinux policy fix.zip on galaxy s4 i9505 lollipop 5.0.1. But selinux mode did not change to permissive.selinux mode still to enforcing mode.
    Please help me to fix this issue

  22. I installed viper4android selinux policy fix.zip on galaxy s4 i9505 lollipop 5.0.1. But selinux mode did not change to permissive.selinux mode still to enforcing mode.
    Please help me to fix this issue

  23. Can i use this zip for miui 7.5 running on marshmallow … my device is xiaomi mi3…thanks in advance

    1. It might not work. Why not use the ADB method, instead.

  24. Can i use this zip for miui 7.5 running on marshmallow … my device is xiaomi mi3…thanks in advance

    1. It might not work. Why not use the ADB method, instead.

  25. Can i use this zip for miui 7.5 running on marshmallow … my device is xiaomi mi3…thanks in advance

  26. Can i use this zip for miui 7.5 running on marshmallow … my device is xiaomi mi3…thanks in advance

  27. Works on Samsung Note 4 N910C rooted stock rom Marshmallow 6.0.1 with Busybox installed. MUST flash viper4android selinux policy fix.zip with TWRP recovery version 3.0.2.0, flash with CWM recovery WILL NOT work

  28. Works on Samsung Note 4 N910C rooted stock rom Marshmallow 6.0.1 with Busybox installed. MUST flash viper4android selinux policy fix.zip with TWRP recovery version 3.0.2.0, flash with CWM recovery WILL NOT work

  29. Works on Samsung Note 4 N910C rooted stock rom Marshmallow 6.0.1 with Busybox installed. MUST flash viper4android selinux policy fix.zip with TWRP recovery version 3.0.2.0, flash with CWM recovery WILL NOT work

  30. Works on Samsung Note 4 N910C rooted stock rom Marshmallow 6.0.1 with Busybox installed. MUST flash viper4android selinux policy fix.zip with TWRP recovery version 3.0.2.0, flash with CWM recovery WILL NOT work

  31. […] soon came a workaround to use ViPER4Android on Lollipop while still running SELinux in enforcing mode (to ensure device security). The trick worked on […]

  32. […] soon came a workaround to use ViPER4Android on Lollipop while still running SELinux in enforcing mode (to ensure device security). The trick worked on […]

  33. I tried the adb method on a Samsung Galaxy S4 active and it only works sometimes. How do I reverse it?

  34. I tried the adb method on a Samsung Galaxy S4 active and it only works sometimes. How do I reverse it?

  35. I tried the adb method on a Samsung Galaxy S4 active and it only works sometimes. How do I reverse it?

  36. I tried the adb method on a Samsung Galaxy S4 active and it only works sometimes. How do I reverse it?

  37. Samsung a5 2016 6.0.1 failed “custom binary blocked by frp”

  38. Samsung a5 2016 6.0.1 failed “custom binary blocked by frp”

  39. Samsung a5 2016 6.0.1 failed “custom binary blocked by frp”

  40. Samsung a5 2016 6.0.1 failed “custom binary blocked by frp”

  41. The su command was not working on my windows pc.
    so i tried several things.

    Then this is what i did.
    Opened terminal from the adb folder.
    then typed adb devices to see if my device is connected the right way.
    after this i typed adb shell to make the connection.
    and after these steps i can use the commands as told in the discription above.

    I am using cm13 snapshot

  42. The su command was not working on my windows pc.
    so i tried several things.

    Then this is what i did.
    Opened terminal from the adb folder.
    then typed adb devices to see if my device is connected the right way.
    after this i typed adb shell to make the connection.
    and after these steps i can use the commands as told in the discription above.

    I am using cm13 snapshot

  43. The su command was not working on my windows pc.
    so i tried several things.

    Then this is what i did.
    Opened terminal from the adb folder.
    then typed adb devices to see if my device is connected the right way.
    after this i typed adb shell to make the connection.
    and after these steps i can use the commands as told in the discription above.

    I am using cm13 snapshot

  44. The su command was not working on my windows pc.
    so i tried several things.

    Then this is what i did.
    Opened terminal from the adb folder.
    then typed adb devices to see if my device is connected the right way.
    after this i typed adb shell to make the connection.
    and after these steps i can use the commands as told in the discription above.

    I am using cm13 snapshot

  45. Correction!! It does not work!!

  46. Correction!! It does not work!!

  47. Correction!! It does not work!!

  48. Correction!! It does not work!!

Leave a Reply

Your email address will not be published. Required fields are marked *