Repository navigation
CI 和部署文档适配 Ubuntu 26.04 自带的 bwrap AppArmor profile (#135) - #140
Merged
Merged
Conversation
…ofile 冲突 (#135) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
Ubuntu 26.04 的 apparmor 5.0.2 自带
/etc/apparmor.d/bwrap-userns-restrict:profilebwrap挂在/usr/bin/bwrap上放行 user namespace,子进程叠到bwrap//&unpriv_bwrap。CI 原来又给同一路径挂了一份baize-bwrap,两份冲突(dmesg:info="conflicting profile attachments"),exec 时一份都不用,bwrap 落回 unconfined,建 user namespace 时被转进unprivileged_userns,capable net_admin/setpcap被 DENIED。带--unshare-net报loopback: Failed RTM_NEWADDR,不带报setting up uid map: Permission denied。不是内核 sysctl 本身,也不是 bwrap 版本。实验(临时探针 workflow,已删)
探针 run 42007221495,26.04 runner:Ubuntu 26.04.1、内核 7.0.0-1019-azure、apparmor 5.0.2、bubblewrap 0.11.1、
apparmor_restrict_unprivileged_userns=1。四种参数(--unshare-net、--unshare-all、BWRAP_PROBE_ARGS、--unshare-user --unshare-net)结果一致:bwrap//&unpriv_bwrap (enforce)baize-bwrap (unconfined)capability,network/allow all容器(bookworm + bubblewrap 0.8.0,
seccomp-bwrap.json、apparmor=unconfined,root 和 uid 1000)跟宿主机走:宿主机 profile 按路径也挂得上容器里的/usr/bin/bwrap。第二轮探针 run 42007586554:新 CI 步骤在两个 runner 上都过。26.04 上 bwrap「不加 profile 就能建」,Chrome(
/usr/local/share/chromium/chrome-linux/chrome)不加 profile 以 134 中止,补baize-chrome后通;系统自带的 chrome/chromium profile 挂别的路径,不冲突。24.04 上两个都补了 profile。改了什么
.github/workflows/ci.yml:每个程序先照原样起一次,起不来才补 profile,补完再起,还不通停在这一步。bwrap 用运行器的BWRAP_PROBE_ARGS,探不通时 Linux 上沙箱用例会全跳过,所以这里要和它一致。只放开 bwrap 和 Chrome,不动 sysctl。注释改准。deploy/README.md「AppArmor 与 bwrap 探测」:探测参数对齐BWRAP_PROBE_ARGS;写实测表;以有没有/etc/apparmor.d/bwrap-userns-restrict判断(不看版本号):有就什么都不加,没有(24.04)才加baize-bwrap;升级到带它的版本先apparmor_parser -R并删掉自己那份;改完docker compose restart remote-computer重探。deploy/remote/README.md:探测命令补全参数,宿主机要求指向上面那节。产品代码没改。探测失败时
sandboxKind()是none:每条 bash 都弹审批、批了不进沙箱直接跑;只读例行里 bash 被拒(NO_SANDBOX_REASON);云电脑网页终端不开;relaxIfContained不放宽。启动日志有bubblewrap 起不来(原因)…。这是收紧方向,不需要改。验证
本地:
CI(同一套改动,临时加 push 触发和
pnpm -r --no-bail test看全量):run 42008343335,userns 步骤通过,测试全部真跑:bwrap 沙箱用例在 26.04 上真跑并通过。唯一的失败是
runner.test.ts > 助理浏览器(真 Chrome)> 截图进模型是图片…,Page.captureScreenshot30 秒不回,属 #89,和本线无关;#134 已在 main 上(本分支已 rebase 到它之后)。最终 CI run(本 PR,head 8ed6858,
pnpm format:check && pnpm check):https://github.com/SmartStudio/baize-bot/actions/runs/42012461349 ,结论 failure。/usr/bin/bwrap 不加 profile 就能建 user namespace,/usr/local/share/chromium/chrome-linux/chrome 补了 profile baize-chrome。助理 Chrome 等了 30s 没回 Page.captureScreenshot,src/cdp.ts:132)。pnpm -r在这里停了,后面的包没跑,全量结果看 run 42008343335。这条截图用例在 26.04 上三次都红(42007586647、42008343335、42012461349),#134 合进来之后也红。它不像 #89 说的偶发,更像 26.04 上稳定复现。它和 bwrap、userns 无关,不在本 PR 修,建议另开 issue 跟。
Closes #135
🤖 Generated with Claude Code
https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni