Move MagiskHide initialization to Magisk Manager

This commit is contained in:
topjohnwu 2017-02-01 23:22:07 +08:00
parent 298f09402f
commit ef9948a967
6 changed files with 76 additions and 34 deletions

View File

@ -526,8 +526,8 @@ else
rm verity_key 2>/dev/null
fi
# sepolicy patches
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/sepolicy-inject --magisk -P sepolicy
# minimal sepolicy patches
LD_LIBRARY_PATH=$SYSTEMLIB $BINDIR/sepolicy-inject --minimal -P sepolicy
# Add new items
mkdir -p magisk 2>/dev/null

View File

@ -488,29 +488,6 @@ case $1 in
MAGISK_VERSION_STUB
log_print "** Magisk late_start service mode running..."
run_scripts service
# Magisk Hide
if [ -f $COREDIR/magiskhide/enable ]; then
log_print "* Removing tampered read-only system props"
VERIFYBOOT=`getprop ro.boot.verifiedbootstate`
FLASHLOCKED=`getprop ro.boot.flash.locked`
VERITYMODE=`getprop ro.boot.veritymode`
[ ! -z "$VERIFYBOOT" -a "$VERIFYBOOT" != "green" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.verifiedbootstate green`"
[ ! -z "$FLASHLOCKED" -a "$FLASHLOCKED" != "1" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.flash.locked 1`"
[ ! -z "$VERITYMODE" -a "$VERITYMODE" != "enforcing" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.veritymode enforcing`"
mktouch $COREDIR/magiskhide/hidelist
chmod -R 755 $COREDIR/magiskhide
# Add Safety Net preset
$COREDIR/magiskhide/add com.google.android.gms.unstable
log_print "* Starting Magisk Hide"
/data/magisk/magiskhide --daemon
fi
;;
esac

View File

@ -1,11 +1,13 @@
#!/system/bin/sh
HIDELIST=/magisk/.core/magiskhide/hidelist
PROCESS=$1
if [ ! -z "$1" ]; then
if [ $(grep -c "^$1$" $HIDELIST) -eq "0" ]; then
echo "$1" >> $HIDELIST
set `/data/busybox/ps -o pid,args | grep "$1" | grep -v "grep"`
kill "$1"
if [ ! -z "$PROCESS" ]; then
if [ `grep -c "^$PROCESS$" $HIDELIST` -eq "0" ]; then
echo "$PROCESS" >> $HIDELIST
set --
set `/data/busybox/ps -o pid,args | grep "$PROCESS" | grep -v grep` >/dev/null
[ ! -z "$1" ] && kill "$1"
fi
fi

View File

@ -0,0 +1,22 @@
#!/system/bin/sh
MODDIR=/magisk/.core/magiskhide
LOGFILE=/cache/magisk.log
log_print() {
echo "MagiskHide: $1"
echo "MagiskHide: $1" >> $LOGFILE
log -p i -t Magisk "MagiskHide: $1"
}
log_print "Stopping MagiskHide daemon"
set --
set `/data/busybox/ps -o pid,args | grep "magiskhide" | grep -v grep | head -1` >/dev/null
[ ! -z "$1" ] && kill "$1"
while read PROCESS; do
log_print "Killing $PROCESS"
set --
set `/data/busybox/ps -o pid,args | grep "$PROCESS" | grep -v grep` >/dev/null
[ ! -z "$1" ] && kill "$1"
done < $MODDIR/hidelist

View File

@ -0,0 +1,39 @@
#!/system/bin/sh
MODDIR=/magisk/.core/magiskhide
BINPATH=/data/magisk
LOGFILE=/cache/magisk.log
log_print() {
echo "MagiskHide: $1"
echo "MagiskHide: $1" >> $LOGFILE
log -p i -t Magisk "MagiskHide: $1"
}
log_print "Removing tampered read-only system props"
VERIFYBOOT=`getprop ro.boot.verifiedbootstate`
FLASHLOCKED=`getprop ro.boot.flash.locked`
VERITYMODE=`getprop ro.boot.veritymode`
[ ! -z "$VERIFYBOOT" -a "$VERIFYBOOT" != "green" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.verifiedbootstate green`"
[ ! -z "$FLASHLOCKED" -a "$FLASHLOCKED" != "1" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.flash.locked 1`"
[ ! -z "$VERITYMODE" -a "$VERITYMODE" != "enforcing" ] && \
log_print "`$BINPATH/resetprop -v -n ro.boot.veritymode enforcing`"
touch $MODDIR/hidelist
chmod -R 755 $MODDIR
# Add Safety Net preset
$MODDIR/add com.google.android.gms.unstable
while read PROCESS; do
log_print "Killing $PROCESS"
set --
set `/data/busybox/ps -o pid,args | grep "$PROCESS" | grep -v grep` >/dev/null
[ ! -z "$1" ] && kill "$1"
done < $MODDIR/hidelist
log_print "Starting MagiskHide daemon"
$MODDIR/magiskhide --daemon

View File

@ -1,11 +1,13 @@
#!/system/bin/sh
HIDELIST=/magisk/.core/magiskhide/hidelist
PROCESS=$1
if [ ! -z "$1" ]; then
if [ ! -z "$PROCESS" ]; then
cp -af $HIDELIST $HIDELIST.tmp
cat $HIDELIST.tmp | grep -v "^$1$" > $HIDELIST
cat $HIDELIST.tmp | grep -v "^$PROCESS$" > $HIDELIST
rm -f $HIDELIST.tmp
set `/data/busybox/ps -o pid,args | grep "$1" | grep -v "grep"`
kill "$1"
set --
set `/data/busybox/ps -o pid,args | grep "$PROCESS" | grep -v grep` >/dev/null
[ ! -z "$1" ] && kill "$1"
fi