From f79fad64aab4034c863e4f15a180f5f139de2ead Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 31 Jul 2017 23:31:40 +0800 Subject: [PATCH] Fix several script issues --- jni/daemon/bootstages.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/jni/daemon/bootstages.c b/jni/daemon/bootstages.c index 1886ab4ec..9de282d42 100644 --- a/jni/daemon/bootstages.c +++ b/jni/daemon/bootstages.c @@ -161,7 +161,8 @@ void exec_module_script(const char* stage) { char *module; vec_for_each(&module_list, module) { snprintf(buf, PATH_MAX, "%s/%s/%s.sh", MOUNTPOINT, module, stage); - if (access(buf, F_OK) == -1) + snprintf(buf2, PATH_MAX, "%s/%s/disable", MOUNTPOINT, module); + if (access(buf, F_OK) == -1 || access(buf2, F_OK) == 0) continue; LOGI("%s: exec [%s.sh]\n", module, stage); char *const command[] = { "sh", buf, NULL }; @@ -551,10 +552,6 @@ void post_fs_data(int client) { xmkdir(COREDIR "/props", 0755); } - // Run common scripts - LOGI("* Running post-fs-data.d scripts\n"); - exec_common_script("post-fs-data"); - // Core only mode if (access(DISABLEFILE, F_OK) == 0) goto core_only; @@ -702,6 +699,10 @@ void post_fs_data(int client) { exec_module_script("post-fs-data"); core_only: + // Run common scripts + LOGI("* Running post-fs-data.d scripts\n"); + exec_common_script("post-fs-data"); + // Systemless hosts if (access(HOSTSFILE, F_OK) == 0) { LOGI("* Enabling systemless hosts file support"); @@ -734,19 +735,18 @@ void late_start(int client) { // Wait till the full patch is done pthread_join(sepol_patch, NULL); - // Run scripts after full patch, most reliable way to run scripts - LOGI("* Running service.d scripts\n"); - exec_common_script("service"); - // Core only mode - if (access(DISABLEFILE, F_OK) == 0) { - setprop("ro.magisk.disable", "1"); - return; - } + if (access(DISABLEFILE, F_OK) == 0) + goto core_only; LOGI("* Running module service scripts\n"); exec_module_script("service"); +core_only: + // Run scripts after full patch, most reliable way to run scripts + LOGI("* Running service.d scripts\n"); + exec_common_script("service"); + // Install Magisk Manager if exists if (access(MANAGERAPK, F_OK) == 0) { while (1) {