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