Repository navigation
fix(tmux): 用参数文件承载长沙箱命令,解决 tmux new-session 命令的长度限制 - #1580
Merged
deepcoldy merged 1 commit intoSep 28, 2026
Merged
Conversation
Kerminate
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
September 25, 2026 13:28
Owner
|
你好 @Kerminate,感谢提交 PR!我们已为这个 PR 创建了飞书评审群,自动评审正在进行中。由于你暂时不在我们的自动拉群名单里,麻烦点击下面的一年有效链接自行加入评审群,后续评审意见和沟通都会在群里同步: 也欢迎把 GitHub 账号和飞书信息补充到名单文档中,补好后后续 PR 的评审群会自动把你拉进去:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe 本条为自动流程发出,最终评审结论以维护者审阅为准,谢谢! |
|
🚀 Released in v3.32.0 |
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.
问题背景
Linux 环境启用
sandbox并使用 tmux backend 创建新会话时,BotMux 会将完整的 bwrap 沙箱参数直接拼入tmux new-session命令。当文件系统挂载规则、环境变量和插件配置较多时,整条命令可能超过 tmux 3.3a 的命令解析长度限制,导致会话启动失败:
该问题与用户输入内容本身无关,也不是系统 ARG_MAX 限制,而是 tmux 接收到的启动 argv 过长。
修复方案
针对 Linux + sandbox + tmux + 新会话冷启动 场景,将体积较大的 bwrap options 从 tmux 启动命令中移出:
新的启动命令只包含固定启动器、参数文件路径和 CLI argv,不再包含完整的 bwrap 挂载参数,从而避免触发 tmux 的长度限制。
安全与资源清理
• 参数文件使用独占创建,避免覆盖已有文件。
• 无论进程 umask 如何,最终权限均固定为 0600。
• 启动器读取参数文件后立即删除目录项。
• 如果 tmux 尚未启动便发生失败,sandbox cleanup 会删除遗留参数文件。
• 参数文件创建、权限设置或参数校验失败时,会回滚整个 sandbox setup。
• 包含 NUL 字节的非法参数会被拒绝,避免破坏参数文件格式。
• 不会因紧凑启动失败而回退到非 sandbox 模式。
影响范围
仅改变以下场景的新会话启动方式:
• Linux
• 启用 sandbox
• tmux backend
• 新会话冷启动
以下路径保持原有行为:
• PTY backend
• 未启用 sandbox 的会话
• macOS Seatbelt sandbox
• 已存在 tmux 会话的 reattach/adopt
• 非 tmux persistent backend
测试验证
已覆盖:
• 超过 16 KB 的 bwrap options 不再进入 tmux-facing argv。
• CLI 特殊参数能够逐字节保持。
• 参数文件权限始终为 0600。
• 启动后参数文件已被 unlink。
• 启动失败及非法参数场景能够完整清理 sandbox tree。
• 原有 inline isolation launcher 仍可识别。
• worker 仅为 tmux backend 开启参数文件传输。
• 真实 tmux 3.3a + bwrap 0.8.0 环境下,约 30 KB 的 bwrap options 可以正常启动 CLI。
验证结果:
• 相关单元测试:70 passed
• tmux+bwrap E2E:5 passed
• bun run build:通过
• git diff --check:通过
• 全量单元测试:26,068 passed,2 failed,21 skipped
全量测试中的 2 个失败为既有的 tmux startup-readiness 超时;在未包含本次改动的基线提交上可稳定复现相同结果,与本次修改无关。