mirror of
https://github.com/topjohnwu/Magisk
synced 2024-11-13 20:54:12 +01:00
Update busybox handling
This commit is contained in:
parent
ef9948a967
commit
db501822ef
@ -320,18 +320,14 @@ fi
|
||||
ui_print "- Constructing environment"
|
||||
|
||||
if (is_mounted /data); then
|
||||
rm -rf /data/busybox /data/magisk 2>/dev/null
|
||||
mkdir -p /data/busybox /data/magisk
|
||||
rm -rf /data/magisk 2>/dev/null
|
||||
mkdir -p /data/magisk
|
||||
cp -af $BINDIR/busybox $BINDIR/sepolicy-inject $BINDIR/resetprop \
|
||||
$INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /data/magisk
|
||||
cp -af $INSTALLER/common/magisk.apk /data/magisk.apk
|
||||
/data/magisk/busybox --install -s /data/busybox
|
||||
ln -s /data/magisk/busybox /data/busybox/busybox
|
||||
# Prevent issues
|
||||
rm -f /data/busybox/su /data/busybox/sh /data/busybox/reboot
|
||||
chcon -hR u:object_r:system_file:s0 /data/magisk /data/busybox
|
||||
chmod -R 755 /data/magisk /data/busybox
|
||||
# PATH=/data/busybox:$PATH
|
||||
chmod -R 755 /data/magisk
|
||||
chcon -h u:object_r:system_file:s0 /data/magisk /data/magisk/*
|
||||
PATH=/data/busybox:$PATH
|
||||
else
|
||||
rm -rf /cache/data_bin 2>/dev/null
|
||||
mkdir -p /cache/data_bin
|
||||
@ -342,6 +338,13 @@ else
|
||||
chmod -R 755 /cache/data_bin
|
||||
fi
|
||||
|
||||
# Temporary busybox for installation
|
||||
mkdir -p $TMPDIR/busybox
|
||||
$BINDIR/busybox --install -s $TMPDIR/busybox
|
||||
rm -f $TMPDIR/busybox/su $TMPDIR/busybox/sh $TMPDIR/busybox/reboot
|
||||
PATH=$TMPDIR/busybox:$PATH
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# Image
|
||||
##########################################################################################
|
||||
@ -486,11 +489,10 @@ else
|
||||
|
||||
# MagiskSU
|
||||
ui_print "- Installing MagiskSU"
|
||||
rm -rf $COREDIR/su 2>/dev/null
|
||||
mkdir -p $COREDIR/su
|
||||
mkdir -p $COREDIR/su 2>/dev/null
|
||||
cp -af $BINDIR/su $INSTALLER/common/magisksu.sh $COREDIR/su
|
||||
chmod -R 755 $COREDIR/su
|
||||
chown -R 0.0 $COREDIR/su
|
||||
chmod 755 $COREDIR/su/su $COREDIR/su/magisksu.sh
|
||||
chown -R 0.0 $COREDIR/su/su $COREDIR/su/magisksu.sh
|
||||
|
||||
# Patch ramdisk
|
||||
ui_print "- Patching ramdisk"
|
||||
|
@ -15,8 +15,12 @@ MOUNTINFO=$TMPDIR/mnt
|
||||
|
||||
# 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
|
||||
TOOLPATH=/data/busybox
|
||||
TOOLPATH=/dev/busybox
|
||||
BINPATH=/data/magisk
|
||||
OLDPATH=$PATH
|
||||
export PATH=$TOOLPATH:$OLDPATH
|
||||
|
||||
APPDIR=/data/data/com.topjohnwu.magisk/files
|
||||
|
||||
# Default permissions
|
||||
umask 022
|
||||
@ -273,24 +277,25 @@ case $1 in
|
||||
mv /cache/magisk.apk /data/magisk.apk 2>/dev/null
|
||||
mv /cache/custom_ramdisk_patch.sh /data/custom_ramdisk_patch.sh 2>/dev/null
|
||||
|
||||
if [ -d "/cache/data_bin" ]; then
|
||||
rm -rf $BINPATH $TOOLPATH
|
||||
mkdir -p $TOOLPATH
|
||||
if [ -d /cache/data_bin ]; then
|
||||
rm -rf $BINPATH
|
||||
mv /cache/data_bin $BINPATH
|
||||
$BINPATH/busybox --install -s $TOOLPATH
|
||||
ln -s $BINPATH/busybox $TOOLPATH/busybox
|
||||
# Prevent issues
|
||||
rm -f $TOOLPATH/su $TOOLPATH/sh $TOOLPATH/reboot
|
||||
fi
|
||||
|
||||
chmod -R 755 $BINPATH
|
||||
chown -R 0.0 $BINPATH
|
||||
|
||||
# Live patch sepolicy
|
||||
$BINPATH/sepolicy-inject --live
|
||||
|
||||
# Set up environment
|
||||
export OLDPATH=$PATH
|
||||
export PATH=$TOOLPATH:$OLDPATH
|
||||
chmod -R 755 $BINPATH $TOOLPATH
|
||||
chown -R 0.0 $BINPATH $TOOLPATH
|
||||
mkdir -p $TOOLPATH
|
||||
$BINPATH/busybox --install -s $TOOLPATH
|
||||
ln -s $BINPATH/busybox $TOOLPATH/busybox
|
||||
# Prevent issues
|
||||
rm -f $TOOLPATH/su $TOOLPATH/sh $TOOLPATH/reboot
|
||||
chmod -R 755 $TOOLPATH
|
||||
chown -R 0.0 $TOOLPATH
|
||||
find $BINPATH $TOOLPATH -exec chcon -h u:object_r:system_file:s0 {} \;
|
||||
|
||||
# Multirom functions should go here, not available right now
|
||||
@ -314,7 +319,7 @@ case $1 in
|
||||
|
||||
# Remove empty directories, legacy paths, symlinks, old temporary images
|
||||
find $MOUNTPOINT -type d -depth ! -path "*core*" -exec rmdir {} \; 2>/dev/null
|
||||
rm -rf $MOUNTPOINT/zzsupersu $MOUNTPOINT/phh $COREDIR/bin $COREDIR/dummy $COREDIR/mirror /data/magisk/*.img 2>/dev/null
|
||||
rm -rf $MOUNTPOINT/zzsupersu $MOUNTPOINT/phh $COREDIR/bin $COREDIR/dummy $COREDIR/mirror /data/magisk/*.img /data/busybox 2>/dev/null
|
||||
|
||||
# Remove modules that are labeled to be removed
|
||||
for MOD in $MOUNTPOINT/* ; do
|
||||
@ -343,7 +348,12 @@ case $1 in
|
||||
fi
|
||||
|
||||
# Start MagiskSU if no SuperSU
|
||||
export PATH=$OLDPATH
|
||||
[ ! -f /sbin/launch_daemonsu.sh ] && sh $COREDIR/su/magisksu.sh
|
||||
export PATH=$TOOLPATH:$OLDPATH
|
||||
|
||||
# Disable Magic Mount if specified
|
||||
[ -f $APPDIR/disable ] && unblock
|
||||
|
||||
log_print "* Preparing modules"
|
||||
|
||||
@ -441,16 +451,6 @@ case $1 in
|
||||
bind_mount $COREDIR/hosts /system/etc/hosts
|
||||
fi
|
||||
|
||||
# Expose busybox
|
||||
if [ -f $COREDIR/busybox/enable ]; then
|
||||
log_print "* Enabling BusyBox"
|
||||
cp -afc /data/busybox/. $COREDIR/busybox
|
||||
cp -afc /system/xbin/. $COREDIR/busybox
|
||||
chmod -R 755 $COREDIR/busybox
|
||||
chcon -hR u:object_r:system_file:s0 $COREDIR/busybox
|
||||
bind_mount $COREDIR/busybox /system/xbin
|
||||
fi
|
||||
|
||||
if [ -f /data/magisk.apk ]; then
|
||||
if [ -z `ls /data/app | grep com.topjohnwu.magisk` ]; then
|
||||
mkdir /data/app/com.topjohnwu.magisk-1
|
||||
@ -480,9 +480,20 @@ case $1 in
|
||||
/data/magisk/resetprop --file $MOD/system.prop
|
||||
fi
|
||||
done
|
||||
|
||||
# Expose busybox
|
||||
[ "`getprop persist.magisk.busybox`" = "1" ] && sh /sbin/magic_mask.sh mount_busybox
|
||||
|
||||
unblock
|
||||
;;
|
||||
|
||||
mount_busybox )
|
||||
log_print "* Enabling BusyBox"
|
||||
cp -afc /system/xbin/. $TOOLPATH
|
||||
umount /system/xbin 2>/dev/null
|
||||
bind_mount $TOOLPATH /system/xbin
|
||||
;;
|
||||
|
||||
service )
|
||||
# Version info
|
||||
MAGISK_VERSION_STUB
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
MODDIR=${0%/*}
|
||||
LOGFILE=/cache/magisk.log
|
||||
PATH=$OLDPATH
|
||||
|
||||
log_print() {
|
||||
echo "MagiskSU: $1"
|
||||
|
Loading…
Reference in New Issue
Block a user