Skip to content

Commit d54fd28

Browse files
committed
module: validate module.prop before writing description
Restore module.prop from module.prop.bak if the id field is missing to prevent broken module metadata.
1 parent ba2efb7 commit d54fd28

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

module/module.prop.bak

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
id=KPatch-Next
2+
name=KPatch-Next
3+
version=v0.0.1
4+
versionCode=1
5+
author=rifsxd, KOWX712
6+
description=Standalone implementation of KPM support for Magisk/KernelSU
7+
updateJson=https://raw.githubusercontent.com/KernelSU-Next/KPatch-Next-Module/main/update.json
8+
banner=banner.png

module/status.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ KPNDIR="/data/adb/kp-next"
55
PATH="$MODDIR/bin:$PATH"
66
key="$1"
77

8+
PROP_FILE="$MODDIR/module.prop"
9+
PROP_BAK="$MODDIR/module.prop.bak"
10+
811
set_prop() {
912
local prop="$1"
1013
local value="$2"
@@ -19,6 +22,14 @@ set_prop() {
1922
rm -f "$file.tmp"
2023
}
2124

25+
restore_prop_if_needed() {
26+
if ! grep -q "^id=" "$PROP_FILE"; then
27+
if [ -f "$PROP_BAK" ]; then
28+
cp "$PROP_BAK" "$PROP_FILE"
29+
fi
30+
fi
31+
}
32+
2233
active="Status: active 😊"
2334
inactive="Status: inactive 😕"
2435
info="info: key incorrect, not set or kernel not patched yet ❌"
@@ -36,4 +47,6 @@ if [ -n "$key" ] && kpatch "$key" hello >/dev/null 2>&1; then
3647
string="$active | kpmodule: $KPM_COUNT 💉"
3748
fi
3849

39-
set_prop "description" "$string" "$MODDIR/module.prop"
50+
restore_prop_if_needed
51+
52+
set_prop "description" "$string" "$PROP_FILE"

0 commit comments

Comments
 (0)