Live patch policy in service mode
This commit is contained in:
parent
81542fc6a8
commit
67f347f880
@ -1 +1 @@
|
|||||||
Subproject commit f66a820e14e1df23948b06dbe631c781c029abe0
|
Subproject commit 03c8079858f68a335a9b75b34f4623221750a6fe
|
@ -294,9 +294,10 @@ MAGISKLOOP=$LOOPDEVICE
|
|||||||
# Core folders and scripts
|
# Core folders and scripts
|
||||||
mkdir -p $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null
|
mkdir -p $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d 2>/dev/null
|
||||||
cp -af $COMMONDIR/magiskhide/. $COREDIR/magiskhide
|
cp -af $COMMONDIR/magiskhide/. $COREDIR/magiskhide
|
||||||
cp -af $BINDIR/resetprop $BINDIR/magiskhide $BINDIR/su $COREDIR/bin
|
cp -af $BINDIR/resetprop $BINDIR/magiskhide $BINDIR/su $BINDIR/magiskpolicy $COREDIR/bin
|
||||||
# Legacy support
|
# Legacy support
|
||||||
ln -sf $COREDIR/bin/resetprop $MAGISKBIN/resetprop
|
ln -sf $COREDIR/bin/resetprop $MAGISKBIN/resetprop
|
||||||
|
|
||||||
chmod -R 755 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
|
chmod -R 755 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
|
||||||
chown -R 0.0 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
|
chown -R 0.0 $COREDIR/bin $COREDIR/magiskhide $COREDIR/post-fs-data.d $COREDIR/service.d
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ in_list() {
|
|||||||
|
|
||||||
unblock() {
|
unblock() {
|
||||||
touch /dev/.magisk.unblock
|
touch /dev/.magisk.unblock
|
||||||
chcon u:object_r:device:s0 /dev/.magisk.unblock
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,18 +80,19 @@ image_size_check() {
|
|||||||
curSizeM=$((curSizeM * 4 / 1024))
|
curSizeM=$((curSizeM * 4 / 1024))
|
||||||
}
|
}
|
||||||
|
|
||||||
run_scripts() {
|
module_scripts() {
|
||||||
BASE=$MOUNTPOINT
|
BASE=$MOUNTPOINT
|
||||||
for MOD in $BASE/* ; do
|
for MOD in $BASE/* ; do
|
||||||
if [ ! -f $MOD/disable ]; then
|
if [ ! -f $MOD/disable -a -f $MOD/$1.sh ]; then
|
||||||
if [ -f $MOD/$1.sh ]; then
|
|
||||||
chmod 755 $MOD/$1.sh
|
chmod 755 $MOD/$1.sh
|
||||||
chcon u:object_r:system_file:s0 $MOD/$1.sh
|
chcon u:object_r:system_file:s0 $MOD/$1.sh
|
||||||
log_print "$1: $MOD/$1.sh"
|
log_print "$1: $MOD/$1.sh"
|
||||||
sh $MOD/$1.sh
|
sh $MOD/$1.sh
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
general_scripts() {
|
||||||
for SCRIPT in $COREDIR/${1}.d/* ; do
|
for SCRIPT in $COREDIR/${1}.d/* ; do
|
||||||
if [ -f "$SCRIPT" ]; then
|
if [ -f "$SCRIPT" ]; then
|
||||||
chmod 755 $SCRIPT
|
chmod 755 $SCRIPT
|
||||||
@ -303,9 +303,6 @@ case $1 in
|
|||||||
chown -R 0.0 $DATABIN
|
chown -R 0.0 $DATABIN
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Live patch sepolicy
|
|
||||||
$DATABIN/magiskpolicy --live
|
|
||||||
|
|
||||||
# Set up environment
|
# Set up environment
|
||||||
mkdir -p $TOOLPATH
|
mkdir -p $TOOLPATH
|
||||||
$DATABIN/busybox --install -s $TOOLPATH
|
$DATABIN/busybox --install -s $TOOLPATH
|
||||||
@ -316,8 +313,7 @@ case $1 in
|
|||||||
|
|
||||||
if [ -f $UNINSTALLER ]; then
|
if [ -f $UNINSTALLER ]; then
|
||||||
touch /dev/.magisk.unblock
|
touch /dev/.magisk.unblock
|
||||||
chcon u:object_r:device:s0 /dev/.magisk.unblock
|
(BOOTMODE=true sh $UNINSTALLER) &
|
||||||
BOOTMODE=true sh $UNINSTALLER
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -368,25 +364,16 @@ case $1 in
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_print "* Linking binaries to /sbin"
|
log_print "* Running post-fs-data.d"
|
||||||
mount -o rw,remount rootfs /
|
general_scripts post-fs-data
|
||||||
chmod 755 /sbin
|
|
||||||
ln -sf $DATABIN/magiskpolicy /sbin/magiskpolicy
|
|
||||||
ln -sf $DATABIN/magiskpolicy /sbin/sepolicy-inject
|
|
||||||
ln -sf $MAGISKBIN/resetprop /sbin/resetprop
|
|
||||||
if [ ! -f /sbin/launch_daemonsu.sh ]; then
|
|
||||||
log_print "* Starting MagiskSU"
|
|
||||||
export PATH=$OLDPATH
|
|
||||||
ln -sf $MAGISKBIN/su /sbin/su
|
|
||||||
ln -sf $DATABIN/magiskpolicy /sbin/supolicy
|
|
||||||
/sbin/su --daemon
|
|
||||||
export PATH=$TOOLPATH:$OLDPATH
|
|
||||||
fi
|
|
||||||
mount -o ro,remount rootfs /
|
|
||||||
|
|
||||||
# Exit if disabled
|
# Exit if disabled
|
||||||
[ -f $DISABLEFILE ] && unblock
|
[ -f $DISABLEFILE ] && unblock
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Core features done #
|
||||||
|
######################
|
||||||
|
|
||||||
# Multirom functions should go here, not available right now
|
# Multirom functions should go here, not available right now
|
||||||
MULTIROM=false
|
MULTIROM=false
|
||||||
|
|
||||||
@ -474,8 +461,8 @@ case $1 in
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Stage 4
|
# Stage 4
|
||||||
log_print "* Stage 4: Execute scripts"
|
log_print "* Stage 4: Execute module scripts"
|
||||||
run_scripts post-fs-data
|
module_scripts post-fs-data
|
||||||
|
|
||||||
# Stage 5
|
# Stage 5
|
||||||
log_print "* Stage 5: Mount mirrored items back to dummy"
|
log_print "* Stage 5: Mount mirrored items back to dummy"
|
||||||
@ -527,6 +514,28 @@ case $1 in
|
|||||||
MAGISK_VERSION_STUB
|
MAGISK_VERSION_STUB
|
||||||
log_print "** Magisk late_start service mode running..."
|
log_print "** Magisk late_start service mode running..."
|
||||||
|
|
||||||
|
# Live patch sepolicy
|
||||||
|
$MAGISKBIN/magiskpolicy --live --magisk
|
||||||
|
|
||||||
|
log_print "* Linking binaries to /sbin"
|
||||||
|
mount -o rw,remount rootfs /
|
||||||
|
chmod 755 /sbin
|
||||||
|
ln -sf $MAGISKBIN/magiskpolicy /sbin/magiskpolicy
|
||||||
|
ln -sf $MAGISKBIN/magiskpolicy /sbin/sepolicy-inject
|
||||||
|
ln -sf $MAGISKBIN/resetprop /sbin/resetprop
|
||||||
|
if [ ! -f /sbin/launch_daemonsu.sh ]; then
|
||||||
|
log_print "* Starting MagiskSU"
|
||||||
|
export PATH=$OLDPATH
|
||||||
|
ln -sf $MAGISKBIN/su /sbin/su
|
||||||
|
ln -sf $MAGISKBIN/magiskpolicy /sbin/supolicy
|
||||||
|
/sbin/su --daemon
|
||||||
|
export PATH=$TOOLPATH:$OLDPATH
|
||||||
|
fi
|
||||||
|
mount -o ro,remount rootfs /
|
||||||
|
|
||||||
|
log_print "* Running service.d"
|
||||||
|
general_scripts service
|
||||||
|
|
||||||
# Start MagiskHide
|
# Start MagiskHide
|
||||||
[ "`getprop persist.magisk.hide`" = "1" ] && sh $COREDIR/magiskhide/enable
|
[ "`getprop persist.magisk.hide`" = "1" ] && sh $COREDIR/magiskhide/enable
|
||||||
|
|
||||||
@ -536,7 +545,7 @@ case $1 in
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run_scripts service
|
module_scripts service
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user