scripts: fix root loss until reboot after Magisk addon.d-v2

- /system/bin/su was being removed in error from the live system so update remove_system_su to be aware of a running A/B OTA and generalize/simplify removal logic with relative paths to correctly run on the updated system slot
This commit is contained in:
osm0sis 2022-12-20 20:16:57 -04:00 committed by John Wu
parent 2a2a452bd4
commit 0d38c94c9c

View File

@ -513,34 +513,39 @@ sign_chromeos() {
} }
remove_system_su() { remove_system_su() {
if [ -f /system/bin/su -o -f /system/xbin/su ] && [ ! -f /su/bin/su ]; then [ -d /postinstall/tmp ] && POSTINST=/postinstall
cd $POSTINST/system
if [ -f bin/su -o -f xbin/su ] && [ ! -f /su/bin/su ]; then
ui_print "- Removing system installed root" ui_print "- Removing system installed root"
blockdev --setrw /dev/block/mapper/system$SLOT 2>/dev/null blockdev --setrw /dev/block/mapper/system$SLOT 2>/dev/null
mount -o rw,remount /system mount -o rw,remount $POSTINST/system
# SuperSU # SuperSU
if [ -e /system/bin/.ext/.su ]; then cd bin
mv -f /system/bin/app_process32_original /system/bin/app_process32 2>/dev/null if [ -e .ext/.su ]; then
mv -f /system/bin/app_process64_original /system/bin/app_process64 2>/dev/null mv -f app_process32_original app_process32 2>/dev/null
mv -f /system/bin/install-recovery_original.sh /system/bin/install-recovery.sh 2>/dev/null mv -f app_process64_original app_process64 2>/dev/null
cd /system/bin mv -f install-recovery_original.sh install-recovery.sh 2>/dev/null
if [ -e app_process64 ]; then if [ -e app_process64 ]; then
ln -sf app_process64 app_process ln -sf app_process64 app_process
elif [ -e app_process32 ]; then elif [ -e app_process32 ]; then
ln -sf app_process32 app_process ln -sf app_process32 app_process
fi fi
fi fi
rm -rf /system/.pin /system/bin/.ext /system/etc/.installed_su_daemon /system/etc/.has_su_daemon \ # More SuperSU, SuperUser & ROM su
/system/xbin/daemonsu /system/xbin/su /system/xbin/sugote /system/xbin/sugote-mksh /system/xbin/supolicy \ cd ..
/system/bin/app_process_init /system/bin/su /cache/su /system/lib/libsupol.so /system/lib64/libsupol.so \ rm -rf .pin bin/.ext etc/.installed_su_daemon etc/.has_su_daemon \
/system/su.d /system/etc/install-recovery.sh /system/etc/init.d/99SuperSUDaemon /cache/install-recovery.sh \ xbin/daemonsu xbin/su xbin/sugote xbin/sugote-mksh xbin/supolicy \
/system/.supersu /cache/.supersu /data/.supersu \ bin/app_process_init bin/su /cache/su lib/libsupol.so lib64/libsupol.so \
/system/app/Superuser.apk /system/app/SuperSU /cache/Superuser.apk su.d etc/init.d/99SuperSUDaemon etc/install-recovery.sh /cache/install-recovery.sh \
elif [ -f /cache/su.img -o -f /data/su.img -o -d /data/adb/su -o -d /data/su ]; then .supersu /cache/.supersu /data/.supersu \
app/Superuser.apk app/SuperSU /cache/Superuser.apk
elif [ -f /cache/su.img -o -f /data/su.img -o -d /data/su -o -d /data/adb/su ]; then
ui_print "- Removing systemless installed root" ui_print "- Removing systemless installed root"
umount -l /su 2>/dev/null umount -l /su 2>/dev/null
rm -rf /cache/su.img /data/su.img /data/adb/su /data/adb/suhide /data/su /cache/.supersu /data/.supersu \ rm -rf /cache/su.img /data/su.img /data/su /data/adb/su /data/adb/suhide \
/cache/supersu_install /data/supersu_install /cache/.supersu /data/.supersu /cache/supersu_install /data/supersu_install
fi fi
cd $TMPDIR
} }
api_level_arch_detect() { api_level_arch_detect() {