mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
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:
@@ -41,7 +41,7 @@ use tokio::process::Child;
|
||||
use tokio::process::Command as TokioCommand;
|
||||
use toml::Value as TomlValue;
|
||||
|
||||
use crate::LandlockCommand;
|
||||
use crate::LinuxSandboxCommand;
|
||||
use crate::SeatbeltCommand;
|
||||
use crate::WindowsCommand;
|
||||
use crate::exit_status::handle_exit_status;
|
||||
@@ -97,12 +97,12 @@ pub async fn run_command_under_seatbelt(
|
||||
anyhow::bail!("Seatbelt sandbox is only available on macOS");
|
||||
}
|
||||
|
||||
pub async fn run_command_under_landlock(
|
||||
command: LandlockCommand,
|
||||
pub async fn run_command_under_linux_sandbox(
|
||||
command: LinuxSandboxCommand,
|
||||
codex_linux_sandbox_exe: Option<PathBuf>,
|
||||
loader_overrides: LoaderOverrides,
|
||||
) -> anyhow::Result<()> {
|
||||
let LandlockCommand {
|
||||
let LinuxSandboxCommand {
|
||||
transparent_tcp,
|
||||
sandbox_state,
|
||||
permissions_profile,
|
||||
@@ -127,7 +127,7 @@ pub async fn run_command_under_landlock(
|
||||
command,
|
||||
config_overrides,
|
||||
codex_linux_sandbox_exe,
|
||||
SandboxType::Landlock { transparent_tcp },
|
||||
SandboxType::Linux { transparent_tcp },
|
||||
/*log_denials*/ false,
|
||||
&[],
|
||||
)
|
||||
@@ -173,7 +173,7 @@ pub async fn run_command_under_windows_sandbox(
|
||||
enum SandboxType {
|
||||
#[cfg(target_os = "macos")]
|
||||
Seatbelt,
|
||||
Landlock {
|
||||
Linux {
|
||||
transparent_tcp: bool,
|
||||
},
|
||||
Windows,
|
||||
@@ -310,7 +310,7 @@ async fn run_command_under_sandbox(
|
||||
};
|
||||
|
||||
let transparent_tcp = match sandbox_type {
|
||||
SandboxType::Landlock { transparent_tcp } => {
|
||||
SandboxType::Linux { transparent_tcp } => {
|
||||
transparent_tcp
|
||||
|| config
|
||||
.permissions
|
||||
@@ -330,7 +330,7 @@ async fn run_command_under_sandbox(
|
||||
SandboxEnforcement::Managed => match sandbox_type {
|
||||
#[cfg(target_os = "macos")]
|
||||
SandboxType::Seatbelt => SandboxBackend::MacosSeatbelt,
|
||||
SandboxType::Landlock { .. } => SandboxBackend::LinuxSeccomp,
|
||||
SandboxType::Linux { .. } => SandboxBackend::LinuxSeccomp,
|
||||
#[cfg(windows)]
|
||||
SandboxType::Windows if windows_sandbox_type == WindowsMxc => WindowsMxc,
|
||||
#[cfg(windows)]
|
||||
|
||||
@@ -11,7 +11,7 @@ use codex_utils_cli::CliConfigOverrides;
|
||||
use codex_utils_cli::ProfileV2Name;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub use debug_sandbox::run_command_under_landlock;
|
||||
pub use debug_sandbox::run_command_under_linux_sandbox;
|
||||
pub use debug_sandbox::run_command_under_seatbelt;
|
||||
pub use debug_sandbox::run_command_under_windows_sandbox;
|
||||
pub use git_credential::GitCredentialArgs;
|
||||
@@ -108,7 +108,7 @@ fn parse_absolute_path(raw: &str) -> Result<AbsolutePathBuf, String> {
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct LandlockCommand {
|
||||
pub struct LinuxSandboxCommand {
|
||||
/// Route outbound TCP through the managed SOCKS proxy.
|
||||
#[arg(long)]
|
||||
pub transparent_tcp: bool,
|
||||
|
||||
@@ -487,7 +487,7 @@ enum SandboxSubcommand {
|
||||
#[cfg(target_os = "macos")]
|
||||
type HostSandboxArgs = codex_cli::SeatbeltCommand;
|
||||
#[cfg(target_os = "linux")]
|
||||
type HostSandboxArgs = codex_cli::LandlockCommand;
|
||||
type HostSandboxArgs = codex_cli::LinuxSandboxCommand;
|
||||
#[cfg(target_os = "windows")]
|
||||
type HostSandboxArgs = codex_cli::WindowsCommand;
|
||||
|
||||
@@ -1851,7 +1851,7 @@ async fn dispatch_cli(
|
||||
)
|
||||
.await?;
|
||||
#[cfg(target_os = "linux")]
|
||||
codex_cli::run_command_under_landlock(
|
||||
codex_cli::run_command_under_linux_sandbox(
|
||||
sandbox_cli,
|
||||
arg0_paths.codex_linux_sandbox_exe.clone(),
|
||||
loader_overrides,
|
||||
|
||||
Reference in New Issue
Block a user