Skip to content

fix: fix old system bubblewrap compatibility without falling back to vendored bwrap#15693

Merged
viyatb-oai merged 25 commits intomainfrom
codex/viyatb/fix-argv0-bubblewrap-fallback
Mar 26, 2026
Merged

fix: fix old system bubblewrap compatibility without falling back to vendored bwrap#15693
viyatb-oai merged 25 commits intomainfrom
codex/viyatb/fix-argv0-bubblewrap-fallback

Conversation

@viyatb-oai
Copy link
Copy Markdown
Collaborator

@viyatb-oai viyatb-oai commented Mar 24, 2026

Fixes #15283.

Summary

Older system bubblewrap builds reject --argv0, which makes our Linux sandbox fail before the helper can re-exec. This PR keeps using system /usr/bin/bwrap whenever it exists and only falls back to vendored bwrap when the system binary is missing. That matters on stricter AppArmor hosts, where the distro bwrap package also provides the policy setup needed for user namespaces.

For old system bwrap, we avoid --argv0 instead of switching binaries:

  • pass the sandbox helper a full-path argv0,
  • keep the existing current_exe() + --argv0 path when the selected launcher supports it,
  • otherwise omit --argv0 and re-exec through the helper's own argv[0] path, whose basename still dispatches as codex-linux-sandbox.

Also updates the launcher/warning tests and docs so they match the new behavior: present-but-old system bwrap uses the compatibility path, and only absent system bwrap falls back to vendored.

Validation

  1. Install Ubuntu 20.04 in a VM
  2. Compile codex and run without bubblewrap installed - see a warning about falling back to the vendored bwrap
  3. Install bwrap and verify version is 0.4.0 without argv0 support
  4. run codex and use apply_patch tool without errors
Screenshot 2026-03-25 at 11 48 36 PM Screenshot 2026-03-25 at 11 47 32 PM Screenshot 2026-03-25 at 11 45 45 PM Screenshot 2026-03-25 at 11 43 56 PM

@viyatb-oai viyatb-oai changed the title Fix old system bubblewrap compatibility without falling back to vendored bwrap fix: fix old system bubblewrap compatibility without falling back to vendored bwrap Mar 24, 2026
@viyatb-oai viyatb-oai force-pushed the codex/viyatb/fix-argv0-bubblewrap-fallback branch from 902dee3 to 3855146 Compare March 24, 2026 22:31
@viyatb-oai viyatb-oai requested a review from bolinfest March 24, 2026 22:36
@viyatb-oai viyatb-oai marked this pull request as ready for review March 24, 2026 22:46
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3855146038

ℹ️ 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".

Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you did get an Ubuntu 20 to test on, can you please update the PR body to explain what you tested?

};
spawn_child_async(SpawnChildRequest {
program: codex_linux_sandbox_exe.as_ref().to_path_buf(),
program: codex_linux_sandbox_exe.to_path_buf(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside the scope of this PR, but I would like to change program to be AsRef<OsStr> instead of String so we don't have to use to_string_lossy() quite so much.

@viyatb-oai viyatb-oai merged commit 937cb50 into main Mar 26, 2026
60 of 62 checks passed
@viyatb-oai viyatb-oai deleted the codex/viyatb/fix-argv0-bubblewrap-fallback branch March 26, 2026 06:51
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandboxed tool calls fail on Ubuntu 20.04 with bubblewrap 0.4.0 ('bwrap: Unknown option --argv0')

3 participants