Skip to content

Commit c28ff7f

Browse files
committed
fix(service): respect zip-provided *.conf on first install
Previously init_persistent_config seeded /data/adb/pathmask/*.conf from the zip-bundled .conf files, then immediately re-injected the hardcoded demo defaults (DEFAULT_TARGET_PATH_*, DEFAULT_DENY_PACKAGE_*) via ensure_config_line whenever the .defaults_v1_seeded marker was missing. As a result, users who edited the .conf files inside the zip before flashing still ended up with the demo paths/packages mixed back in on first boot. Make the zip-bundled .conf the single source of truth on first install: drop the marker, the hardcoded constants, and the dedicated seed_target_config / seed_deny_packages_config / ensure_config_line helpers. seed_config_file now handles every conf file uniformly (zip file -> persisted file, fallback to a small typed default for boolean/numeric configs). The runtime fallback that re-added DEFAULT_TARGET_PATH_* when TARGET_PATHS ends up empty is also removed; the existing 'empty target path list' guard already covers that case. Bumps to 2.2.2 / versionCode 13.
1 parent 196fa8e commit c28ff7f

10 files changed

Lines changed: 25 additions & 98 deletions

ksu-module/module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id=pathmask
22
name=PathMask 路径遮罩
3-
version=2.2.1
4-
versionCode=12
3+
version=2.2.2
4+
versionCode=13
55
author=Andrea-lyz
66
description=Android LKM path masking with blacklist, persistent config, WebUI diagnostics and hot reload. 安卓 LKM 路径遮罩,支持黑名单、持久化配置、WebUI 诊断和热重载。

ksu-module/service.sh

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ KO_NAME=pathmask.ko
88
KO_PATH="$MODDIR/$KO_NAME"
99
PERSIST_DIR="/data/adb/pathmask"
1010
LEGACY_PERSIST_DIR="/data/adb/nohello"
11-
DEFAULTS_MARKER="$PERSIST_DIR/.defaults_v1_seeded"
1211
LOAD_FAIL_COUNT_PATH="$PERSIST_DIR/load_fail_count"
1312
LOAD_FAIL_REASON_PATH="$PERSIST_DIR/load_fail_reason"
1413
LOAD_FAIL_LIMIT=3
@@ -29,13 +28,6 @@ DENY_PACKAGES_CONFIG="$PERSIST_DIR/deny_packages.conf"
2928
TARGET_WAIT_SECONDS_CONFIG="$PERSIST_DIR/target_wait_seconds.conf"
3029
PACKAGE_WAIT_SECONDS_CONFIG="$PERSIST_DIR/package_wait_seconds.conf"
3130

32-
DEFAULT_TARGET_PATH_1="/dev/cpuset/scene-daemon"
33-
DEFAULT_TARGET_PATH_2="/dev/scene"
34-
DEFAULT_TARGET_PATH_3="/system_ext/app/SoterService"
35-
DEFAULT_DENY_PACKAGE_1="com.chunqiunativecheck"
36-
DEFAULT_DENY_PACKAGE_2="com.eltavine.duckdetector"
37-
DEFAULT_DENY_PACKAGE_3="luna.safe.luna"
38-
3931
TARGET_PATHS=""
4032
HIDE_DIRENTS=1
4133
SCOPE_MODE=deny
@@ -115,54 +107,6 @@ seed_config_file() {
115107
printf '%s\n' "$DEFAULT_VALUE" > "$DEST"
116108
}
117109

118-
seed_target_config() {
119-
DEST="$1"
120-
SRC="$2"
121-
122-
if [ -f "$DEST" ]; then
123-
return
124-
fi
125-
126-
if [ -f "$SRC" ]; then
127-
cp "$SRC" "$DEST" 2>/dev/null && return
128-
fi
129-
130-
printf '%s\n' \
131-
"$DEFAULT_TARGET_PATH_1" \
132-
"$DEFAULT_TARGET_PATH_2" \
133-
"$DEFAULT_TARGET_PATH_3" > "$DEST"
134-
}
135-
136-
seed_deny_packages_config() {
137-
DEST="$1"
138-
SRC="$2"
139-
140-
if [ -f "$DEST" ]; then
141-
return
142-
fi
143-
144-
if [ -f "$SRC" ]; then
145-
cp "$SRC" "$DEST" 2>/dev/null && return
146-
fi
147-
148-
printf '%s\n' \
149-
"$DEFAULT_DENY_PACKAGE_1" \
150-
"$DEFAULT_DENY_PACKAGE_2" \
151-
"$DEFAULT_DENY_PACKAGE_3" > "$DEST"
152-
}
153-
154-
ensure_config_line() {
155-
DEST="$1"
156-
LINE="$2"
157-
158-
[ -n "$LINE" ] || return
159-
[ -f "$DEST" ] || : > "$DEST"
160-
161-
if ! grep -Fxq "$LINE" "$DEST" 2>/dev/null; then
162-
printf '%s\n' "$LINE" >> "$DEST"
163-
fi
164-
}
165-
166110
migrate_legacy_config() {
167111
[ -d "$PERSIST_DIR" ] && return
168112
[ -d "$LEGACY_PERSIST_DIR" ] || return
@@ -193,26 +137,13 @@ init_persistent_config() {
193137
fi
194138

195139
chmod 0700 "$PERSIST_DIR" 2>/dev/null || true
196-
seed_target_config "$CONFIG_PATH" "$MOD_CONFIG_PATH"
140+
seed_config_file "$CONFIG_PATH" "$MOD_CONFIG_PATH" ""
197141
seed_config_file "$HIDE_DIRENTS_CONFIG" "$MOD_HIDE_DIRENTS_CONFIG" "1"
198142
seed_config_file "$SCOPE_MODE_CONFIG" "$MOD_SCOPE_MODE_CONFIG" "deny"
199143
seed_config_file "$DENY_UIDS_CONFIG" "$MOD_DENY_UIDS_CONFIG" ""
200-
seed_deny_packages_config "$DENY_PACKAGES_CONFIG" "$MOD_DENY_PACKAGES_CONFIG"
144+
seed_config_file "$DENY_PACKAGES_CONFIG" "$MOD_DENY_PACKAGES_CONFIG" ""
201145
seed_config_file "$TARGET_WAIT_SECONDS_CONFIG" "$MOD_TARGET_WAIT_SECONDS_CONFIG" "90"
202146
seed_config_file "$PACKAGE_WAIT_SECONDS_CONFIG" "$MOD_PACKAGE_WAIT_SECONDS_CONFIG" "90"
203-
204-
if [ ! -f "$DEFAULTS_MARKER" ]; then
205-
ensure_config_line "$CONFIG_PATH" "$DEFAULT_TARGET_PATH_1"
206-
ensure_config_line "$CONFIG_PATH" "$DEFAULT_TARGET_PATH_2"
207-
ensure_config_line "$CONFIG_PATH" "$DEFAULT_TARGET_PATH_3"
208-
ensure_config_line "$DENY_PACKAGES_CONFIG" "$DEFAULT_DENY_PACKAGE_1"
209-
ensure_config_line "$DENY_PACKAGES_CONFIG" "$DEFAULT_DENY_PACKAGE_2"
210-
ensure_config_line "$DENY_PACKAGES_CONFIG" "$DEFAULT_DENY_PACKAGE_3"
211-
if [ ! -s "$SCOPE_MODE_CONFIG" ]; then
212-
printf '%s\n' "deny" > "$SCOPE_MODE_CONFIG"
213-
fi
214-
touch "$DEFAULTS_MARKER" 2>/dev/null || true
215-
fi
216147
}
217148

218149
add_target_path() {
@@ -504,12 +435,6 @@ if [ -f "$CONFIG_PATH" ]; then
504435
done < "$CONFIG_PATH"
505436
fi
506437

507-
if [ -z "$TARGET_PATHS" ]; then
508-
add_target_path "$DEFAULT_TARGET_PATH_1"
509-
add_target_path "$DEFAULT_TARGET_PATH_2"
510-
add_target_path "$DEFAULT_TARGET_PATH_3"
511-
fi
512-
513438
if [ -f "$HIDE_DIRENTS_CONFIG" ]; then
514439
HIDE_DIRENTS="$(head -n 1 "$HIDE_DIRENTS_CONFIG" | tr -d '\r')"
515440
fi

update/android12-5.10.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android12-5.10_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android13-5.10.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android13-5.10_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android13-5.15.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android13-5.15_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android14-5.15.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android14-5.15_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android14-6.1.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android14-6.1_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android15-6.6.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android15-6.6_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/android16-6.12.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2.2.1",
3-
"versionCode": 12,
2+
"version": "2.2.2",
3+
"versionCode": 13,
44
"zipUrl": "https://github.com/Andrea-lyz/LKM-PathMask/releases/download/pathmask-latest/android16-6.12_pathmask-ksu.zip",
55
"changelog": "https://raw.githubusercontent.com/Andrea-lyz/LKM-PathMask/main/update/changelog.md"
66
}

update/changelog.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# PathMask 2.2.1
1+
# PathMask 2.2.2
22

3-
- Fix silent reboot on Android GKI kernels with `CONFIG_CFI_CLANG=y` (e.g. OnePlus 11 android13-5.15) caused by Clang CFI checking the indirect call to kprobe-resolved `kern_path` / `path_put`.
4-
- The two indirect call sites are now wrapped in `__nocfi` helpers; the rest of the module retains full CFI coverage. Behaviour on OEM kernels that prune `EXPORT_SYMBOL(kern_path)` / `path_put` is unchanged.
3+
- Fix silent reboot on Android GKI kernels with `CONFIG_CFI_CLANG=y` (e.g. OnePlus 11 android13-5.15) caused by Clang CFI checking the indirect call to kprobe-resolved `kern_path` / `path_put`. The two indirect call sites are now wrapped in `__nocfi` helpers; the rest of the module retains full CFI coverage. Behaviour on OEM kernels that prune `EXPORT_SYMBOL(kern_path)` / `path_put` is unchanged.
4+
- Fix install-time config seed: previously, even if you edited `target_path.conf` / `deny_packages.conf` etc. inside the zip before flashing, the boot script would unconditionally re-add the demo defaults (`/dev/cpuset/scene-daemon`, `com.chunqiunativecheck`, ...) into `/data/adb/pathmask/*.conf`. Now the zip's own `*.conf` files are the single source of truth on first install; subsequent boots leave persisted user config alone.
5+
- Drop the unused `.defaults_v1_seeded` marker and inlined hardcoded defaults from `service.sh`. The WebUI "恢复默认" button still writes its own demo defaults explicitly.
56

67
中文说明:
78

8-
- 修复在 `CONFIG_CFI_CLANG=y` 的 Android GKI 内核(例如一加 11 android13-5.15)上,因 Clang CFI 校验 kprobe 解析后的 `kern_path` / `path_put` 间接调用而导致的静默重启。
9-
- 这两处间接调用改为 `__nocfi` 包装函数,模块其余部分仍保留完整的 CFI 覆盖;对裁剪了 `EXPORT_SYMBOL(kern_path)` / `path_put` 的 OEM 内核行为不变。
9+
- 修复在 `CONFIG_CFI_CLANG=y` 的 Android GKI 内核(例如一加 11 android13-5.15)上,因 Clang CFI 校验 kprobe 解析后的 `kern_path` / `path_put` 间接调用而导致的静默重启。两处间接调用改为 `__nocfi` 包装函数,模块其余部分仍保留完整的 CFI 覆盖;对裁剪了 `EXPORT_SYMBOL(kern_path)` / `path_put` 的 OEM 内核行为不变。
10+
- 修复刷入配置被覆盖的问题:之前即便在刷机前手动改了 zip 内的 `target_path.conf` / `deny_packages.conf` 等,开机脚本仍会无条件把 `/dev/cpuset/scene-daemon``com.chunqiunativecheck` 等示例项追加进 `/data/adb/pathmask/*.conf`。现在以 zip 内的 `*.conf` 为唯一初始来源,之后开机不再回写默认。
11+
- 移除 `service.sh` 中未使用的 `.defaults_v1_seeded` 标记和写死的默认项。WebUI 的"恢复默认"按钮仍能按需写入示例配置。
1012

1113
# PathMask 2.2.0
1214

0 commit comments

Comments
 (0)