Magisk/native/jni/core
topjohnwu a1b5185ecb Make sure rootfs file selabels are correct
Android Q init assumes rootfs to always be on EXT4 images, thus
never runs restorecon on the whole root directory. This is an issue
because some folders in rootfs were set with special selabels in
the system partition, but when copying over to initramfs by magiskinit,
these labels will not be preserved.

So the solution is to relabel the files in rootfs with the original
context right? Yes, but rootfs does not allow security xattr to be set
on files before the kernel SELinux initializes with genfs_contexts.
We have to load our sepolicy to the kernel before we clone the root
directory from system partition, which we will also restore the selabel
in the meantime.

Unfortunately this means that for each reboot, the exact same policy
will be loaded to the kernel twice: once in magiskinit so we can label
rootfs properly, and once by the original init, which is part of the
boot procedure. There is no easy way to prevent init from loading
sepolicy, as init will refuse to continue if policy loading has failed.
2019-03-14 22:27:29 -04:00
..
applets.cpp Remove Zygote notifier 2019-03-08 03:35:17 -05:00
bootstages.cpp Remove Zygote notifier 2019-03-08 03:35:17 -05:00
daemon.cpp Remove Zygote notifier 2019-03-08 03:35:17 -05:00
db.cpp Use our own function to parse int 2019-03-07 20:31:35 -05:00
init.cpp Make sure rootfs file selabels are correct 2019-03-14 22:27:29 -04:00
magisk.cpp Remove Zygote notifier 2019-03-08 03:35:17 -05:00
magiskrc.h Add newlines before rc scripts 2019-02-18 03:30:30 -05:00
scripting.cpp Remove unused scripts 2019-02-18 03:08:40 -05:00
socket.cpp Separate scripting code 2019-02-15 20:45:05 -05:00