Compare commits

...

23 Commits
v26.2 ... v26.3

Author SHA1 Message Date
topjohnwu
5a16418543 Release Magisk v26.3 2023-09-04 00:01:46 -07:00
topjohnwu
7297aba15a Add v26.3 release notes 2023-09-03 23:54:45 -07:00
Ylarod
bc5d5f9502 Update details.md
The `MAGISKTMP` changed to `/debug_ramdisk` since https://github.com/topjohnwu/Magisk/pull/6931
2023-09-03 23:46:25 -07:00
vvb2060
1761986c1b Update zh-rCN translation 2023-09-03 23:43:07 -07:00
topjohnwu
1e034e3e0e Update libsu 2023-09-03 23:41:17 -07:00
topjohnwu
bbf9756bfa Release new canary build 2023-09-02 06:20:10 -07:00
topjohnwu
96e559fb0e Skip cargo build if possible 2023-09-02 06:03:39 -07:00
topjohnwu
4c45775131 Update BusyBox 2023-09-02 05:45:18 -07:00
LoveSy
c072b4254d Wrap rename and renameat 2023-09-02 04:24:24 -07:00
topjohnwu
2dbb812126 Disable stack protector on x86 static executables
Close #7274
2023-09-01 23:04:19 -07:00
topjohnwu
be50f17f55 Update to ONDK r26.0
Close #7264
2023-09-01 23:01:49 -07:00
残页
6f77f190f2 Fix processPayload 2023-08-31 20:30:10 -07:00
topjohnwu
6bdc57cbe4 Release new canary build 2023-08-30 01:22:02 -07:00
残页
de00f1d5a9 Always check mounts to detect legacy SAR on bootmode 2023-08-30 01:02:19 -07:00
残页
e9b9bf987b Fix syntax error in util_functions.sh 2023-08-29 15:33:03 -07:00
topjohnwu
f4b6385f9f Disable boot vbmeta patch when found vbmeta.img 2023-08-28 22:54:55 -07:00
topjohnwu
75d905a56d Fix device detection scripts and logic 2023-08-28 22:13:36 -07:00
topjohnwu
b1363ee479 Do not allow user to configure boot vbmeta patching 2023-08-28 22:13:36 -07:00
topjohnwu
51afe43a30 Cleanup util_functions 2023-08-28 22:13:36 -07:00
残页
189c03c047 Add canyie to developer list 2023-08-28 13:21:58 -07:00
topjohnwu
ae9d270a32 Release new canary build 2023-08-28 01:25:07 -07:00
topjohnwu
e47e869f6b Update full changelog 2023-08-28 01:15:14 -07:00
topjohnwu
c39038a439 Update README 2023-08-28 01:13:25 -07:00
23 changed files with 197 additions and 103 deletions

View File

