From f4ed6274a4c8294cc4804385bc29957f0a73934d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 14 Dec 2021 04:52:15 -0800 Subject: [PATCH] Invert vbmeta header patching config vbmeta header should not be patched in most cases --- native/jni/magiskboot/bootimg.cpp | 2 +- native/jni/magiskboot/main.cpp | 4 ++-- scripts/boot_patch.sh | 6 +++--- scripts/util_functions.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index 3b1d213df..ca090cf1c 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -756,7 +756,7 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) { memcpy(footer, boot.avb_footer, sizeof(AvbFooter)); footer->original_image_size = __builtin_bswap64(off.total); footer->vbmeta_offset = __builtin_bswap64(off.vbmeta); - if (!check_env("KEEPVBMETAFLAG")) { + if (check_env("PATCHVBMETAFLAG")) { vbmeta->flags = __builtin_bswap32(3); } } diff --git a/native/jni/magiskboot/main.cpp b/native/jni/magiskboot/main.cpp index f55b52a5c..b08130e59 100644 --- a/native/jni/magiskboot/main.cpp +++ b/native/jni/magiskboot/main.cpp @@ -35,8 +35,8 @@ Supported actions: If '-n' is provided, it will not attempt to recompress ramdisk.cpio, otherwise it will compress ramdisk.cpio and kernel with the same format as in if the file provided is not already compressed. - All disable flags will be set in the vbmeta header, unless env variable - KEEPVBMETAFLAG is set to true. + If env variable PATCHVBMETAFLAG is set to true, all disable flags will + be set in the vbmeta header. hexpatch Search in , and replace with diff --git a/scripts/boot_patch.sh b/scripts/boot_patch.sh index 721bd9511..ad8885641 100644 --- a/scripts/boot_patch.sh +++ b/scripts/boot_patch.sh @@ -70,11 +70,11 @@ fi # Flags [ -z $KEEPVERITY ] && KEEPVERITY=false [ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false -[ -z $KEEPVBMETAFLAG ] && KEEPVBMETAFLAG=false +[ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false [ -z $RECOVERYMODE ] && RECOVERYMODE=false export KEEPVERITY export KEEPFORCEENCRYPT -export KEEPVBMETAFLAG +export PATCHVBMETAFLAG chmod -R 755 . @@ -151,7 +151,7 @@ ui_print "- Patching ramdisk" echo "KEEPVERITY=$KEEPVERITY" > config echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config -echo "KEEPVBMETAFLAG=$KEEPVBMETAFLAG" >> config +echo "PATCHVBMETAFLAG=$PATCHVBMETAFLAG" >> config echo "RECOVERYMODE=$RECOVERYMODE" >> config [ ! -z $SHA1 ] && echo "SHA1=$SHA1" >> config diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index b1022189b..431065929 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -382,7 +382,7 @@ get_flags() { getvar KEEPVERITY getvar KEEPFORCEENCRYPT getvar RECOVERYMODE - getvar KEEPVBMETAFLAG + getvar PATCHVBMETAFLAG if [ -z $KEEPVERITY ]; then if $SYSTEM_ROOT; then KEEPVERITY=true @@ -403,7 +403,7 @@ get_flags() { KEEPFORCEENCRYPT=false fi fi - [ -z $KEEPVBMETAFLAG ] && KEEPVBMETAFLAG=false + [ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false [ -z $RECOVERYMODE ] && RECOVERYMODE=false }