1
mirror of https://github.com/topjohnwu/Magisk synced 2024-10-31 22:06:40 +01:00

Hide /magisk

This commit is contained in:
topjohnwu 2017-10-28 16:12:01 +08:00
parent 7244c02a0d
commit 2bc30e5c22
3 changed files with 17 additions and 7 deletions

View File

@ -415,7 +415,7 @@ static void daemon_init() {
unlinkat(sbin, entry->d_name, 0); unlinkat(sbin, entry->d_name, 0);
} }
close(sbin); close(sbin);
mount("tmpfs", "/sbin", "tmpfs", 0, NULL); xmount("tmpfs", "/sbin", "tmpfs", 0, NULL);
sbin = xopen("/sbin", O_RDONLY | O_CLOEXEC); sbin = xopen("/sbin", O_RDONLY | O_CLOEXEC);
fchmod(sbin, 0755); fchmod(sbin, 0755);
fsetfilecon(sbin, "u:object_r:rootfs:s0"); fsetfilecon(sbin, "u:object_r:rootfs:s0");
@ -430,7 +430,9 @@ static void daemon_init() {
snprintf(buf2, PATH_MAX, "/sbin/%s", applet[i]); snprintf(buf2, PATH_MAX, "/sbin/%s", applet[i]);
xsymlink("/root/magisk", buf2); xsymlink("/root/magisk", buf2);
} }
xmkdir("/magisk", 0755); xsymlink(MOUNTPOINT, FAKEPOINT);
close(root);
close(sbin);
xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL); xmount(NULL, "/", NULL, MS_REMOUNT | MS_RDONLY, NULL);
LOGI("* Mounting mirrors"); LOGI("* Mounting mirrors");

View File

@ -22,17 +22,19 @@
#define UNBLOCKFILE "/dev/.magisk.unblock" #define UNBLOCKFILE "/dev/.magisk.unblock"
#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 CACHEMOUNT "/cache/magisk_mount"
#define MAGISKTMP "/dev/magisk"
#define MIRRDIR MAGISKTMP "/mirror"
#define BBPATH MAGISKTMP "/bin"
#define MOUNTPOINT MAGISKTMP "/img"
#define FAKEPOINT "/magisk"
#define COREDIR MOUNTPOINT "/.core" #define COREDIR MOUNTPOINT "/.core"
#define HOSTSFILE COREDIR "/hosts" #define HOSTSFILE COREDIR "/hosts"
#define HIDELIST COREDIR "/hidelist" #define HIDELIST COREDIR "/hidelist"
#define MAINIMG "/data/magisk.img" #define MAINIMG "/data/magisk.img"
#define DATABIN "/data/magisk" #define DATABIN "/data/magisk"
#define MANAGERAPK DATABIN "/magisk.apk" #define MANAGERAPK DATABIN "/magisk.apk"
#define MAGISKTMP "/dev/magisk"
#define MIRRDIR MAGISKTMP "/mirror"
#define BBPATH MAGISKTMP "/bin"
#define CACHEMOUNT "/cache/magisk_mount"
#define SELINUX_PATH "/sys/fs/selinux/" #define SELINUX_PATH "/sys/fs/selinux/"
#define SELINUX_ENFORCE SELINUX_PATH "enforce" #define SELINUX_ENFORCE SELINUX_PATH "enforce"

View File

@ -125,11 +125,17 @@ static void hide_daemon(int pid) {
free(line); free(line);
} }
xmount(NULL, "/", NULL, MS_REMOUNT, NULL);
unlink(FAKEPOINT);
exit: exit:
// Send resume signal // Send resume signal
kill(pid, SIGCONT); kill(pid, SIGCONT);
// Free up memory // Free up memory
vec_destroy(&mount_list); vec_destroy(&mount_list);
// Wait a while and link it back
sleep(10);
xsymlink(MOUNTPOINT, FAKEPOINT);
_exit(0); _exit(0);
} }