@@ -19,7 +19,7 @@ Some highlight features:
[Github](https://github.com/topjohnwu/Magisk/) is the only source where you can get official Magisk information and downloads.
[![](https://img.shields.io/badge/Magisk-v26.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v26.1)
[![](https://img.shields.io/badge/Magisk%20Beta-v26.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v26.1)
[![](https://img.shields.io/badge/Magisk%20Beta-v26.2-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v26.2)
[![](https://img.shields.io/badge/Magisk-Canary-red)](https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-release.apk)
[![](https://img.shields.io/badge/Magisk-Debug-red)](https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-debug.apk)

View File

@@ -80,7 +80,7 @@ dependencies {
implementation("dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.2")
implementation("io.noties.markwon:core:4.6.2")
val vLibsu = "5.2.0"
val vLibsu = "5.2.1"
implementation("com.github.topjohnwu.libsu:core:${vLibsu}")
implementation("com.github.topjohnwu.libsu:service:${vLibsu}")
implementation("com.github.topjohnwu.libsu:nio:${vLibsu}")

View File

@@ -114,7 +114,6 @@ object Config : PreferenceConfig, DBConfig {
@JvmField var keepVerity = false
@JvmField var keepEnc = false
@JvmField var patchVbmeta = false
@JvmField var recovery = false
var bootId by preference(Key.BOOT_ID, "")

View File

@@ -1,6 +1,5 @@
package com.topjohnwu.magisk.core
import android.os.Build
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.topjohnwu.magisk.StubApk
@@ -33,13 +32,12 @@ object Info {
@JvmField val isZygiskEnabled = System.getenv("ZYGISK_ENABLED") == "1"
@JvmStatic val isFDE get() = crypto == "block"
@JvmField var ramdisk = false
@JvmField var vbmeta = false
var patchBootVbmeta = false
var crypto = ""
var noDataExec = false
var isRooted = false
@JvmField var hasGMS = true
val isSamsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
@JvmField val isEmulator =
getProperty("ro.kernel.qemu", "0") == "1" ||
getProperty("ro.boot.qemu", "0") == "1"

View File

@@ -218,6 +218,8 @@ abstract class MagiskInstallImpl protected constructor(
ByteBuffer.wrap(rawData).putInt(120, 3)
tarOut.putNextEntry(newTarEntry("vbmeta.img", rawData.size.toLong()))
tarOut.write(rawData)
// vbmeta partition exist, disable boot vbmeta patch
Info.patchBootVbmeta = false
} else if (entry.name.contains("userdata.img")) {
continue
} else {
@@ -320,7 +322,8 @@ abstract class MagiskInstallImpl protected constructor(
val fd = Os.open(fifo.path, O_WRONLY, 0)
try {
val buf = ByteBuffer.allocate(1024 * 1024)
val bufSize = 1024 * 1024
val buf = ByteBuffer.allocate(bufSize)
buf.position(input.read(buf.array()).coerceAtLeast(0)).flip()
while (buf.hasRemaining()) {
try {
@@ -332,6 +335,7 @@ abstract class MagiskInstallImpl protected constructor(
break
}
if (!buf.hasRemaining()) {
buf.limit(bufSize)
buf.position(input.read(buf.array()).coerceAtLeast(0)).flip()
}
}
@@ -490,7 +494,7 @@ abstract class MagiskInstallImpl protected constructor(
"cd $installDir",
"KEEPFORCEENCRYPT=${Config.keepEnc} " +
"KEEPVERITY=${Config.keepVerity} " +
"PATCHVBMETAFLAG=${Config.patchVbmeta} " +
"PATCHVBMETAFLAG=${Info.patchBootVbmeta} " +
"RECOVERYMODE=${Config.recovery} " +
"LEGACYSAR=${Info.legacySAR} " +
"sh boot_patch.sh $srcBoot")

View File

@@ -73,18 +73,17 @@ class ShellInit : Shell.Initializer() {
fun getVar(name: String) = fastCmd("echo \$$name")
fun getBool(name: String) = getVar(name).toBoolean()
Info.isSAR = getBool("SYSTEM_ROOT")
Info.isSAR = getBool("SYSTEM_AS_ROOT")
Info.ramdisk = getBool("RAMDISKEXIST")
Info.vbmeta = getBool("VBMETAEXIST")
Info.isAB = getBool("ISAB")
Info.crypto = getVar("CRYPTOTYPE")
Info.patchBootVbmeta = getBool("PATCHVBMETAFLAG")
Info.legacySAR = getBool("LEGACYSAR")
// Default presets
Config.recovery = getBool("RECOVERYMODE")
Config.keepVerity = getBool("KEEPVERITY")
Config.keepEnc = getBool("KEEPFORCEENCRYPT")
Config.patchVbmeta = getBool("PATCHVBMETAFLAG")
return true
}

View File

@@ -24,6 +24,10 @@ private interface RikkaImpl : Dev {
override val name get() = "RikkaW"
}
private interface CanyieImpl : Dev {
override val name get() = "canyie"
}
sealed class DeveloperItem : Dev {
abstract val items: List<IconLink>
@@ -61,6 +65,14 @@ sealed class DeveloperItem : Dev {
object : IconLink.Github.User(), RikkaImpl {}
)
}
object Canyie : DeveloperItem(), CanyieImpl {
override val items =
listOf<IconLink>(
object : IconLink.Twitter() { override val name = "canyie2977" },
object : IconLink.Github.User(), CanyieImpl {}
)
}
}
sealed class IconLink : RvItem() {

View File

@@ -37,8 +37,7 @@ import java.io.IOException
class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel() {
val isRooted get() = Info.isRooted
val hideVbmeta = Info.vbmeta || Info.isSamsung || Info.isAB
val skipOptions = Info.isEmulator || (Info.isSAR && !Info.isFDE && hideVbmeta && Info.ramdisk)
val skipOptions = Info.isEmulator || (Info.isSAR && !Info.isFDE && Info.ramdisk)
val noSecondSlot = !isRooted || !Info.isAB || Info.isEmulator
@get:Bindable
@@ -105,7 +104,6 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
step,
Config.keepVerity,
Config.keepEnc,
Config.patchVbmeta,
Config.recovery
))
}
@@ -116,7 +114,6 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
step = it.step
Config.keepVerity = it.keepVerity
Config.keepEnc = it.keepEnc
Config.patchVbmeta = it.patchVbmeta
Config.recovery = it.recovery
}
}
@@ -137,7 +134,6 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
val step: Int,
val keepVerity: Boolean,
val keepEnc: Boolean,
val patchVbmeta: Boolean,
val recovery: Boolean,
) : Parcelable

View File

@@ -242,6 +242,14 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50" />
<include
item="@{DeveloperItem.Canyie.INSTANCE}"
layout="@layout/item_developer"
viewModel="@{viewModel}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@@ -108,15 +108,6 @@
android:text="@string/keep_force_encryption"
app:tint="?colorPrimary" />
<CheckBox
style="@style/WidgetFoundation.Checkbox"
gone="@{viewModel.hideVbmeta}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@={Config.patchVbmeta}"
android:text="@string/patch_vbmeta"
app:tint="?colorPrimary" />
<CheckBox
style="@style/WidgetFoundation.Checkbox"
gone="@{Info.ramdisk}"

View File

@@ -193,27 +193,29 @@ check_encryption() {
mount_partitions() {
[ "$(getprop ro.build.ab_update)" = "true" ] && SLOT=$(getprop ro.boot.slot_suffix)
# Check whether non rootfs root dir exists
SYSTEM_ROOT=false
grep ' / ' /proc/mounts | grep -qv 'rootfs' && SYSTEM_ROOT=true
SYSTEM_AS_ROOT=false
grep ' / ' /proc/mounts | grep -qv 'rootfs' && SYSTEM_AS_ROOT=true
}
get_flags() {
KEEPVERITY=$SYSTEM_ROOT
KEEPVERITY=$SYSTEM_AS_ROOT
ISENCRYPTED=false
[ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true
KEEPFORCEENCRYPT=$ISENCRYPTED
VBMETAEXIST=false
if [ -n "$(getprop ro.boot.vbmeta.device)" -o -n "$(getprop ro.boot.vbmeta.size)" ]; then
VBMETAEXIST=true
PATCHVBMETAFLAG=false
elif getprop ro.product.ab_ota_partitions | grep -wq vbmeta; then
VBMETAEXIST=true
PATCHVBMETAFLAG=false
else
PATCHVBMETAFLAG=true
fi
# Preset PATCHVBMETAFLAG to false in the non-root case
PATCHVBMETAFLAG=false
# Make sure RECOVERYMODE has value
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
if grep ' / ' /proc/mounts | grep -q '/dev/root'; then
LEGACYSAR=true
if $SYSTEM_AS_ROOT; then
if grep ' / ' /proc/mounts | grep -q '/dev/root'; then
LEGACYSAR=true
else
LEGACYSAR=false
fi
else
LEGACYSAR=false
fi

View File

@@ -88,6 +88,9 @@
<string name="logs_cleared">日志已清空</string>
<string name="pid">PID: %1$d</string>
<string name="target_uid">目标 UID: %1$d</string>
<string name="target_pid">挂载命名空间目标 PID: %s</string>
<string name="selinux_context">SELinux 上下文: %s</string>
<string name="supp_group">补充组: %s</string>
<!--SafetyNet-->

View File

@@ -259,7 +259,6 @@ def run_cargo(cmds, triple="aarch64-linux-android"):
def run_cargo_build(args):
os.chdir(op.join("native", "src"))
native_out = op.join("..", "out")
mkdir(native_out)
@@ -267,6 +266,9 @@ def run_cargo_build(args):
if "resetprop" in args.target:
targets.add("magisk")
if len(targets) == 0:
return
# Start building the actual build commands
cmds = ["build"]
for target in targets:
@@ -298,8 +300,6 @@ def run_cargo_build(args):
target = op.join(arch_out, f"lib{tgt}-rs.a")
mv(source, target)
os.chdir(op.join("..", ".."))
def run_cargo_cmd(args):
global STDOUT
@@ -382,7 +382,9 @@ def build_binary(args):
header("* Building binaries: " + " ".join(args.target))
os.chdir(op.join("native", "src"))
run_cargo_build(args)
os.chdir(op.join("..", ".."))
dump_flag_header()

View File

@@ -1,5 +1,30 @@
# Magisk Changelog
### v26.3
- [General] Fix device information detection script
- [General] Update BusyBox to 1.36.1
- [General] Update toolchain that produces broken arm32 executables
- [App] Fix root service unable to bind on OnePlus devices
### v26.2
- [MagiskBoot] Support extracting boot image from `payload.bin`
- [MagiskBoot] Support cpio files containing character files
- [MagiskBoot] Support listing cpio content
- [MagiskBoot] Directly handle AVB 1.0 signing and verification without going through Java implementation
- [Daemon] Make daemon socket a fixed path in MAGISKTMP
- [resetprop] Support printing property context
- [resetprop] Support only printing persistent properties from storage
- [resetprop] Properly support setting persistent properties bypassing property_service
- [MagiskSU] Support `-g` and `-G` options
- [MagiskSU] Support switching mount namespace to PID with `-t`
- [MagiskPolicy] Fix patching extended permissions
- [MagiskPolicy] Support more syntax for extended permissions
- [MagiskPolicy] Support printing out the loaded sepolicy rules
- [App] Support patching boot image from ROM zips
- [App] Properly preserve `boot.img` when patching Samsung firmware with `init_boot.img`
### v26.1
- [App] Fix crashing when revoking root permissions

View File

@@ -4,7 +4,7 @@
### Paths in "Magisk tmpfs directory"
Magisk will mount a `tmpfs` directory to store some temporary data. For devices with the `/sbin` folder, it will be chosen as it will also act as an overlay to inject binaries into `PATH`. From Android 11 onwards, the `/sbin` folder might not exist, so Magisk will randomly create a folder under `/dev` and use it as the base folder.
Magisk will mount a `tmpfs` directory to store some temporary data. For devices with the `/sbin` folder, it will be chosen as it will also act as an overlay to inject binaries into `PATH`. From Android 11 onwards, the `/sbin` folder might not exist, so Magisk will use `/debug_ramdisk` as the base folder.
```
# In order to get the current base folder Magisk is using,

28
docs/releases/26300.md Normal file
View File

@@ -0,0 +1,28 @@
## 2023.9.4 Magisk v26.3
### v26.3
- [General] Fix device information detection script
- [General] Update BusyBox to 1.36.1
- [General] Update toolchain that produces broken arm32 executables
- [App] Fix root service unable to bind on OnePlus devices
### v26.2
- [MagiskBoot] Support extracting boot image from `payload.bin`
- [MagiskBoot] Support cpio files containing character files
- [MagiskBoot] Support listing cpio content
- [MagiskBoot] Directly handle AVB 1.0 signing and verification without going through Java implementation
- [Daemon] Make daemon socket a fixed path in MAGISKTMP
- [resetprop] Support printing property context
- [resetprop] Support only printing persistent properties from storage
- [resetprop] Properly support setting persistent properties bypassing property_service
- [MagiskSU] Support `-g` and `-G` options
- [MagiskSU] Support switching mount namespace to PID with `-t`
- [MagiskPolicy] Fix patching extended permissions
- [MagiskPolicy] Support more syntax for extended permissions
- [MagiskPolicy] Support printing out the loaded sepolicy rules
- [App] Support patching boot image from ROM zips
- [App] Properly preserve `boot.img` when patching Samsung firmware with `init_boot.img`
### Full Changelog: [here](https://topjohnwu.github.io/Magisk/changes.html)

View File

@@ -1,5 +1,6 @@
# Release Notes
- [v26.3](26300.md)
- [v26.2](26200.md)
- [v26.1](26100.md)
- [v26.0](26000.md)

View File

@@ -27,5 +27,5 @@ android.nonFinalResIds=false
# Magisk
magisk.stubVersion=37
magisk.versionCode=26200
magisk.ondkVersion=r25.7
magisk.versionCode=26300
magisk.ondkVersion=r26.0

View File

@@ -28,10 +28,13 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcompat
# Add "hacky" libc.a missing symbols back
# All symbols in this library are weak, so a vanilla NDK should still link properly
LOCAL_SRC_FILES := compat/compat.cpp
# Fix static variables' ctor/dtor when using LTO
# See: https://github.com/android/ndk/issues/1461
LOCAL_EXPORT_LDFLAGS := -static -T src/lto_fix.lds
LOCAL_EXPORT_LDFLAGS := -static -T src/lto_fix.lds -Wl,--wrap=rename -Wl,--wrap=renameat
# For some reason, using the hacky libc.a with x86 will trigger stack protection violation
# when mixing Rust and C++ code. Disable stack protector to bypass this issue.
ifeq ($(TARGET_ARCH), x86)
LOCAL_EXPORT_CFLAGS := -fno-stack-protector
endif
include $(BUILD_STATIC_LIBRARY)

View File

@@ -1,8 +1,6 @@
// This file implements all missing symbols that should exist in normal API 23
// libc.a but missing in our extremely lean libc.a replacements.
#if !defined(__LP64__)
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -12,6 +10,11 @@
extern "C" {
#if !defined(__LP64__)
// Add "hacky" libc.a missing symbols back
// All symbols in this file are weak, so a vanilla NDK should still link properly
#include "fortify.hpp"
// Original source: https://github.com/freebsd/freebsd/blob/master/contrib/file/src/getline.c
@@ -111,5 +114,20 @@ extern FILE __sF[];
[[gnu::weak]] FILE* stdout = &__sF[1];
[[gnu::weak]] FILE* stderr = &__sF[2];
#endif // !defined(__LP64__)
[[maybe_unused]]
int __wrap_renameat(int old_dir_fd, const char *old_path, int new_dir_fd, const char *new_path) {
long out = syscall(__NR_renameat, old_dir_fd, old_path, new_dir_fd, new_path);
if (out == -1 && errno == ENOSYS) {
out = syscall(__NR_renameat2, old_dir_fd, old_path, new_dir_fd, new_path, 0);
}
return static_cast<int>(out);
}
[[maybe_unused]]
int __wrap_rename(const char *old_path, const char *new_path) {
return __wrap_renameat(AT_FDCWD, old_path, AT_FDCWD, new_path);
}
} // extern "C"
#endif

View File

@@ -5,7 +5,7 @@
#
# Usage: boot_patch.sh <bootimage>
#
# The following flags can be set in environment variables:
# The following environment variables can configure the installation:
# KEEPVERITY, KEEPFORCEENCRYPT, PATCHVBMETAFLAG, RECOVERYMODE, LEGACYSAR
#
# This script should be placed in a directory with the following files:
@@ -179,7 +179,6 @@ fi
echo "KEEPVERITY=$KEEPVERITY" > config
echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
echo "PATCHVBMETAFLAG=$PATCHVBMETAFLAG" >> config
echo "RECOVERYMODE=$RECOVERYMODE" >> config
if [ -n "$PREINITDEVICE" ]; then
ui_print "- Pre-init storage partition: $PREINITDEVICE"

View File

@@ -112,7 +112,7 @@ setup_flashable() {
$BOOTMODE && return
if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then
# We will have to manually find out OUTFD
for FD in `ls /proc/$$/fd`; do
for FD in $(ls /proc/$$/fd); do
if readlink /proc/$$/fd/$FD | grep -q pipe; then
if ps | grep -v grep | grep -qE " 3 $FD |status_fd=$FD"; then
OUTFD=$FD
@@ -214,7 +214,7 @@ recovery_cleanup() {
find_block() {
local BLOCK DEV DEVICE DEVNAME PARTNAME UEVENT
for BLOCK in "$@"; do
DEVICE=`find /dev/block \( -type b -o -type c -o -type l \) -iname $BLOCK | head -n 1` 2>/dev/null
DEVICE=$(find /dev/block \( -type b -o -type c -o -type l \) -iname $BLOCK | head -n 1) 2>/dev/null
if [ ! -z $DEVICE ]; then
readlink -f $DEVICE
return 0
@@ -222,8 +222,8 @@ find_block() {
done
# Fallback by parsing sysfs uevents
for UEVENT in /sys/dev/block/*/uevent; do
DEVNAME=`grep_prop DEVNAME $UEVENT`
PARTNAME=`grep_prop PARTNAME $UEVENT`
DEVNAME=$(grep_prop DEVNAME $UEVENT)
PARTNAME=$(grep_prop PARTNAME $UEVENT)
for BLOCK in "$@"; do
if [ "$(toupper $BLOCK)" = "$(toupper $PARTNAME)" ]; then
echo /dev/block/$DEVNAME
@@ -233,7 +233,7 @@ find_block() {
done
# Look just in /dev in case we're dealing with MTD/NAND without /dev/block devices/links
for DEV in "$@"; do
DEVICE=`find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname $DEV | head -n 1` 2>/dev/null
DEVICE=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname $DEV | head -n 1) 2>/dev/null
if [ ! -z $DEVICE ]; then
readlink -f $DEVICE
return 0
@@ -278,6 +278,8 @@ mount_ro_ensure() {
is_mounted $POINT || abort "! Cannot mount $POINT"
}
# After calling this method, the following variables will be set:
# SLOT, SYSTEM_AS_ROOT
mount_partitions() {
# Check A/B slot
SLOT=$(grep_cmdline androidboot.slot_suffix)
@@ -295,7 +297,7 @@ mount_partitions() {
fi
mount_ro_ensure "system$SLOT app$SLOT" /system
if [ -f /system/init -o -L /system/init ]; then
SYSTEM_ROOT=true
SYSTEM_AS_ROOT=true
setup_mntpoint /system_root
if ! mount --move /system /system_root; then
umount /system
@@ -304,61 +306,73 @@ mount_partitions() {
fi
mount -o bind /system_root/system /system
else
SYSTEM_ROOT=false
grep ' / ' /proc/mounts | grep -qv 'rootfs' || grep -q ' /system_root ' /proc/mounts && SYSTEM_ROOT=true
if grep ' / ' /proc/mounts | grep -qv 'rootfs' || grep -q ' /system_root ' /proc/mounts; then
SYSTEM_AS_ROOT=true
else
SYSTEM_AS_ROOT=false
fi
fi
$SYSTEM_ROOT && ui_print "- Device is system-as-root"
$SYSTEM_AS_ROOT && ui_print "- Device is system-as-root"
}
# After calling this method, the following variables will be set:
# KEEPVERITY, KEEPFORCEENCRYPT, RECOVERYMODE, PATCHVBMETAFLAG,
# ISENCRYPTED, VBMETAEXIST, LEGACYSAR
# ISENCRYPTED, PATCHVBMETAFLAG, LEGACYSAR,
# KEEPVERITY, KEEPFORCEENCRYPT, RECOVERYMODE
get_flags() {
if grep ' /data ' /proc/mounts | grep -q 'dm-'; then
ISENCRYPTED=true
elif [ "$(getprop ro.crypto.state)" = "encrypted" ]; then
ISENCRYPTED=true
elif [ "$DATA" = "false" ]; then
# No data access means unable to decrypt in recovery
ISENCRYPTED=true
else
ISENCRYPTED=false
fi
if [ -n "$(find_block vbmeta vbmeta_a)" ]; then
PATCHVBMETAFLAG=false
else
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
getvar KEEPFORCEENCRYPT
getvar RECOVERYMODE
getvar PATCHVBMETAFLAG
if [ -z $KEEPVERITY ]; then
if $SYSTEM_ROOT; then
if $SYSTEM_AS_ROOT; then
KEEPVERITY=true
ui_print "- System-as-root, keep dm/avb-verity"
ui_print "- System-as-root, keep dm-verity"
else
KEEPVERITY=false
fi
fi
ISENCRYPTED=false
grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true
[ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true
if [ -z $KEEPFORCEENCRYPT ]; then
# No data access means unable to decrypt in recovery
if $ISENCRYPTED || ! $DATA; then
if $ISENCRYPTED; then
KEEPFORCEENCRYPT=true
ui_print "- Encrypted data, keep forceencrypt"
else
KEEPFORCEENCRYPT=false
fi
fi
VBMETAEXIST=false
local VBMETAIMG=$(find_block vbmeta vbmeta_a)
[ -n "$VBMETAIMG" ] && VBMETAEXIST=true
if [ -z $PATCHVBMETAFLAG ]; then
if $VBMETAEXIST; then
PATCHVBMETAFLAG=false
else
PATCHVBMETAFLAG=true
ui_print "- No vbmeta partition, patch vbmeta in boot image"
fi
fi
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
local IS_DYNAMIC=false
grep -q 'androidboot.super_partition' /proc/cmdline && IS_DYNAMIC=true
[ -b "/dev/block/by-name/super" ] && IS_DYNAMIC=true
if $SYSTEM_ROOT && ! $IS_DYNAMIC; then
LEGACYSAR=true
ui_print "- legacy SAR, force kernel to load rootfs"
else
LEGACYSAR=false
fi
}
find_boot_image() {
@@ -524,7 +538,7 @@ run_migrations() {
# Legacy backup
for gz in /data/stock_boot*.gz; do
[ -f $gz ] || break
LOCSHA1=`basename $gz | sed -e 's/stock_boot_//' -e 's/.img.gz//'`
LOCSHA1=$(basename $gz | sed -e 's/stock_boot_//' -e 's/.img.gz//')
[ -z $LOCSHA1 ] && break
mkdir /data/magisk_backup_${LOCSHA1} 2>/dev/null
mv $gz /data/magisk_backup_${LOCSHA1}/boot.img.gz
@@ -536,7 +550,7 @@ run_migrations() {
BACKUP=$MAGISKBIN/stock_${name}.img
[ -f $BACKUP ] || continue
if [ $name = 'boot' ]; then
LOCSHA1=`$MAGISKBIN/magiskboot sha1 $BACKUP`
LOCSHA1=$($MAGISKBIN/magiskboot sha1 $BACKUP)
mkdir /data/magisk_backup_${LOCSHA1} 2>/dev/null
fi
TARGET=/data/magisk_backup_${LOCSHA1}/${name}.img
@@ -597,14 +611,6 @@ mktouch() {
chmod 644 $1
}
request_size_check() {
reqSizeM=`du -ms "$1" | cut -f1`
}
request_zip_size_check() {
reqSizeM=`unzip -l "$1" | tail -n 1 | awk '{ print int(($1 - 1) / 1048576 + 1) }'`
}
boot_actions() { return; }
# Require ZIPFILE to be set
@@ -638,9 +644,9 @@ install_module() {
local MODDIRNAME=modules
$BOOTMODE && MODDIRNAME=modules_update
local MODULEROOT=$NVBASE/$MODDIRNAME
MODID=`grep_prop id $TMPDIR/module.prop`
MODNAME=`grep_prop name $TMPDIR/module.prop`
MODAUTH=`grep_prop author $TMPDIR/module.prop`
MODID=$(grep_prop id $TMPDIR/module.prop)
MODNAME=$(grep_prop name $TMPDIR/module.prop)
MODAUTH=$(grep_prop author $TMPDIR/module.prop)
MODPATH=$MODULEROOT/$MODID
# Create mod paths