Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/openshell-core/testdata/orin-nvidia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2216,4 +2216,3 @@ containerEdits:
- nodev
- rbind
- rprivate

55 changes: 50 additions & 5 deletions crates/openshell-sandbox/src/boundary_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct LocalBoundaryExec {
ca_file_paths: Option<Arc<(std::path::PathBuf, std::path::PathBuf)>>,
provider_credentials: ProviderCredentialState,
user_environment: HashMap<String, String>,
repair_standard_sbin: bool,
runtime: Arc<crate::boundary_io::BoundaryRuntimeState>,
#[cfg(target_os = "linux")]
launcher: openshell_isolation_interface::linux::workload_launcher::WorkloadLauncher,
Expand All @@ -59,6 +60,7 @@ impl LocalBoundaryExec {
ca_file_paths,
provider_credentials,
user_environment,
repair_standard_sbin: false,
runtime,
#[cfg(target_os = "linux")]
launcher,
Expand Down Expand Up @@ -121,6 +123,13 @@ impl LocalBoundaryExec {
})
}

/// Configure whether workload paths should include the standard sbin directories.
#[must_use]
pub fn with_standard_sbin_path_repair(mut self, enabled: bool) -> Self {
self.repair_standard_sbin = enabled;
self
}

fn command(&self, spec: &ExecSpec) -> Result<Command, BackendError> {
let (program, args) = if let Some(shell_spec) = &spec.shell {
let shell = openshell_core::shell::find_login_shell().ok_or_else(|| {
Expand Down Expand Up @@ -151,12 +160,18 @@ impl LocalBoundaryExec {
if program.is_empty() {
return Err(BackendError::Process("exec program is empty".to_string()));
}
let repair_standard_sbin = self.repair_standard_sbin;
let args = crate::process::process_args_with_standard_sbin_paths(
&program,
&args,
repair_standard_sbin,
);
let mut command = Command::new(&program);
command.args(&args);
command.args(args);
let effective_workdir = spec.workdir.as_deref().or(self.base_workdir.as_deref());
let (session_user, session_home) =
crate::process::session_user_and_home(&self.policy, effective_workdir);
let path = std::env::var("PATH").unwrap_or_else(|_| "/usr/local/bin:/usr/bin:/bin".into());
let path = crate::child_env::child_path_from_env(repair_standard_sbin);
command
.env_clear()
.env(openshell_core::sandbox_env::SANDBOX, "1")
Expand All @@ -169,7 +184,17 @@ impl LocalBoundaryExec {
}
for (key, value) in &self.user_environment {
if !key.starts_with("OPENSHELL_") {
command.env(key, value);
if key == "PATH" {
command.env(
key,
crate::child_env::maybe_path_with_standard_sbin_paths(
value,
repair_standard_sbin,
),
);
} else {
command.env(key, value);
}
}
}
if let Some((ca_cert_path, combined_bundle_path)) = self.ca_file_paths.as_deref() {
Expand All @@ -179,13 +204,33 @@ impl LocalBoundaryExec {
}
for (key, value) in self.provider_credentials.child_env_with_gcp_resolved() {
if !crate::process::is_supervisor_only_env_var(&key) {
command.env(key, value);
if key == "PATH" {
command.env(
key,
crate::child_env::maybe_path_with_standard_sbin_paths(
&value,
repair_standard_sbin,
),
);
} else {
command.env(key, value);
}
}
}
crate::process::strip_proxy_env_std(&mut command);
for (key, value) in &spec.env {
if !key.starts_with("OPENSHELL_") {
command.env(key, value);
if key == "PATH" {
command.env(
key,
crate::child_env::maybe_path_with_standard_sbin_paths(
value,
repair_standard_sbin,
),
);
} else {
command.env(key, value);
}
}
}
if let Some(workdir) = spec.workdir.as_deref().or(self.base_workdir.as_deref()) {
Expand Down
5 changes: 5 additions & 0 deletions crates/openshell-sandbox/src/boundary_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,7 @@ mod linux {
process_id: format!("{}:main:0", self.config.generation),
spec,
policy,
cdi_active: self.config.cdi_context.is_some(),
provider_env_revision,
provider_env,
ca_file_paths,
Expand Down Expand Up @@ -2961,6 +2962,7 @@ mod linux {
process_id: String,
spec: AgentSpecWire,
policy: openshell_core::policy::SandboxPolicy,
cdi_active: bool,
provider_env_revision: u64,
provider_env: std::collections::HashMap<String, String>,
ca_file_paths: Option<(std::path::PathBuf, std::path::PathBuf)>,
Expand Down Expand Up @@ -2995,6 +2997,7 @@ mod linux {
process_id,
spec,
policy,
cdi_active,
provider_env_revision,
provider_env,
ca_file_paths,
Expand All @@ -3015,6 +3018,7 @@ mod linux {
spec.timeout_secs,
spec.interactive,
&policy,
cdi_active,
entrypoint_pid,
provider_credentials.clone(),
provider_env,
Expand Down Expand Up @@ -5327,6 +5331,7 @@ containerEdits:
process_id: "generation-retained:main:0".to_string(),
spec: agent_spec.clone(),
policy,
cdi_active: false,
provider_env_revision: 0,
provider_env: std::collections::HashMap::new(),
ca_file_paths: None,
Expand Down
Loading
Loading