fix: UID resolution in save commands used printf \n escapes instead of real newlines

The shell variable $UIDS accumulated UIDs with literal \n (two chars)
instead of actual newlines. printf "$UIDS" wrote garbage to
/proc/vpnhide_targets and vpnhide_uids.txt. The empty-targets case
used bare > redirect which never triggers the proc write handler.

Fix: accumulate UIDs with real newlines (like service.sh does), use
echo "$UIDS" for output, and echo (writes \n) for the empty case so
the kmod write handler fires and clears the UID list.

Affects: APK target picker, kmod WebUI, zygisk WebUI.
This commit is contained in:
okhsunrog 2026-04-12 03:14:59 +03:00
parent ce1143d2ea
commit c52a6711ff
3 changed files with 28 additions and 16 deletions

View file

@ -295,10 +295,13 @@
const step2 = [
`UIDS=""`,
...selected.map(pkg =>
`U=$(pm list packages -U '${pkg}' 2>/dev/null | grep '^package:${pkg} ' | sed 's/.*uid://') && [ -n "$U" ] && UIDS="$UIDS$U\\n"`
[
`U=$(pm list packages -U '${pkg}' 2>/dev/null | grep '^package:${pkg} ' | sed 's/.*uid://')`,
`if [ -n "$U" ]; then if [ -z "$UIDS" ]; then UIDS="$U"; else UIDS="$UIDS`,
`$U"; fi; fi`,
].join('\n')
),
`printf "$UIDS" > ${PROC_TARGETS} 2>/dev/null`,
`printf "$UIDS" > ${SS_UIDS_FILE}`,
`if [ -n "$UIDS" ]; then echo "$UIDS" > ${PROC_TARGETS} 2>/dev/null; echo "$UIDS" > ${SS_UIDS_FILE}; else echo > ${PROC_TARGETS} 2>/dev/null; echo > ${SS_UIDS_FILE}; fi`,
`chmod 644 ${SS_UIDS_FILE}`,
`chcon u:object_r:system_data_file:s0 ${SS_UIDS_FILE} 2>/dev/null`,
].join(' ; ');