Don't expose module_list

This commit is contained in:
topjohnwu 2020-05-18 05:36:02 -07:00
parent c3e045e367
commit 4497e0aaca
4 changed files with 21 additions and 25 deletions

View File

@ -268,8 +268,7 @@ void post_fs_data(int client) {
foreach_modules("disable");
stop_magiskhide();
} else {
LOGI("* Running post-fs-data.d scripts\n");
exec_common_script("post-fs-data");
exec_common_scripts("post-fs-data");
auto_start_magiskhide();
handle_modules();
}
@ -299,15 +298,8 @@ void late_start(int client) {
if (!pfs_done || safe_mode)
return;
LOGI("* Running service.d scripts\n");
exec_common_script("service");
LOGI("* Running module service scripts\n");
exec_module_script("service", module_list);
// All boot stage done, cleanup
module_list.clear();
module_list.shrink_to_fit();
exec_common_scripts("service");
exec_module_scripts("service");
}
void boot_complete(int client) {

View File

@ -25,7 +25,7 @@ using namespace std;
#define TYPE_CUSTOM (1 << 5) /* custom node type overrides all */
#define TYPE_DIR (TYPE_INTER|TYPE_SKEL|TYPE_ROOT)
vector<string> module_list;
static vector<string> module_list;
class node_entry;
class dir_node;
@ -671,10 +671,7 @@ static void collect_modules() {
void handle_modules() {
prepare_modules();
collect_modules();
// Execute module scripts
LOGI("* Running module post-fs-data scripts\n");
exec_module_script("post-fs-data", module_list);
exec_module_scripts("post-fs-data");
// Recollect modules (module scripts could remove itself)
module_list.clear();
@ -699,3 +696,7 @@ void foreach_modules(const char *name) {
}
}
}
void exec_module_scripts(const char *stage) {
exec_module_scripts(stage, module_list);
}

View File

@ -24,7 +24,8 @@ void exec_script(const char *script) {
exec_command_sync(exec, BBEXEC_CMD, script);
}
void exec_common_script(const char *stage) {
void exec_common_scripts(const char *stage) {
LOGI("* Running %s.d scripts\n", stage);
char path[4096];
char *name = path + sprintf(path, SECURE_DIR "/%s.d", stage);
auto dir = xopen_dir(path);
@ -53,7 +54,8 @@ void exec_common_script(const char *stage) {
}
}
void exec_module_script(const char *stage, const vector<string> &module_list) {
void exec_module_scripts(const char *stage, const vector<string> &module_list) {
LOGI("* Running module %s scripts\n", stage);
char path[4096];
bool pfs = stage == "post-fs-data"sv;
for (auto &m : module_list) {

View File

@ -42,22 +42,23 @@ extern bool RECOVERY_MODE;
extern int DAEMON_STATE;
#define APP_DATA_DIR (SDK_INT >= 24 ? "/data/user_de" : "/data/user")
extern std::vector<std::string> module_list;
// Daemon handlers
void post_fs_data(int client);
void late_start(int client);
void boot_complete(int client);
void magiskhide_handler(int client);
void su_daemon_handler(int client, struct ucred *credential);
void foreach_modules(const char *name);
void su_daemon_handler(int client, ucred *credential);
// Misc
int connect_daemon(bool create = false);
void unlock_blocks();
void reboot();
// Module stuffs
void handle_modules();
void magic_mount();
void reboot();
void foreach_modules(const char *name);
void exec_module_scripts(const char *stage);
// MagiskHide
void auto_start_magiskhide();
@ -65,6 +66,6 @@ int stop_magiskhide();
// Scripting
void exec_script(const char *script);
void exec_common_script(const char *stage);
void exec_module_script(const char *stage, const std::vector<std::string> &module_list);
void exec_common_scripts(const char *stage);
void exec_module_scripts(const char *stage, const std::vector<std::string> &module_list);
void install_apk(const char *apk);