AdAway doesn't work because of SELinux


Dec 1, 2017
10
0
13
#1
Hi all,
I have mix 3 with the last eu rom weekly 9.3.7 and Magisk 18.1. I wish to install AdAway to get advertising stucked but it has to modify /system/etc/hosts file. System partition is write only and I think this is due to SELinux set to enforced. I tried the Magisk module SELinuxModeInverter4Magisk but I got no success. Is there any way to permanently set SELinux to permissive and get AdAway working? It would be useful to have a flashable zip via TWRP.
Thanks in advance for your help.
Best regards
 
Sep 23, 2017
13
0
13
#3
In TWRP screen now:
1. Select MOUNT and check the System partition. Go back.
2. Select ADVANCED>TERMINAL
You have a # prompt. If not, type SU.
3. Type the following two lines in that terminal:

Code:
mv /system/etc/hosts /system/etc/hosts.bak

This renames the existing hosts file to hosts.bak . Not really needed... but better safer than sorry.


Code:
ln -s /data/hosts /system/etc/hosts
This creates a symbolic link to a location that AdAway can write.
Reboot and enjoy.


THx to Sonic67 XDA
 
Dec 1, 2017
10
0
13
#4
In TWRP screen now:
1. Select MOUNT and check the System partition. Go back.
2. Select ADVANCED>TERMINAL
You have a # prompt. If not, type SU.
3. Type the following two lines in that terminal:

Code:
mv /system/etc/hosts /system/etc/hosts.bak

This renames the existing hosts file to hosts.bak . Not really needed... but better safer than sorry.


Code:
ln -s /data/hosts /system/etc/hosts
This creates a symbolic link to a location that AdAway can write.
Reboot and enjoy.


THx to Sonic67 XDA
Thank you for your reply.
I followed your instructions but when I enter the command

# mv /system/etc/hosts /system/etc/hosts.bak

I get the following error

WARNING: linker: Warning: couldn't read "/system/etc/ld.config.txt" for "/sbin/toybox" (using default configuration instead): error reading file "/system/etc/ld.config.txt": too many symbolic links encountered
mv: bad '/system/etc/hosts': Too many symbolic links encountered

Even if I symply enter the command

# cd /system/etc

I got the same error

sh: cd: /system/etc: Too many symbolic links encountered

I tried to flash the ROM again but nothing changed. What's the matter in your opinion?

Have a nice day