Files
codex-app-server/chv-guest/chv-gitea-worker.service
T
host 35d9c3ff3f 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。
2026-11-08 06:00:58 +00:00

40 lines
1.8 KiB
Desktop File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[Unit]
Description=CHV Gitea sync privsep worker (feat-chv-muse-p6)
After=network-online.target chv-authd.service
Wants=network-online.target
# authd 是可选依赖:worker 的 git 经 P3 helper 向 authd 取凭证;
# authd 没起来时 worker 的 git 调用直接拒绝,不静默用旧凭证。
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/chv-gitea-worker
Restart=on-failure
RestartSec=2
# systemd 沙箱(与 P3 authd 同款 root 单元外服务口径,再收紧):
# 只读系统、独立 /tmp、不许提权、不留 capability、只许 Unix 与
# inet 协议族、只许 @system-service 系统调用、读写路径只限工作区
# 与 worker 运行时目录。网络层强制(eBPF)是 P5 的范围,不在这里
# 冒充——出口收紧靠 Sentinel 评估(authd 放凭证前)+ 只配 helper
# 的 git(见 chv-gitea-worker.py)。
ProtectSystem=strict
PrivateTmp=yes
NoNewPrivileges=yes
CapabilityBoundingSet=
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
SystemCallFilter=@system-service
# ReadWritePaths 下的路径必须在开机时已存在(ProtectSystem=strict
# 下 systemd 建 mount namespace 的硬要求,缺一个即 226/NAMESPACE):
# /run/chv-gitea 与 /var/log/chv-gitea-worker.log 由
# /etc/tmpfiles.d/chv.conf 预建(build.sh 内联写,round-12 修复轮
# 第二轮项 1);/home/chv/workspace 开机时已在(R12 复测的 226
# 只报过前两处)。ExecStartPre 不能替代 tmpfiles.d——命名空间
# 搭建在它之前,226 发生在它运行之前。
ReadWritePaths=/home/chv/workspace /run/chv-gitea /var/log/chv-gitea-worker.log
# worker 崩溃不拖垮 agent:broker/薄 CLI 收到类型化失败即返回,
# 不重试、不挂起;systemd 只负责拉起 worker 本身。
[Install]
WantedBy=multi-user.target