Don't always mock selinux enforce as "0"

This commit is contained in:
LoveSy 2022-03-19 13:49:32 +08:00 committed by John Wu
parent 92f0e53fee
commit 2fb49ad780

View File

@ -70,7 +70,6 @@ void MagiskInit::hijack_sepolicy() {
} else {
// We block using the "enforce" node
blocking_target = SELINUX_ENFORCE;
actual_content = "0";
}
// Hijack the "load" and "enforce" node in selinuxfs to manipulate
@ -169,6 +168,10 @@ void MagiskInit::hijack_sepolicy() {
xmount("selinuxfs", REAL_SELINUXFS, "selinuxfs", 0, nullptr);
sepol->to_file(REAL_SELINUXFS "/load");
if (strcmp(blocking_target, SELINUX_ENFORCE) == 0) {
actual_content = full_read(SELINUX_ENFORCE);
}
// Write to mock blocking target ONLY after sepolicy is loaded. We need to make sure
// the actual init process is blocked until sepolicy is loaded, or else
// restorecon will fail and re-exec won't change context, causing boot failure.