Use env variables to enable standalone mode

This commit is contained in:
topjohnwu 2020-05-08 04:09:58 -07:00
parent 912009494d
commit a62bdc58cb

View File

@ -10,10 +10,15 @@
using namespace std; using namespace std;
#define BBEXEC_CMD DATABIN "/busybox", "sh", "-o", "standalone" #define BBEXEC_CMD DATABIN "/busybox", "sh"
static void set_standalone() {
setenv("ASH_STANDALONE", "1", 1);
};
void exec_script(const char *script) { void exec_script(const char *script) {
exec_t exec { exec_t exec {
.pre_exec = set_standalone,
.fork = fork_no_zombie .fork = fork_no_zombie
}; };
exec_command_sync(exec, BBEXEC_CMD, script); exec_command_sync(exec, BBEXEC_CMD, script);
@ -37,6 +42,7 @@ void exec_common_script(const char *stage) {
LOGI("%s.d: exec [%s]\n", stage, entry->d_name); LOGI("%s.d: exec [%s]\n", stage, entry->d_name);
strcpy(name, entry->d_name); strcpy(name, entry->d_name);
exec_t exec { exec_t exec {
.pre_exec = set_standalone,
.fork = pfs ? fork_no_zombie : fork_dont_care .fork = pfs ? fork_no_zombie : fork_dont_care
}; };
if (pfs) if (pfs)
@ -57,6 +63,7 @@ void exec_module_script(const char *stage, const vector<string> &module_list) {
continue; continue;
LOGI("%s: exec [%s.sh]\n", module, stage); LOGI("%s: exec [%s.sh]\n", module, stage);
exec_t exec { exec_t exec {
.pre_exec = set_standalone,
.fork = pfs ? fork_no_zombie : fork_dont_care .fork = pfs ? fork_no_zombie : fork_dont_care
}; };
if (pfs) if (pfs)
@ -76,6 +83,7 @@ rm -f $APK
void install_apk(const char *apk) { void install_apk(const char *apk) {
setfilecon(apk, "u:object_r:" SEPOL_FILE_DOMAIN ":s0"); setfilecon(apk, "u:object_r:" SEPOL_FILE_DOMAIN ":s0");
exec_t exec { exec_t exec {
.pre_exec = set_standalone,
.fork = fork_no_zombie .fork = fork_no_zombie
}; };
char cmds[sizeof(install_script) + 4096]; char cmds[sizeof(install_script) + 4096];