fix(linux-sandbox): prefer system /usr/bin/bwrap when available#14963
Merged
viyatb-oai merged 16 commits intomainfrom Mar 17, 2026
Merged
fix(linux-sandbox): prefer system /usr/bin/bwrap when available#14963viyatb-oai merged 16 commits intomainfrom
viyatb-oai merged 16 commits intomainfrom
Conversation
bolinfest
reviewed
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a44c08742
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
etraut-openai
requested changes
Mar 17, 2026
bolinfest
reviewed
Mar 17, 2026
etraut-openai
approved these changes
Mar 17, 2026
Collaborator
etraut-openai
left a comment
There was a problem hiding this comment.
I didn't review the sandbox changes (I presume bolinfest did). The error reporting looks good to me now.
bolinfest
approved these changes
Mar 17, 2026
Collaborator
bolinfest
left a comment
There was a problem hiding this comment.
Thanks for jumping on this!
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
Ubuntu/AppArmor hosts started failing in the default Linux sandbox path after the switch to vendored/default bubblewrap in
0.115.0.The clearest report is in #14919, especially this investigation comment: on affected Ubuntu systems,
/usr/bin/bwrapworks, but a copied or vendoredbwrapbinary fails with errors likebwrap: setting up uid map: Permission deniedorbwrap: loopback: Failed RTM_NEWADDR: Operation not permitted.The root cause is Ubuntu's
/etc/apparmor.d/bwrap-userns-restrictprofile, which grantsusernsaccess specifically to/usr/bin/bwrap. Once Codex started using a vendored/internal bubblewrap path, that path was no longer covered by the distro AppArmor exception, so sandbox namespace setup could fail even when user namespaces were otherwise enabled anduidmapwas installed.What this PR changes
/usr/bin/bwrapwhenever it is available/usr/bin/bwrapis missing/usr/bin/bwrapis missing, surface a Codex startup warning through the app-server/TUI warning path instead of printing directly from the sandbox helper witheprintln!/procpreflight pathWhy this fix
This still fixes the Ubuntu/AppArmor regression from #14919, but it keeps the runtime rule simple and platform-agnostic: if the standard system bubblewrap is installed, use it; otherwise fall back to the vendored helper.
The warning now follows that same simple rule. If Codex cannot find
/usr/bin/bwrap, it tells the user that it is falling back to the vendored helper, and it does so through the existing startup warning plumbing that reaches the TUI and app-server instead of low-level sandbox stderr.Testing
cargo test -p codex-linux-sandboxcargo test -p codex-app-server --libcargo test -p codex-tui-app-server tests::embedded_app_server_start_failure_is_returnedcargo clippy -p codex-linux-sandbox --all-targetscargo clippy -p codex-app-server --all-targetscargo clippy -p codex-tui-app-server --all-targets