mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Fix $RECOVERYMODE from config being incorrectly overridden
Move legacy SAR checking logic into mount_partitions, and avoid calling get_flags before check_boot_ramdisk Fix #7346
This commit is contained in:
parent
f5d3a71478
commit
187f583c95
@ -195,6 +195,9 @@ mount_partitions() {
|
||||
# Check whether non rootfs root dir exists
|
||||
SYSTEM_AS_ROOT=false
|
||||
grep ' / ' /proc/mounts | grep -qv 'rootfs' && SYSTEM_AS_ROOT=true
|
||||
|
||||
LEGACYSAR=false
|
||||
grep ' / ' /proc/mounts | grep -q '/dev/root' && LEGACYSAR=true
|
||||
}
|
||||
|
||||
get_flags() {
|
||||
@ -210,15 +213,6 @@ get_flags() {
|
||||
PATCHVBMETAFLAG=true
|
||||
fi
|
||||
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
|
||||
if $SYSTEM_AS_ROOT; then
|
||||
if grep ' / ' /proc/mounts | grep -q '/dev/root'; then
|
||||
LEGACYSAR=true
|
||||
else
|
||||
LEGACYSAR=false
|
||||
fi
|
||||
else
|
||||
LEGACYSAR=false
|
||||
fi
|
||||
}
|
||||
|
||||
run_migrations() { return; }
|
||||
@ -231,9 +225,9 @@ grep_prop() { return; }
|
||||
|
||||
app_init() {
|
||||
mount_partitions
|
||||
get_flags
|
||||
RAMDISKEXIST=false
|
||||
check_boot_ramdisk && RAMDISKEXIST=true
|
||||
get_flags
|
||||
run_migrations
|
||||
SHA1=$(grep_prop SHA1 $MAGISKTMP/.magisk/config)
|
||||
check_encryption
|
||||
|
@ -279,7 +279,7 @@ mount_ro_ensure() {
|
||||
}
|
||||
|
||||
# After calling this method, the following variables will be set:
|
||||
# SLOT, SYSTEM_AS_ROOT
|
||||
# SLOT, SYSTEM_AS_ROOT, LEGACYSAR
|
||||
mount_partitions() {
|
||||
# Check A/B slot
|
||||
SLOT=$(grep_cmdline androidboot.slot_suffix)
|
||||
@ -313,10 +313,27 @@ mount_partitions() {
|
||||
fi
|
||||
fi
|
||||
$SYSTEM_AS_ROOT && ui_print "- Device is system-as-root"
|
||||
|
||||
LEGACYSAR=false
|
||||
if $BOOTMODE; then
|
||||
grep ' / ' /proc/mounts | grep -q '/dev/root' && LEGACYSAR=true
|
||||
else
|
||||
# Recovery mode, assume devices that don't use dynamic partitions are legacy SAR
|
||||
local IS_DYNAMIC=false
|
||||
if grep -q 'androidboot.super_partition' /proc/cmdline; then
|
||||
IS_DYNAMIC=true
|
||||
elif [ -n "$(find_block super)" ]; then
|
||||
IS_DYNAMIC=true
|
||||
fi
|
||||
if $SYSTEM_AS_ROOT && ! $IS_DYNAMIC; then
|
||||
LEGACYSAR=true
|
||||
ui_print "- Legacy SAR, force kernel to load rootfs"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# After calling this method, the following variables will be set:
|
||||
# ISENCRYPTED, PATCHVBMETAFLAG, LEGACYSAR,
|
||||
# ISENCRYPTED, PATCHVBMETAFLAG,
|
||||
# KEEPVERITY, KEEPFORCEENCRYPT, RECOVERYMODE
|
||||
get_flags() {
|
||||
if grep ' /data ' /proc/mounts | grep -q 'dm-'; then
|
||||
@ -335,22 +352,6 @@ get_flags() {
|
||||
PATCHVBMETAFLAG=true
|
||||
ui_print "- No vbmeta partition, patch vbmeta in boot image"
|
||||
fi
|
||||
LEGACYSAR=false
|
||||
if $BOOTMODE; then
|
||||
grep ' / ' /proc/mounts | grep -q '/dev/root' && LEGACYSAR=true
|
||||
else
|
||||
# Recovery mode, assume devices that don't use dynamic partitions are legacy SAR
|
||||
local IS_DYNAMIC=false
|
||||
if grep -q 'androidboot.super_partition' /proc/cmdline; then
|
||||
IS_DYNAMIC=true
|
||||
elif [ -n "$(find_block super)" ]; then
|
||||
IS_DYNAMIC=true
|
||||
fi
|
||||
if $SYSTEM_AS_ROOT && ! $IS_DYNAMIC; then
|
||||
LEGACYSAR=true
|
||||
ui_print "- Legacy SAR, force kernel to load rootfs"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Overridable config flags with safe defaults
|
||||
getvar KEEPVERITY
|
||||
|
Loading…
Reference in New Issue
Block a user