Add systemless hosts support

This commit is contained in:
topjohnwu 2017-05-04 03:05:37 +08:00
parent 396afaa181
commit 693848280b
2 changed files with 9 additions and 1 deletions

View File

@ -187,7 +187,7 @@ static void trim_img(const char *img) {
void exec_common_script(const char* stage) { void exec_common_script(const char* stage) {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
snprintf(buf, PATH_MAX, "%s/.core/%s.d", MOUNTPOINT, stage); snprintf(buf, PATH_MAX, "%s/%s.d", COREDIR, stage);
if (!(dir = opendir(buf))) if (!(dir = opendir(buf)))
return; return;
@ -677,6 +677,12 @@ void post_fs_data(int client) {
LOGI("* Running module post-fs-data scripts\n"); LOGI("* Running module post-fs-data scripts\n");
exec_module_script("post-fs-data"); exec_module_script("post-fs-data");
// Systemless hosts
if (access(HOSTSFILE, F_OK) == 0) {
LOGI("* Enabling systemless hosts file support");
bind_mount(HOSTSFILE, "/system/etc/hosts");
}
// Start magiskhide if enabled // Start magiskhide if enabled
char *hide_prop = getprop("persist.magisk.hide"); char *hide_prop = getprop("persist.magisk.hide");
if (hide_prop) { if (hide_prop) {

View File

@ -30,6 +30,8 @@
#define DISABLEFILE "/cache/.disable_magisk" #define DISABLEFILE "/cache/.disable_magisk"
#define UNINSTALLER "/cache/magisk_uninstaller.sh" #define UNINSTALLER "/cache/magisk_uninstaller.sh"
#define MOUNTPOINT "/magisk" #define MOUNTPOINT "/magisk"
#define COREDIR MOUNTPOINT "/.core"
#define HOSTSFILE COREDIR "/hosts"
#define MAINIMG "/data/magisk.img" #define MAINIMG "/data/magisk.img"
#define DATABIN "/data/magisk" #define DATABIN "/data/magisk"
#define MAGISKTMP "/dev/magisk" #define MAGISKTMP "/dev/magisk"