SAR can also have monolithic sepolicy

This commit is contained in:
topjohnwu 2022-03-17 22:32:49 -07:00
parent f008420891
commit 32cd694ad5
2 changed files with 8 additions and 5 deletions

View File

@ -61,9 +61,6 @@ protected:
// When this boolean is set, this means we are currently
// running magiskinit on legacy SAR AVD emulator
bool avd_hack = false;
#else
// Make it constexpr so compiler can optimize hacks out of the code
static constexpr bool avd_hack = false;
#endif
void patch_sepolicy(const char *file);

View File

@ -181,6 +181,7 @@ void SARBase::patch_ro_root() {
xmkdir(ROOTOVL, 0);
#if ENABLE_AVD_HACK
// Handle avd hack
if (avd_hack) {
int src = xopen("/init", O_RDONLY | O_CLOEXEC);
@ -193,6 +194,7 @@ void SARBase::patch_ro_root() {
close(src);
close(dest);
}
#endif
// Handle overlay.d
restore_folder(ROOTOVL, overlays);
@ -233,14 +235,18 @@ void SARBase::patch_ro_root() {
}
}
if (access("/sepolicy", F_OK) == 0) {
patch_sepolicy(ROOTOVL "/sepolicy");
} else {
hijack_sepolicy();
}
// Mount rootdir
magic_mount(ROOTOVL);
int dest = xopen(ROOTMNT, O_WRONLY | O_CREAT, 0);
write(dest, magic_mount_list.data(), magic_mount_list.length());
close(dest);
hijack_sepolicy();
chdir("/");
}