From 0784448c697282f8ccc60ffa0664249406d411bf Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 20 Nov 2018 05:24:40 -0500 Subject: [PATCH] Remove /.backup folder on start --- app/src/full/res/raw/utils.sh | 3 +-- native/jni/daemon/bootstages.cpp | 9 ++++++--- scripts/util_functions.sh | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/full/res/raw/utils.sh b/app/src/full/res/raw/utils.sh index 4f20d73ad..65a92b1c7 100644 --- a/app/src/full/res/raw/utils.sh +++ b/app/src/full/res/raw/utils.sh @@ -79,9 +79,8 @@ mm_patch_dtbo() { } restore_imgs() { - local SHA1=`grep_prop SHA1 /.backup/.magisk` + local SHA1=`grep_prop SHA1 /sbin/.magisk/config` [ -z $SHA1 ] && local SHA1=`cat /.backup/.sha1` - [ -z $SHA1 ] && local SHA1=`grep_prop #STOCKSHA1 /.backup/.magisk` [ -z $SHA1 ] && return 1 local STOCKBOOT=/data/stock_boot_${SHA1}.img.gz local STOCKDTBO=/data/stock_dtbo.img.gz diff --git a/native/jni/daemon/bootstages.cpp b/native/jni/daemon/bootstages.cpp index d7591d1d7..2f2886ae7 100644 --- a/native/jni/daemon/bootstages.cpp +++ b/native/jni/daemon/bootstages.cpp @@ -683,9 +683,6 @@ void startup() { xmount(nullptr, "/", nullptr, MS_REMOUNT, nullptr); - // Remove some traits of Magisk - unlink(MAGISKRC); - // GSIs will have to override /sbin/adbd with /system/bin/adbd if (access("/sbin/adbd", F_OK) == 0 && access("/system/bin/adbd", F_OK) == 0) { umount2("/sbin/adbd", MNT_DETACH); @@ -710,6 +707,12 @@ void startup() { setfilecon("/sbin", "u:object_r:rootfs:s0"); sbin = xopen("/sbin", O_RDONLY | O_CLOEXEC); + // Remove some traces of Magisk + unlink(MAGISKRC); + mkdir(MAGISKTMP, 0755); + cp_afc("/.backup/.magisk", MAGISKTMP "/config"); + rm_rf("/.backup"); + // Create applet symlinks for (int i = 0; applet_names[i]; ++i) { snprintf(buf, PATH_MAX, "/sbin/%s", applet_names[i]); diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 61198e375..a2b5d88b5 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -153,7 +153,7 @@ grep_prop() { getvar() { local VARNAME=$1 local VALUE= - VALUE=`grep_prop $VARNAME /.backup/.magisk /data/.magisk /cache/.magisk /system/.magisk` + VALUE=`grep_prop $VARNAME /sbin/.magisk/config /data/.magisk /cache/.magisk /system/.magisk` [ ! -z $VALUE ] && eval $VARNAME=\$VALUE }