Updated find_packages_uid() to compute UID based on user ID and app ID for entries like "user:package".

This commit is contained in:
taamarin
2025-07-10 21:16:54 +07:00
parent 361e4210f5
commit 2dcc4ca30d
5 changed files with 59 additions and 23 deletions

View File

@@ -2,14 +2,12 @@
# allow <interface name>
allow ap+
allow wlan+
# allow wlan1
allow rndis+
allow swlan+
allow ncm+
allow eth+
# -----------------🌼🌼----------------------- #
# Ignore network interface
# Ignore <interface name>
# ignore wlan0
# ignore swlan0
# Ignore specific network interfaces that may conflict with the allowed list
# ignore <interface name>
# ignore swlan+
# ignore wlan+

View File

@@ -1 +1 @@
# cron tasks for root
# This is the system crontab in which scheduled tasks can be defined

View File

@@ -1,8 +1,17 @@
# 黑/白 名单模式;black/white list mode.
# black/white list mode.
mode:blacklist
# 格式/format:
# +----------------+------+
# | User | ID |
# +----------------+------+
# | Owner | 0 |
# | Second Space | 10 |
# | App Clone | 999 |
# +----------------+------+
# package_name ▼
# com.topjohnwu.magisk
# 0:com.termux
# Gid ▼
# 10450 alook
# 99910450 999_alook
# 12345
# 1000

View File

@@ -113,11 +113,32 @@ bin_alive() {
find_packages_uid() {
echo -n "" > "${uid_list}"
for package in "${packages_list[@]}"; do
busybox awk -v p="${package}" '$1~p{print $2}' "${system_packages_file}" >> "${uid_list}"
if [[ "$package" == *:* ]]; then
user="${package%%:*}"
pkg="${package##*:}"
else
user=0
pkg="$package"
fi
appid="$(busybox awk -v p="$pkg" '$1 == p {print $2}' "$system_packages_file")"
if [[ -n "$appid" ]]; then
uid=$((user * 100000 + appid))
echo "$uid" >> "${uid_list}"
fi
done
}
# find_packages_uid() {
# echo -n "" > "${uid_list}"
# for package in "${packages_list[@]}"; do
# busybox awk -v p="${package}" '$1~p{print $2}' "${system_packages_file}" >> "${uid_list}"
# done
# }
probe_user_group() {
if PID=$(busybox pidof ${bin_name}) ; then
box_user=$(stat -c %U /proc/$PID)

View File

@@ -106,16 +106,14 @@ write_listap=$(dirname "$settings")/ap.list.cfg
# allow <interface name>
allow ap+
allow wlan+
# allow wlan1
allow rndis+
allow swlan+
allow ncm+
allow eth+
# -----------------🌼🌼----------------------- #
# Ignore network interface
# Ignore <interface name>
# ignore wlan0
# ignore swlan0
# Ignore specific network interfaces that may conflict with the allowed list
# ignore <interface name>
# ignore swlan+
# ignore wlan+
init
@@ -129,14 +127,23 @@ pkg_config=$(dirname "$settings")/package.list.cfg
# Check pkg config file
[ -d ${pkg_config} ] && rm -rf ${pkg_config}
[ ! -f ${pkg_config} ] && cat > ${pkg_config}<<init
# 黑/白 名单模式;black/white list mode.
mode:whitelist
# 格式/format:
# black/white list mode.
mode:blacklist
# +----------------+------+
# | User | ID |
# +----------------+------+
# | Owner | 0 |
# | Second Space | 10 |
# | App Clone | 999 |
# +----------------+------+
# -----------------🌼🌼----------------------- #
# package_name ▼
# com.topjohnwu.magisk
# com.topjohnwu.magisk # Otherwise, assume the user ID is 0.
# 0:com.termux
# -----------------🌼🌼----------------------- #
# Gid ▼
# 10450 alook
# 99910450 999_alook
# 12345
# 1000
init
# Extract mode, package list and gid list
@@ -147,7 +154,8 @@ init
# Extract mode, package list and gid list
proxy_mode=$(sed -n 's/^mode:\([^ ]*\).*/\1/p' ${pkg_config})
packages_list=($(sed -n '/^[^#]/s/^\([^ ]*\.[^ ]*\).*/\1/p' ${pkg_config}))
gid_list=($(sed -n '/^[^#]/s/^\([0-9]\{1,8\}\).*/\1/p' ${pkg_config}))
# gid_list=($(sed -n '/^[^#]/s/^\([0-9]\{1,8\}\).*/\1/p' ${pkg_config}))
gid_list=($(busybox awk '!/^#/ && /^[0-9]+$/ {print $1}' ${pkg_config}))
notify() {
# eg: notify $title $content