Adjust scripts for resetprop
This commit is contained in:
parent
1d0c36a0ab
commit
bcdd74514f
@ -160,7 +160,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
logfile = fopen("/cache/magisk.log", "a+");
|
logfile = fopen("/cache/magisk.log", "a+");
|
||||||
setbuf(logfile, NULL);
|
setbuf(logfile, NULL);
|
||||||
|
|
||||||
pthread_t list_monitor, unmount_thread;
|
pthread_t list_monitor;
|
||||||
|
|
||||||
pthread_mutex_init(&mutex, NULL);
|
pthread_mutex_init(&mutex, NULL);
|
||||||
pthread_create(&list_monitor, NULL, monitor_list, "/magisk/.core/magiskhide/hidelist");
|
pthread_create(&list_monitor, NULL, monitor_list, "/magisk/.core/magiskhide/hidelist");
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 3a0df56605bc9226b4c989979c1d4e9a8a565ad4
|
Subproject commit be1dcb7264e8a20b101a93d01bd671a7f56d07c3
|
@ -376,7 +376,7 @@ fi
|
|||||||
if (! $SUPERSU); then
|
if (! $SUPERSU); then
|
||||||
ui_print "- Creating backups"
|
ui_print "- Creating backups"
|
||||||
mkdir .backup 2>/dev/null
|
mkdir .backup 2>/dev/null
|
||||||
cp -af init.environ.rc *fstab* verity_key sepolicy .backup 2>/dev/null
|
cp -af *fstab* verity_key sepolicy .backup 2>/dev/null
|
||||||
if (is_mounted /data); then
|
if (is_mounted /data); then
|
||||||
cp -af $ORIGBOOT /data/stock_boot.img
|
cp -af $ORIGBOOT /data/stock_boot.img
|
||||||
else
|
else
|
||||||
@ -396,17 +396,17 @@ for INIT in init*.rc; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add magisk specific
|
# # Add magisk specific
|
||||||
if [ $(grep -c "export PATH" init.environ.rc) -eq "0" ]; then
|
# if [ $(grep -c "export PATH" init.environ.rc) -eq "0" ]; then
|
||||||
sed -i "/on init/a\ \ \ \ export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/magisk/.core/busybox" init.environ.rc
|
# sed -i "/on init/a\ \ \ \ export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/magisk/.core/busybox" init.environ.rc
|
||||||
else
|
# else
|
||||||
if [ $(grep -c "/magisk/.core/busybox" init.environ.rc) -eq "0" ]; then
|
# if [ $(grep -c "/magisk/.core/busybox" init.environ.rc) -eq "0" ]; then
|
||||||
sed -i "/export PATH/ s/\/system\/xbin/\/system\/xbin:\/magisk\/.core\/busybox/g" init.environ.rc
|
# sed -i "/export PATH/ s/\/system\/xbin/\/system\/xbin:\/magisk\/.core\/busybox/g" init.environ.rc
|
||||||
fi
|
# fi
|
||||||
if [ $(grep -c "/magisk/.core/bin" init.environ.rc) -eq "0" ] && (! $SUPERSU); then
|
# if [ $(grep -c "/magisk/.core/bin" init.environ.rc) -eq "0" ] && (! $SUPERSU); then
|
||||||
sed -i "/export PATH/ s/\/sbin/\/magisk\/.core\/bin:\/sbin/g" init.environ.rc
|
# sed -i "/export PATH/ s/\/sbin/\/magisk\/.core\/bin:\/sbin/g" init.environ.rc
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if (! $SUPERSU); then
|
if (! $SUPERSU); then
|
||||||
sed -i "/selinux.reload_policy/d" init.rc
|
sed -i "/selinux.reload_policy/d" init.rc
|
||||||
|
@ -15,8 +15,10 @@ MOUNTINFO=$TMPDIR/mnt
|
|||||||
# Use the included busybox for maximum compatibility and reliable results
|
# Use the included busybox for maximum compatibility and reliable results
|
||||||
# e.g. we rely on the option "-c" for cp (reserve contexts), and -exec for find
|
# e.g. we rely on the option "-c" for cp (reserve contexts), and -exec for find
|
||||||
TOOLPATH=/data/busybox
|
TOOLPATH=/data/busybox
|
||||||
|
BINPATH=/data/magisk
|
||||||
|
|
||||||
# Legacy support for old phh, we don't change PATH now
|
# Legacy support for old phh, we don't change PATH now
|
||||||
|
# Will remove in the next release
|
||||||
export OLDPATH=$PATH
|
export OLDPATH=$PATH
|
||||||
|
|
||||||
|
|
||||||
@ -224,11 +226,11 @@ case $1 in
|
|||||||
touch $LOGFILE
|
touch $LOGFILE
|
||||||
chmod 644 $LOGFILE
|
chmod 644 $LOGFILE
|
||||||
|
|
||||||
log_print "** Magisk post-fs mode running..."
|
|
||||||
|
|
||||||
# No more cache mods!
|
# No more cache mods!
|
||||||
# Only for multirom!
|
# Only for multirom!
|
||||||
|
|
||||||
|
# log_print "** Magisk post-fs mode running..."
|
||||||
|
|
||||||
unblock
|
unblock
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -244,28 +246,31 @@ case $1 in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't run twice
|
# Don't run twice
|
||||||
if [ "$(getprop magisk.restart_pfsd)" != "1" ]; then
|
if [ "`getprop magisk.restart_pfsd`" != "1" ]; then
|
||||||
|
|
||||||
log_print "** Magisk post-fs-data mode running..."
|
log_print "** Magisk post-fs-data mode running..."
|
||||||
|
|
||||||
# Live patch sepolicy
|
# Live patch sepolicy
|
||||||
/data/magisk/sepolicy-inject --live -s su
|
$BINPATH/sepolicy-inject --live -s su
|
||||||
|
|
||||||
|
# Multirom functions should go here, not available right now
|
||||||
|
MULTIROM=false
|
||||||
|
|
||||||
# Cache support
|
# Cache support
|
||||||
if [ -d "/cache/data_bin" ]; then
|
if [ -d "/cache/data_bin" ]; then
|
||||||
rm -rf /data/busybox /data/magisk
|
rm -rf $BINPATH $TOOLPATH
|
||||||
mkdir -p /data/busybox
|
mkdir -p $TOOLPATH
|
||||||
mv /cache/data_bin /data/magisk
|
mv /cache/data_bin $BINPATH
|
||||||
chmod -R 755 /data/busybox /data/magisk
|
chmod -R 755 $BINPATH $TOOLPATH
|
||||||
/data/magisk/busybox --install -s /data/busybox
|
$BINPATH/busybox --install -s $TOOLPATH
|
||||||
ln -s /data/magisk/busybox /data/busybox/busybox
|
ln -s $BINPATH/busybox $TOOLPATH/busybox
|
||||||
# Prevent issues
|
# Prevent issues
|
||||||
rm -f /data/busybox/su /data/busybox/sh
|
rm -f $TOOLPATH/su $TOOLPATH/sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv /cache/stock_boot.img /data 2>/dev/null
|
mv /cache/stock_boot.img /data 2>/dev/null
|
||||||
|
|
||||||
chcon -R 'u:object_r:system_file:s0' /data/busybox /data/magisk
|
chcon -R 'u:object_r:system_file:s0' $BINPATH $TOOLPATH
|
||||||
|
|
||||||
# Image merging
|
# Image merging
|
||||||
chmod 644 $IMG /cache/magisk.img /data/magisk_merge.img 2>/dev/null
|
chmod 644 $IMG /cache/magisk.img /data/magisk_merge.img 2>/dev/null
|
||||||
@ -286,7 +291,7 @@ case $1 in
|
|||||||
unblock
|
unblock
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove empty directories and remove legacy paths and previous symlink
|
# Remove empty directories, legacy paths and symlinks
|
||||||
rm -rf $COREDIR/bin $COREDIR/dummy $COREDIR/mirror
|
rm -rf $COREDIR/bin $COREDIR/dummy $COREDIR/mirror
|
||||||
$TOOLPATH/find $MOUNTPOINT -type d -depth ! -path "*core*" -exec rmdir {} \; 2>/dev/null
|
$TOOLPATH/find $MOUNTPOINT -type d -depth ! -path "*core*" -exec rmdir {} \; 2>/dev/null
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ case $1 in
|
|||||||
mkdir -p $DUMMDIR
|
mkdir -p $DUMMDIR
|
||||||
mkdir -p $MIRRDIR/system
|
mkdir -p $MIRRDIR/system
|
||||||
|
|
||||||
# Travel through all mods
|
# Travel through all mods, all magic happens here
|
||||||
for MOD in $MOUNTPOINT/* ; do
|
for MOD in $MOUNTPOINT/* ; do
|
||||||
if [ -f "$MOD/auto_mount" -a -d "$MOD/system" -a ! -f "$MOD/disable" ]; then
|
if [ -f "$MOD/auto_mount" -a -d "$MOD/system" -a ! -f "$MOD/disable" ]; then
|
||||||
(travel $MOD system)
|
(travel $MOD system)
|
||||||
@ -379,7 +384,7 @@ case $1 in
|
|||||||
log_print "Bind mount mirror items"
|
log_print "Bind mount mirror items"
|
||||||
# Find all empty directores and dummy files, they should be mounted by original files in /system
|
# Find all empty directores and dummy files, they should be mounted by original files in /system
|
||||||
TOOLPATH=/data/busybox $TOOLPATH/find $DUMMDIR -type d \
|
TOOLPATH=/data/busybox $TOOLPATH/find $DUMMDIR -type d \
|
||||||
-exec sh -c '[ -z "$($TOOLPATH/ls -A $1)" ] && echo $1' -- {} \; \
|
-exec sh -c '[ -z "`$TOOLPATH/ls -A $1`" ] && echo $1' -- {} \; \
|
||||||
-o \( -type f -size 0 -print \) | \
|
-o \( -type f -size 0 -print \) | \
|
||||||
while read ITEM ; do
|
while read ITEM ; do
|
||||||
ORIG=${ITEM/dummy/mirror}
|
ORIG=${ITEM/dummy/mirror}
|
||||||
@ -387,8 +392,8 @@ case $1 in
|
|||||||
bind_mount $ORIG $TARGET
|
bind_mount $ORIG $TARGET
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restart post-fs-data, since data might be changed (multirom)
|
# Restart post-fs-data if necessary (multirom)
|
||||||
setprop magisk.restart_pfsd 1
|
($MULTIROM) && setprop magisk.restart_pfsd 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
unblock
|
unblock
|
||||||
@ -400,14 +405,25 @@ case $1 in
|
|||||||
log_print "** Magisk late_start service mode running..."
|
log_print "** Magisk late_start service mode running..."
|
||||||
run_scripts service
|
run_scripts service
|
||||||
|
|
||||||
# MagiskHide
|
# Hide Safety Net
|
||||||
if [ -f "$COREDIR/magiskhide/enable" ]; then
|
if [ -f "$COREDIR/magiskhide/enable" ]; then
|
||||||
[ ! -f "$COREDIR/magiskhide/hidelist" ] && mktouch $COREDIR/magiskhide/hidelist
|
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
|
chmod -R 755 $COREDIR/magiskhide
|
||||||
# Add Safety Net preset
|
# Add Safety Net preset
|
||||||
$COREDIR/magiskhide/add com.google.android.gms.unstable
|
$COREDIR/magiskhide/add com.google.android.gms.unstable
|
||||||
log_print "** Starting Magisk Hide"
|
log_print "** Starting Magisk Hide"
|
||||||
/data/magisk/magiskhide
|
/data/magisk/magiskhide
|
||||||
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user