Skip to content

Commit

Permalink
Invert vbmeta header patching config
Browse files Browse the repository at this point in the history
vbmeta header should not be patched in most cases
  • Loading branch information
topjohnwu committed Dec 14, 2021
1 parent 56eb1a1 commit f4ed627
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion native/jni/magiskboot/bootimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions native/jni/magiskboot/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <origbootimg> 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 <file> <hexpattern1> <hexpattern2>
Search <hexpattern1> in <file>, and replace with <hexpattern2>
Expand Down
6 changes: 3 additions & 3 deletions scripts/boot_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions scripts/util_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -403,7 +403,7 @@ get_flags() {
KEEPFORCEENCRYPT=false
fi
fi
[ -z $KEEPVBMETAFLAG ] && KEEPVBMETAFLAG=false
[ -z $PATCHVBMETAFLAG ] && PATCHVBMETAFLAG=false
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
}

Expand Down

0 comments on commit f4ed627

Please sign in to comment.