Resolve Linux sandbox mode once before launching the helper (#62215)

## Why

Managed proxy routes require bubblewrap's network namespace even when
`features.use_legacy_landlock` is enabled. WSL1 compatibility checks and
helper arguments need to agree on the effective mode.

## What changed

Resolve bubblewrap or legacy Landlock once and use that mode for both the
WSL1 check and the `codex-linux-sandbox` arguments. Use Linux sandbox
naming for the shared launcher and CLI code, and preserve the published
analytics category for a missing helper executable.

## Testing

Unit tests exercise the production argument builder, including managed
network context serialization when legacy Landlock is requested. They
also cover which sandbox configurations WSL1 accepts and rejects.

GitOrigin-RevId: 619ab9d3eef965de6bc6cb13ff8a33132018abcf
This commit is contained in:
viyatb-oai
2026-11-18 07:23:25 +00:00
committed by copyberry
parent ba8ab2d050
commit bcff988bd1
26 changed files with 301 additions and 360 deletions
+2 -4
View File
@@ -38,7 +38,7 @@ use codex_protocol::protocol::FileSystemSandboxEntry;
use codex_protocol::protocol::FileSystemSandboxPolicy;
use codex_protocol::protocol::FileSystemSpecialPath;
use codex_protocol::protocol::NetworkSandboxPolicy;
use codex_sandboxing::landlock::CODEX_LINUX_SANDBOX_ARG0;
use codex_sandboxing::linux::CODEX_LINUX_SANDBOX_ARG0;
static BWRAP_CHILD_PID: AtomicI32 = AtomicI32::new(0);
static PENDING_FORWARDED_SIGNAL: AtomicI32 = AtomicI32::new(0);
@@ -82,9 +82,7 @@ pub struct LinuxSandboxCommand {
)]
pub permission_profile: Option<PermissionProfile>,
/// Opt-in: use the legacy Landlock Linux sandbox fallback.
///
/// When not set, the helper uses the default bubblewrap pipeline.
/// Request legacy Landlock mode. Bubblewrap is the default.
#[arg(long = "use-legacy-landlock", hide = true, default_value_t = false)]
pub use_legacy_landlock: bool,
+1 -1
View File
@@ -5,7 +5,7 @@ use crate::bwrap::BwrapArgs;
use crate::exec_util::make_files_inheritable;
use crate::proxy_lifecycle::move_fd_above_stdio;
use codex_protocol::protocol::FileSystemSandboxPolicy;
use codex_sandboxing::landlock::CODEX_LINUX_SANDBOX_ARG0;
use codex_sandboxing::linux::CODEX_LINUX_SANDBOX_ARG0;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::fs::File;