Delay full sepolicy patch loading time

This commit is contained in:
topjohnwu 2018-08-02 05:35:01 +08:00
parent 35f1c396f2
commit d9564bd04c
2 changed files with 9 additions and 3 deletions

View File

@ -678,7 +678,8 @@ void post_fs_data(int client) {
LOGI("** post-fs-data mode running\n");
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
full_patch_pid = exec_command(0, NULL, NULL, "/sbin/magiskpolicy", "--live", "allow "SEPOL_PROC_DOMAIN" * * *", NULL);
full_patch_pid = exec_command(0, NULL, NULL,
"/sbin/magiskpolicy", "--save", TMPSEPOLICY, "allow "SEPOL_PROC_DOMAIN" * * *", NULL);
// Allocate buffer
buf = xmalloc(PATH_MAX);
@ -803,9 +804,13 @@ void late_start(int client) {
if (buf == NULL) buf = xmalloc(PATH_MAX);
if (buf2 == NULL) buf2 = xmalloc(PATH_MAX);
if (full_patch_pid > 0) {
// Wait till the full patch is done
if (full_patch_pid > 0)
waitpid(full_patch_pid, NULL, 0);
// Load the policy
exec_command_sync("/sbin/magiskpolicy", "--live", "--load", TMPSEPOLICY, NULL);
unlink(TMPSEPOLICY);
}
// Run scripts after full patch, most reliable way to run scripts
LOGI("* Running service.d scripts\n");

View File

@ -17,6 +17,7 @@
#define LOGFILE "/cache/magisk.log"
#define UNBLOCKFILE "/dev/.magisk.unblock"
#define TMPSEPOLICY "/dev/.tmp_sepolicy"
#define DISABLEFILE "/cache/.disable_magisk"
#define MAGISKTMP "/sbin/.core"
#define BLOCKDIR MAGISKTMP "/block"