From e261579e72a5d0939a0872e8628881ea879ac1d8 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 11 Mar 2020 00:11:15 -0700 Subject: [PATCH] Use standalone mode in boot scripts --- native/jni/core/scripting.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/native/jni/core/scripting.cpp b/native/jni/core/scripting.cpp index 37fd23898..78413c727 100644 --- a/native/jni/core/scripting.cpp +++ b/native/jni/core/scripting.cpp @@ -10,18 +10,13 @@ using namespace std; -static void set_path() { - char buf[4096]; - sprintf(buf, BBPATH ":%s", getenv("PATH")); - setenv("PATH", buf, 1); -} +#define BBEXEC_CMD DATABIN "/busybox", "sh", "-o", "standalone" void exec_script(const char *script) { exec_t exec { - .pre_exec = set_path, .fork = fork_no_zombie }; - exec_command_sync(exec, "/system/bin/sh", script); + exec_command_sync(exec, BBEXEC_CMD, script); } void exec_common_script(const char *stage) { @@ -42,13 +37,12 @@ void exec_common_script(const char *stage) { LOGI("%s.d: exec [%s]\n", stage, entry->d_name); strcpy(name, entry->d_name); exec_t exec { - .pre_exec = set_path, .fork = pfs ? fork_no_zombie : fork_dont_care }; if (pfs) - exec_command_sync(exec, "/system/bin/sh", path); + exec_command_sync(exec, BBEXEC_CMD, path); else - exec_command(exec, "/system/bin/sh", path); + exec_command(exec, BBEXEC_CMD, path); } } } @@ -63,13 +57,12 @@ void exec_module_script(const char *stage, const vector &module_list) { continue; LOGI("%s: exec [%s.sh]\n", module, stage); exec_t exec { - .pre_exec = set_path, .fork = pfs ? fork_no_zombie : fork_dont_care }; if (pfs) - exec_command_sync(exec, "/system/bin/sh", path); + exec_command_sync(exec, BBEXEC_CMD, path); else - exec_command(exec, "/system/bin/sh", path); + exec_command(exec, BBEXEC_CMD, path); } } @@ -83,10 +76,9 @@ rm -f $APK void install_apk(const char *apk) { setfilecon(apk, "u:object_r:" SEPOL_FILE_DOMAIN ":s0"); exec_t exec { - .pre_exec = set_path, .fork = fork_no_zombie }; char cmds[sizeof(install_script) + 4096]; sprintf(cmds, install_script, apk); - exec_command_sync(exec, "/system/bin/sh", "-c", cmds); + exec_command_sync(exec, BBEXEC_CMD, "-c", cmds); }