Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix: keep local jail temp files inside scratch

Steven Enamakel35b11ad1faba
diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rs
index f1588b6c00..99d134d675 100644
--- a/crates/openhuman-core/src/sandbox/ops.rs
+++ b/crates/openhuman-core/src/sandbox/ops.rs
@@ -406,10 +406,15 @@ async fn execute_local_jail(
}
}
platform_shell::forward_windows_bootstrap_env_std(&mut cmd);
- cmd.env("TMPDIR", &scratch.path);
for (k, v) in extra_env {
cmd.env(k, v);
}
+ // Keep every Windows spelling of the temporary directory inside this
+ // per-call grant. `TEMP`/`TMP` are the variables used by Windows tools;
+ // `TMPDIR` covers Unix-oriented tools running on the same host.
+ cmd.env("TMPDIR", &scratch.path);
+ cmd.env("TEMP", &scratch.path);
+ cmd.env("TMP", &scratch.path);
let os_backend = cwd_jail::default_backend();
let spawn_result = if os_backend.is_available() {
diff --git a/tests/windows_sandbox_env_e2e.rs b/tests/windows_sandbox_env_e2e.rs
index 1dfdfc3799..554f4956c8 100644
--- a/tests/windows_sandbox_env_e2e.rs
+++ b/tests/windows_sandbox_env_e2e.rs
@@ -89,6 +89,15 @@ fn assert_bootstrap_env_resolved(result: &openhuman_core::sandbox::types::Sandbo
"`USERPROFILE` resolved to nothing; stdout {:?}",
result.stdout
);
+ for name in ["TEMP", "PATH"] {
+ assert!(
+ !bracketed(&result.stdout, &format!("{name}="))
+ .unwrap_or_default()
+ .is_empty(),
+ "`{name}` resolved to nothing; stdout {:?}",
+ result.stdout
+ );
+ }
}
#[cfg(windows)]
@@ -122,7 +131,7 @@ async fn sandboxed_child_receives_windows_bootstrap_env() {
#[tokio::test]
async fn node_crypto_runs_through_sandbox_path() {
if !tool_available("node") {
- eprintln!("skipping node_crypto_runs_through_sandbox_path: `node` is not on PATH");
+ eprintln!("test skipped: node_crypto_runs_through_sandbox_path (`node` is not on PATH)");
return;
}
@@ -161,7 +170,9 @@ async fn node_crypto_runs_through_sandbox_path() {
#[tokio::test]
async fn powershell_runs_through_sandbox_path() {
if !tool_available("powershell.exe") {
- eprintln!("skipping powershell_runs_through_sandbox_path: `powershell.exe` is not on PATH");
+ eprintln!(
+ "test skipped: powershell_runs_through_sandbox_path (`powershell.exe` is not on PATH)"
+ );
return;
}