feat(config): 涉密内容外置到配置目录(档案 140)

把散落在代码里的真实部署值统一收进 config/,代码改为引用配置,
使仓库副本/开源导出不再带出生产域名、IP、内网路径与凭据。

新增 config/:platform.env.example(模板)· load.sh(shell 加载器)·
index.cjs(node 加载器)· README.md(键一览与优先级)。
真实值放 config/platform.env —— 已 .gitignore 排除,不入库、不进导出。

TS 侧新增 src/platform-paths.ts 作部署路径的唯一解析处(零副作用):
platformDir/stateDir/backupDir/artifactDir/installDir/scriptPath。
config.ts 接入这些字段;内置中继种子由生产 URL 改为空(改由
DSHS_OVERLAY_BOOTSTRAP_SEEDS 提供)。修掉 5 处硬编码绝对路径,
src/** 注释中性化 116 行/53 文件。

scripts/** 36 个内部运维脚本:真令牌/PG 口令/隧道目标/主机号/路径
一律改从配置取;web/wake.html 的注册域白名单改为运行时从
location.hostname 推导;test/** 夹具 119 行/13 文件改 RFC 2606/5737
保留值,并把「内置种子必须为空」固化为回归断言。

取证:tsc 0 错;npm test 373/375(唯一失败 lease 属既有);
全仓扫描(大小写不敏感)代码面涉密标识 = 0;已部署 47 并零回归
(/opt/dsh/* 未搬家,/var/lib/dshs/platform 未被误建)。
This commit is contained in:
admin committed 2026-09-19 15:12:19 +08:00
1 parent 9c2e7975ac
commit 452924d89c
100 files changed
+1167 -453

No files matched your search

+7 -6
View File
@@ -1,13 +1,14 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "$0")/.." && pwd)/config/load.sh"
set -euo pipefail
for dir in /var/lib/dshs/users/*/; do
for dir in "$DSH_USERS_DIR"/*/; do
[ -d "$dir" ] || continue
id="$(basename "$dir")"
[ "$id" = . ] && continue
short="$(echo "$id" | tr -d '-' | cut -c1-20)"
user="dsh-$short"
if ! id "$user" &>/dev/null; then
uid="$(node /opt/dshs/lib/cli.js uid-for-user "$id" --db /var/lib/dshs/dshs.db 2>/dev/null || echo 0)"
uid="$(node "$DSH_INSTALL_DIR/lib"/cli.js uid-for-user "$id" --db "$DSH_DB_FILE" 2>/dev/null || echo 0)"
[ "$uid" = 0 ] && { echo "SKIP $id (uid-for-user失败)"; continue; }
# 若该uid已被其他账号占用则跳过
if id "$uid" &>/dev/null; then echo "SKIP $id (uid $uid 已被占用)"; continue; fi
@@ -22,8 +23,8 @@ done
# 2026-09-11 追加(档案 18 v3 收尾):为该批新用户补齐「目录选择器收敛」——
# ① 安装受限插件(逐用户 pnpm add)② 写平台段(cordis.patch.yml,幂等)。
# best-effort:失败不影响上面的账号 provisioning;日志见 journalctl -u dsh-provision。
if [ -f /opt/dshs/poc/workspace-scoped-picker/ensure-workspace-picker.cjs ]; then
node /opt/dshs/poc/workspace-scoped-picker/ensure-workspace-picker.cjs 2>&1 | sed "s/^/[picker] /" || true
if [ -f "$DSH_INSTALL_DIR"/poc/workspace-scoped-picker/ensure-workspace-picker.cjs ]; then
node "$DSH_INSTALL_DIR"/poc/workspace-scoped-picker/ensure-workspace-picker.cjs 2>&1 | sed "s/^/[picker] /" || true
fi
# 2026-09-11 追加:「设置面板 → 用户管理」入口(@dsh-local/portal-entry)全员兜底。
@@ -31,6 +32,6 @@ fi
# 普通用户=仅退出登录)。**普通用户没有它就没有任何退出登录入口**,故必须与新用户
# 注册同步补齐(与上面的 picker 同一时机、同一 best-effort 策略)。
# 幂等:按 node_modules 已装版本 + dep spec 判定,已是最新即跳过。
if [ -f /opt/dshs/scripts/ensure-portal-entry.cjs ]; then
node /opt/dshs/scripts/ensure-portal-entry.cjs 2>&1 | sed "s/^/[portal-entry] /" || true
if [ -f "$DSH_INSTALL_DIR/scripts"/ensure-portal-entry.cjs ]; then
node "$DSH_INSTALL_DIR/scripts"/ensure-portal-entry.cjs 2>&1 | sed "s/^/[portal-entry] /" || true
fi