Fix fs helper path URI rebase fallout

This commit is contained in:
David Wiesen
2026-06-12 14:29:00 -07:00
parent dc060322c7
commit 82a5089f26
2 changed files with 17 additions and 10 deletions

View File

@@ -85,7 +85,7 @@ impl FileSystemSandboxRunner {
&file_system_policy,
network_policy,
);
let command = self.sandbox_exec_request(&permission_profile, &cwd.uri, sandbox)?;
let command = self.sandbox_exec_request(&permission_profile, &cwd, sandbox)?;
let request_json = serde_json::to_vec(&request).map_err(json_error)?;
run_command(command, request_json).await
}
@@ -93,7 +93,7 @@ impl FileSystemSandboxRunner {
fn sandbox_exec_request(
&self,
permission_profile: &PermissionProfile,
cwd: &PathUri,
cwd: &SandboxCwd,
sandbox_context: &FileSystemSandboxContext,
) -> Result<SandboxExecRequest, JSONRPCErrorError> {
let helper = &self.runtime_paths.codex_self_exe;
@@ -109,7 +109,7 @@ impl FileSystemSandboxRunner {
let command = SandboxCommand {
program: helper.as_path().as_os_str().to_owned(),
args: vec![CODEX_FS_HELPER_ARG1.to_string()],
cwd: cwd.clone(),
cwd: cwd.uri.clone(),
env: self.helper_env.clone(),
additional_permissions: None,
};
@@ -127,7 +127,7 @@ impl FileSystemSandboxRunner {
sandbox,
enforce_managed_network: false,
network: None,
sandbox_policy_cwd: cwd.as_path(),
sandbox_policy_cwd: &cwd.uri,
codex_linux_sandbox_exe: self.runtime_paths.codex_linux_sandbox_exe.as_deref(),
use_legacy_landlock: sandbox_context.use_legacy_landlock,
windows_sandbox_level: sandbox_context.windows_sandbox_level,
@@ -526,15 +526,21 @@ mod tests {
let runner = FileSystemSandboxRunner::new(runtime_paths);
let native_cwd = AbsolutePathBuf::current_dir().expect("cwd");
let cwd = PathUri::from_abs_path(&native_cwd);
let file_system_policy =
restricted_policy(vec![path_entry(native_cwd, FileSystemAccessMode::Write)]);
let file_system_policy = restricted_policy(vec![path_entry(
native_cwd.clone(),
FileSystemAccessMode::Write,
)]);
let network_policy = NetworkSandboxPolicy::Restricted;
let permission_profile =
PermissionProfile::from_runtime_permissions(&file_system_policy, network_policy);
let sandbox_context = sandbox_context_with_cwd(&file_system_policy, cwd.clone());
let sandbox_cwd = SandboxCwd {
uri: cwd,
native: native_cwd,
};
let request = runner
.sandbox_exec_request(&permission_profile, &cwd, &sandbox_context)
.sandbox_exec_request(&permission_profile, &sandbox_cwd, &sandbox_context)
.expect("sandbox exec request");
assert_eq!(request.env.get(&path_key), Some(&path));

View File

@@ -488,10 +488,11 @@ fn transform_for_direct_spawn_windows_materializes_inner_helper() {
let configured_helper = helper_dir.path().join("configured-codex-helper.exe");
std::fs::write(&configured_helper, b"helper").expect("write configured helper");
let cwd = AbsolutePathBuf::from_absolute_path(helper_dir.path()).expect("absolute cwd");
let cwd_uri = PathUri::from_abs_path(&cwd).expect("cwd URI");
let other_workspace = tempfile::TempDir::new().expect("other workspace");
let other_workspace_root = AbsolutePathBuf::from_absolute_path(other_workspace.path())
.expect("absolute other workspace");
let workspace_roots = vec![cwd.clone(), other_workspace_root];
let workspace_roots = vec![cwd, other_workspace_root];
let manager = SandboxManager::new();
let exec_request = manager
.transform_for_direct_spawn(SandboxDirectSpawnTransformRequest {
@@ -500,7 +501,7 @@ fn transform_for_direct_spawn_windows_materializes_inner_helper() {
command: SandboxCommand {
program: configured_helper.as_os_str().to_owned(),
args: vec!["--codex-run-as-fs-helper".to_string()],
cwd: cwd.clone(),
cwd: cwd_uri.clone(),
env: HashMap::from([("Path".to_string(), r"C:\Windows\System32".to_string())]),
additional_permissions: None,
},
@@ -508,7 +509,7 @@ fn transform_for_direct_spawn_windows_materializes_inner_helper() {
sandbox: SandboxType::WindowsRestrictedToken,
enforce_managed_network: false,
network: None,
sandbox_policy_cwd: cwd.as_path(),
sandbox_policy_cwd: &cwd_uri,
codex_linux_sandbox_exe: None,
use_legacy_landlock: false,
windows_sandbox_level: WindowsSandboxLevel::RestrictedToken,