Skip to content

Commit d5ebb7c

Browse files
committed
fix: 将默认运行用户改为 root, 并在 TUI 中增加安全提醒
- 之前设置为 shell 用户,网络访问可能受限 - 但我不推荐直接使用 root 用户运行 - 建议更改 run_as_user 为 shell 用户,并在 sub_store.env 中配置代理
1 parent c0f6622 commit d5ebb7c

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎module/action.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ draw_menu() {
8282
echo " [!] SUB_STORE_FRONTEND_BACKEND_PATH 仍为模块默认值"
8383
echo " 建议用下方菜单项重新生成随机路径"
8484
fi
85+
# 安全提醒: 运行用户为 root 时告警
86+
if run_user_is_root; then
87+
echo " [!] 当前运行用户为 root, 建议改为 shell 用户"
88+
echo " 可在 sub_store.config 中修改 run_as_user"
89+
echo " shell 用户如果网络访问受限,可在 sub_store.env 中配置代理"
90+
echo " SUB_STORE_BACKEND_DEFAULT_PROXY=<你的代理软件代理地址>"
91+
fi
8592
echo "---------------------------------------"
8693
echo ""
8794
echo " --- $title ---"

‎module/scripts/lib.sh‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ backend_path_is_default() {
9595
[ "${SUB_STORE_FRONTEND_BACKEND_PATH:-}" = "$DEFAULT_BACKEND_PATH" ]
9696
}
9797

98+
run_user_is_root() {
99+
[ "$run_as_user" != "shell" ] && [ "$run_as_user" != "2000" ]
100+
}
101+
98102
compute_direct_urls() {
99103
if [ "${SUB_STORE_BACKEND_MERGE:-}" = "true" ]; then
100104
# 合并模式: 单端口, 前端带 ?api= 指向后端路径
@@ -166,6 +170,12 @@ print_status_json() {
166170
_backend_path_is_default=false
167171
fi
168172

173+
if run_user_is_root; then
174+
_run_user_is_root=true
175+
else
176+
_run_user_is_root=false
177+
fi
178+
169179
printf '{'
170180
printf '"serviceRunning":%s,' "$_service_running"
171181
printf '"autostart":%s,' "$_autostart"
@@ -175,7 +185,8 @@ print_status_json() {
175185
printf '"frontUrl":"%s",' "$(json_escape "$FRONT_ADDR")"
176186
printf '"backUrl":"%s",' "$(json_escape "$BACK_ADDR")"
177187
printf '"openUrl":"%s",' "$(json_escape "$OPEN_URL")"
178-
printf '"backendPathIsDefault":%s' "$_backend_path_is_default"
188+
printf '"backendPathIsDefault":%s,' "$_backend_path_is_default"
189+
printf '"runUserIsRoot":%s' "$_run_user_is_root"
179190
printf '}\n'
180191
}
181192

‎module/scripts/sub_store.config‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ http_meta_pid_file="${run_path}/http-meta.pid"
2626
# node 默认以低权限 shell (uid 2000) 运行, 不授予多余权限
2727
# 运行目录 (run/) 与 http-meta 目录已由安装脚本自动授权给该用户
2828
# 置空则以 root 运行
29-
run_as_user="shell"
29+
run_as_user="root"

‎module/scripts/sub_store.env‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ SUB_STORE_DATA_BASE_PATH="${run_path}"
2020
# 若仍在使用模块默认值, 执行菜单 (TUI) 会告警, 可用菜单项一键重新生成
2121
SUB_STORE_FRONTEND_BACKEND_PATH="/2cXaAxRGfddmGz2yx1wA"
2222
# 默认代理, 支持 SOCKS5 / HTTP / HTTPS
23+
# shell 用户可能必改
2324
# SUB_STORE_BACKEND_DEFAULT_PROXY="socks5://127.0.0.1:7890"
2425

2526
# ---------- 请求限制 ----------

0 commit comments

Comments
 (0)