Support enable/disable Zygisk

This commit is contained in:
topjohnwu
2021-09-15 02:49:54 -07:00
parent 3b8ce85092
commit c0be5383de
12 changed files with 65 additions and 22 deletions

View File

@@ -18,6 +18,7 @@
using namespace std;
static bool safe_mode = false;
bool zygisk_enabled = false;
/*********
* Setup *
@@ -301,7 +302,12 @@ void post_fs_data(int client) {
disable_deny();
} else {
exec_common_scripts("post-fs-data");
check_enforce_denylist();
db_settings dbs;
get_db_settings(dbs, ZYGISK_CONFIG);
if (dbs[ZYGISK_CONFIG]) {
zygisk_enabled = true;
check_enforce_denylist();
}
handle_modules();
}
@@ -350,8 +356,6 @@ void boot_complete(int client) {
if (access(SECURE_DIR, F_OK) != 0)
xmkdir(SECURE_DIR, 0700);
check_enforce_denylist();
if (!check_manager()) {
if (access(MANAGERAPK, F_OK) == 0) {
// Only try to install APK when no manager is installed

View File

@@ -6,6 +6,7 @@
extern bool RECOVERY_MODE;
extern int DAEMON_STATE;
extern bool zygisk_enabled;
void unlock_blocks();
void reboot();

View File

@@ -113,6 +113,7 @@ db_settings::db_settings() {
data[SU_MULTIUSER_MODE] = MULTIUSER_MODE_OWNER_ONLY;
data[SU_MNT_NS] = NAMESPACE_MODE_REQUESTER;
data[DENYLIST_CONFIG] = false;
data[ZYGISK_CONFIG] = false;
}
int db_settings::get_idx(string_view key) const {

View File

@@ -616,10 +616,12 @@ void magic_mount() {
root->mount();
// Mount on top of modules to enable zygisk
string zygisk_bin = MAGISKTMP + "/" ZYGISKBIN;
mkdir(zygisk_bin.data(), 0);
mount_zygisk(32)
mount_zygisk(64)
if (zygisk_enabled) {
string zygisk_bin = MAGISKTMP + "/" ZYGISKBIN;
mkdir(zygisk_bin.data(), 0);
mount_zygisk(32)
mount_zygisk(64)
}
}
static void prepare_modules() {

View File

@@ -38,7 +38,8 @@ constexpr const char *DB_SETTING_KEYS[] = {
"root_access",
"multiuser_mode",
"mnt_ns",
"denylist"
"denylist",
"zygisk"
};
// Settings key indices
@@ -46,7 +47,8 @@ enum {
ROOT_ACCESS = 0,
SU_MULTIUSER_MODE,
SU_MNT_NS,
DENYLIST_CONFIG
DENYLIST_CONFIG,
ZYGISK_CONFIG
};
// Values for root_access