2025-04-29 19:21:26 -07:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
pub mod landlock;
|
|
|
|
|
pub mod proto;
|
|
|
|
|
pub mod seatbelt;
|
|
|
|
|
|
|
|
|
|
use clap::Parser;
|
2025-05-06 17:38:56 -07:00
|
|
|
use codex_common::SandboxPermissionOption;
|
2025-04-29 19:21:26 -07:00
|
|
|
use codex_core::protocol::SandboxPolicy;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
|
pub struct SeatbeltCommand {
|
|
|
|
|
/// Convenience alias for low-friction sandboxed automatic execution (network-disabled sandbox that can write to cwd and TMPDIR)
|
|
|
|
|
#[arg(long = "full-auto", default_value_t = false)]
|
|
|
|
|
pub full_auto: bool,
|
|
|
|
|
|
|
|
|
|
#[clap(flatten)]
|
|
|
|
|
pub sandbox: SandboxPermissionOption,
|
|
|
|
|
|
|
|
|
|
/// Full command args to run under seatbelt.
|
|
|
|
|
#[arg(trailing_var_arg = true)]
|
|
|
|
|
pub command: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
|
pub struct LandlockCommand {
|
|
|
|
|
/// Convenience alias for low-friction sandboxed automatic execution (network-disabled sandbox that can write to cwd and TMPDIR)
|
|
|
|
|
#[arg(long = "full-auto", default_value_t = false)]
|
|
|
|
|
pub full_auto: bool,
|
|
|
|
|
|
|
|
|
|
#[clap(flatten)]
|
|
|
|
|
pub sandbox: SandboxPermissionOption,
|
|
|
|
|
|
|
|
|
|
/// Full command args to run under landlock.
|
|
|
|
|
#[arg(trailing_var_arg = true)]
|
|
|
|
|
pub command: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn create_sandbox_policy(full_auto: bool, sandbox: SandboxPermissionOption) -> SandboxPolicy {
|
|
|
|
|
if full_auto {
|
|
|
|
|
SandboxPolicy::new_full_auto_policy()
|
|
|
|
|
} else {
|
|
|
|
|
match sandbox.permissions.map(Into::into) {
|
|
|
|
|
Some(sandbox_policy) => sandbox_policy,
|
|
|
|
|
None => SandboxPolicy::new_read_only_policy(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|