From e8e9603fb12f7080942d1503593b49a34c0cc9d1 Mon Sep 17 00:00:00 2001 From: T-vK Date: Sun, 5 Jul 2026 14:21:04 +0200 Subject: [PATCH] Harden addon.d overlay install validation (v1.1). Verify Magisk's addon.d source exists before copying, abort module installation when the copy fails, document the Magisk-first install requirement, and bump module version to v1.1. --- README.md | 8 ++++--- customize.sh | 60 +++++++++++++++++++++++--------------------------- mSurvival.json | 8 +++---- module.prop | 6 ++--- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index b5473f6..447b460 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ The addon.d script can not be copied into `system/addon.d` since system is mount This module will overlay a copy of the addon.d script into `system/addon.d`.
So it can be found and run with other addon.d script(s) during a system OTA update. -Note: This module only works with addon.d-v2 (A/B slot devices). +Note: This module only works with addon.d-v2 (A/B slot devices).
+Install Magisk before installing this module. ## Warning This module is only systemless before the first OTA update.
@@ -30,13 +31,14 @@ After the first OTA update, this module is no longer needed and can be disabled Available in the releases tab. [Link](https://github.com/mModule/mSurvival/releases) ### Install -- Copy the zip file to the device. +- Install Magisk first (boot patch or recovery zip). +- Copy the module zip file to the device. - Open Magisk, select Modules and then Install from storage. - Reboot device ### Recent changes +- Validate Magisk addon.d source before copy; fail install on copy errors. - Initial release. -- Not planned for long-term support. ### Notes - Feel free to use, change, improve, adapt. diff --git a/customize.sh b/customize.sh index 80bc8ad..3506522 100755 --- a/customize.sh +++ b/customize.sh @@ -1,44 +1,40 @@ #!/system/bin/sh ## Magisk OTA Survival module. -## This module will overlay Magisk's addon.d script into the system/addon.d directory if it exists. -## ipdev @ xda-developers +## Overlays Magisk's addon.d script into system/addon.d when boot-patched installs skip it. -# __ Define variables. __ - -### Magisk variables -## MODPATH (path): the path where your module files should be installed. - -# ADB Directory ADB=/data/adb +MAGISK_ADDON="$ADB/magisk/addon.d.sh" +MODULE_ID=MagiskSurvival +TARGET="$MODPATH/system/addon.d/99-magisk.sh" + +abort_install() { + echo "! $1" >&2 + echo " This module will not be installed." >&2 + rm -rf "$ADB/modules_update/$MODULE_ID" + exit 1 +} -# __ Define functions. __ - -### Magisk functions -## set_perm [context] - -# __ Here we go. __ - -if [ -d /system/addon.d ]; then - # Make the module addon.d directory if it does not exist. - if [ ! -d "$MODPATH"/system/addon.d ]; then - mkdir -p "$MODPATH"/system/addon.d - else - # Remove the previous addon.d script. - rm "$MODPATH"/system/addon.d/99-magisk.sh - fi +if [ ! -d /system/addon.d ]; then + abort_install "Survival (addon.d) scripts are not supported on this ROM." +fi - # Copy the current addon.d script from magisk to the module directory. - cp "$ADB"/magisk/addon.d.sh "$MODPATH"/system/addon.d/99-magisk.sh +if [ ! -f "$MAGISK_ADDON" ]; then + abort_install "Magisk addon.d.sh not found at $MAGISK_ADDON. Install Magisk first." +fi - # Set owner, group, permission and security. - set_perm "$MODPATH"/system/addon.d/99-magisk.sh 0 0 0755 u:object_r:system_file:s0 +if [ ! -d "$MODPATH/system/addon.d" ]; then + mkdir -p "$MODPATH/system/addon.d" else - echo "Survival (addon.d) scripts are not supported." - echo " This module will not be installed." - rm -rf "$ADB"/modules_update/MagiskSurvival - exit 1 + rm -f "$TARGET" fi -# __ Finish and Cleanup. __ +if ! cp "$MAGISK_ADDON" "$TARGET"; then + abort_install "Failed to copy Magisk addon.d script into module overlay." +fi + +if [ ! -f "$TARGET" ]; then + abort_install "addon.d overlay script missing after copy." +fi +set_perm "$TARGET" 0 0 0755 u:object_r:system_file:s0 diff --git a/mSurvival.json b/mSurvival.json index 106ec5c..65d0d5e 100644 --- a/mSurvival.json +++ b/mSurvival.json @@ -1,6 +1,6 @@ { - "versionCode": "10", - "version": "Module (v1)", - "zipUrl": "https://github.com/mModule/mSurvival/releases/download/v1/MagiskSurvival-v1.zip", - "changelog": "https://github.com/mModule/mSurvival/releases/download/v1/v1.md" + "versionCode": "11", + "version": "Module (v1.1)", + "zipUrl": "https://github.com/mModule/mSurvival/releases/download/v1.1/MagiskSurvival-v1.1.zip", + "changelog": "https://github.com/mModule/mSurvival/releases/download/v1.1/v1.1.md" } diff --git a/module.prop b/module.prop index a016f23..09d9d1d 100755 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=MagiskSurvival name=Magisk Survival Script -version=Module (v1) -versionCode=10 +version=Module (v1.1) +versionCode=11 author=ip -description=Magisk Survival (addon.d) script. +description=Magisk Survival (addon.d) script for boot-patched installs. updateJson=https://raw.githubusercontent.com/mModule/mSurvival/master/mSurvival.json