fix(chv-muse-r12fix2-1): tmpfiles.d 预建 worker 运行时路径(P6-1)

R12 复测钉死的根因:chv-gitea-worker.service 用 ProtectSystem=strict
+ ReadWritePaths=/home/chv/workspace /run/chv-gitea
/var/log/chv-gitea-worker.log,systemd 建 mount namespace 时要求每个
列出路径事先存在,否则 226/NAMESPACE crash-loop(NRestarts=12);
交付镜像里 /run/chv-gitea(/run 是 tmpfs)与
/var/log/chv-gitea-worker.log(worker 首次写审计才建)两处都不存在,
worker 从未起来过。

取舍:只用 tmpfiles.d(/etc/tmpfiles.d/chv.conf,加 d /run/chv-gitea
0700 与 f /var/log/chv-gitea-worker.log 0600,与 P4 的 /run/chv 同款
写法、同一文件)。ExecStartPre 不行——命名空间搭建在任何
ExecStartPre 之前,226 发生在它运行之前;改 ReadWritePaths 为已存在
目录(/var/log)会把写权限放大到整个目录。tmpfiles.d 由
systemd-tmpfiles-setup 在 sysinit 跑、早于 multi-user 的服务启动;
不新增进镜像的文件(chv.conf 本就是 build.sh 内联生成),lockfile
无需登记。unit 文件只加注释说明耦合,不改 ReadWritePaths 本身。

测试:WorkerUnitTmpfilesTest 钉住 ReadWritePaths 每一项挥发路径都有
对应的 tmpfiles 行(类型 + 模式)、P4 四行仍在、unit 无 ExecStartPre。
This commit is contained in:
host committed 2026-11-08 06:00:58 +00:00
1 parent a18a530bfd
commit 35d9c3ff3f
3 files changed
+94 -1

No files matched your search

+14 -1
View File
@@ -388,7 +388,20 @@ VC_ARGS=(-a "$OUT/disk.raw"
# root 所有时 chv-browser 建不了 cdp-broker.sock,broker
# bind 报 PermissionError 而 crash-loop。绝不用 0666/0777
# 那种放宽(与 round-11 authd socket 组权限 0660 同款口径)。
--run-command 'printf "d /run/chv 2775 root chv-browser -\nd /run/chv/shots 0755 chv-browser chv-browser -\nd /run/chv/ask-queue 0750 chv-browser chv-browser -\nd /run/chv-browser 0755 chv-browser chv-browser -\n" > /etc/tmpfiles.d/chv.conf && systemctl enable chv-broker chv-browser chv-cdp-broker || true')
# round-12 修复轮第二轮(项 1,P6):tmpfiles.d 再预建 worker
# 的运行时路径。chv-gitea-worker.service 用 ProtectSystem=strict
# + ReadWritePaths=/home/chv/workspace /run/chv-gitea
# /var/log/chv-gitea-worker.log;systemd 建 mount namespace 时
# 要求每个列出路径事先存在,否则 226/NAMESPACE(R12 复测钉死:
# /run 是 tmpfs、开机不存在;log 文件要 worker 首次写审计才建,
# 而 worker 永远跑不到那一步)。ExecStartPre 救不了——命名空间
# 搭建在任何 ExecStartPre 之前,226 发生在它运行之前;改
# ReadWritePaths 为已存在目录(/var/log)会把写权限放大到整个
# 目录,也不要。tmpfiles.d 由 systemd-tmpfiles-setup 在 sysinit
# 跑、早于 multi-user 的服务启动,且与 P4 的 /run/chv 同款写法,
# 不新增进镜像的文件(chv.conf 本就是 build.sh 内联生成),
# lockfile 无需登记。模式与 worker 审计 0600 同款口径。
--run-command 'printf "d /run/chv 2775 root chv-browser -\nd /run/chv/shots 0755 chv-browser chv-browser -\nd /run/chv/ask-queue 0750 chv-browser chv-browser -\nd /run/chv-browser 0755 chv-browser chv-browser -\nd /run/chv-gitea 0700 root root -\nf /var/log/chv-gitea-worker.log 0600 root root -\n" > /etc/tmpfiles.d/chv.conf && systemctl enable chv-broker chv-browser chv-cdp-broker || true')
# P3 交接(Muse P3 的 authd/sentinel 叶子模块):文件在仓库里存在时
# 拷入镜像(本分支已有,合入后自动生效);不存在时只警告、不失败——
# M4 既定 build.sh 不硬要求 cloud/,见上。缺叶子模块时 chv-authd