feat(chv-guest): 对齐 Muse P2——nspawn 单元 + broker + 浏览器子代理
- chv-cell:systemd-nspawn 单命令单元,--private-users=1000:65536 (单元 root → 客机 chv),丢 8 项能力(含 SYS_PTRACE/NET_ADMIN), syscall 过滤扣 io_uring,遮蔽 /etc/chv 与 playwright, --network-veth(10.200.0.0/24 + NAT),白名单环境透传 - chv-broker:Unix socket + SO_PEERCRED(uid 范围 + pid ns 对照), 白名单 ping/sync/browser;sync 只调 chv-sync(runuser -u chv) - chv-browser:单元外独立进程,只暴露 open/snapshot/screenshot/ close/ping,返回无障碍树快照(截断);evaluate/content 拒绝 - build.sh:装 systemd-container/iproute2/iptables,拷入三脚本, 建 chv-browser 用户与两个 systemd 单元;vsock_notify 条件拷入 - buildinfo:内容项加 P2 四项,支持可选 extra_contents - 测试:cloud/tests/test_chv_muse_p2.py 40 项全过;broker/browser 真实 socket 回路冒烟通过(root 连 broker 被拒) - 差距表:docs/chv-muse-p2-gap.md;真机验证待测试机空闲(round 11) 本地做,不推、不合、不部署
This commit is contained in:
1 parent
06c3e172fe
commit
c61484aa68
8 files changed
+1826
-9
No files matched your search
+17
-5
@@ -37,6 +37,8 @@ BASE_CONTENTS = [
|
||||
"xz-utils", "fonts-wqy-microhei", "fontconfig", "codex",
|
||||
"codex-code-mode-host", "codex-resources/bwrap",
|
||||
"/app/host.py", "gt", "chv-sync",
|
||||
# 对齐 Muse P2:nspawn 单元启动器 + broker + 浏览器子代理。
|
||||
"systemd-container", "chv-cell", "chv-broker", "chv-browser",
|
||||
]
|
||||
|
||||
# 执行器默认内核 cmdline(config.py),构建产物须与它一起记录(B-12),
|
||||
@@ -67,12 +69,18 @@ def _sha256_size(path):
|
||||
|
||||
|
||||
def build(outdir, tag, ubuntu, codex_version, repo_commit,
|
||||
ubuntu_image_sha256, playwright, chromium_pinned_rev=None):
|
||||
ubuntu_image_sha256, playwright, chromium_pinned_rev=None,
|
||||
extra_contents=None):
|
||||
disk_path = os.path.join(outdir, "disk.raw")
|
||||
vmlinux_path = os.path.join(outdir, "vmlinux")
|
||||
disk_sha, disk_size = _sha256_size(disk_path)
|
||||
vmlinux_sha, vmlinux_size = _sha256_size(vmlinux_path)
|
||||
contents = list(BASE_CONTENTS)
|
||||
# extra_contents:构建时才确定的附加内容(如 P1 的 vsock_notify,
|
||||
# 文件存在才拷入)。调用方传什么记什么,不编默认值。
|
||||
for item in extra_contents or []:
|
||||
if item and item not in contents:
|
||||
contents.append(item)
|
||||
versions = {
|
||||
"dpkg": _read_lines(
|
||||
os.path.join(outdir, "guest-versions-dpkg.txt")),
|
||||
@@ -123,14 +131,18 @@ def build(outdir, tag, ubuntu, codex_version, repo_commit,
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) not in (8, 9):
|
||||
if len(argv) not in (8, 9, 10):
|
||||
print("用法:buildinfo.py OUT TAG UBUNTU CODEX_VERSION "
|
||||
"REPO_COMMIT UBUNTU_IMAGE_SHA256 PLAYWRIGHT "
|
||||
"[CHROMIUM_HEADLESS_SHELL_REV]", file=sys.stderr)
|
||||
"[CHROMIUM_HEADLESS_SHELL_REV] [EXTRA_CONTENTS]", file=sys.stderr)
|
||||
return 2
|
||||
_, outdir, tag, ubuntu, codex_version, repo_commit, \
|
||||
ubuntu_image_sha256, playwright = argv[:8]
|
||||
chromium_pinned_rev = argv[8] if len(argv) == 9 else None
|
||||
chromium_pinned_rev = argv[8] if len(argv) >= 9 else None
|
||||
# 第 10 参数:逗号分隔的附加内容(如 vsock_notify),可空。
|
||||
extra_contents = None
|
||||
if len(argv) == 10 and argv[9]:
|
||||
extra_contents = [s for s in argv[9].split(",") if s]
|
||||
if chromium_pinned_rev and not re.fullmatch(r"[0-9]+",
|
||||
chromium_pinned_rev):
|
||||
print("CHROMIUM_HEADLESS_SHELL_REV 须为纯数字:%s"
|
||||
@@ -138,7 +150,7 @@ def main(argv):
|
||||
return 2
|
||||
info = build(outdir, tag, ubuntu, codex_version, repo_commit,
|
||||
ubuntu_image_sha256, playwright == "1",
|
||||
chromium_pinned_rev)
|
||||
chromium_pinned_rev, extra_contents)
|
||||
if not info["versions"]["dpkg"]:
|
||||
print("BUILDINFO versions.dpkg 为空", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
Reference in new issue
Block a user