Skip to content
Merged
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
4 changes: 3 additions & 1 deletion crates/dim-agent-capabilities/src/host_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3851,6 +3851,7 @@ impl HostPlatform {
}
let root =
std::fs::canonicalize(self.exec_root_path()).unwrap_or_else(|_| self.exec_root_path());
let input_root = self.home.join(".dim").join("exec");
let target = canonicalize_existing_prefix(path)?;
if target == root || !target.starts_with(&root) {
return Err(io::Error::new(
Expand All @@ -3860,7 +3861,8 @@ impl HostPlatform {
}
let mut current = root.clone();
for component in path
.strip_prefix(&root)
.strip_prefix(&input_root)
.or_else(|_| path.strip_prefix(&root))
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "outside the exec root"))?
.components()
{
Expand Down
42 changes: 42 additions & 0 deletions crates/dim-agent-capabilities/tests/host_platform_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,48 @@ async fn output_removal_refuses_traversal_and_links() {
std::fs::remove_dir_all(dir).unwrap();
}

#[cfg(unix)]
#[tokio::test]
async fn remove_output_directory_accepts_a_symlinked_home() {
let dir = std::env::temp_dir().join(unique("dim-host-remove-symlink"));
let home = dir.join("real-home");
std::fs::create_dir_all(&home).unwrap();
let alias = dir.join("alias-home");
std::os::unix::fs::symlink(&home, &alias).unwrap();
let root = rutis::Ctx::root_with(tokio::runtime::Handle::current());
let catalog = dim_agent_capabilities::catalog();
let build = Default::default();
let names = dim_agent_runtime::Names::copy(&catalog, &build);
let _execution = root
.provide(ExecutionSettingsHost::fixed(Default::default()))
.unwrap();
let _toolchain = root.provide(ToolchainSourceHost::fixed(vec![])).unwrap();
let plugin = root.plugin(
HostPlatformPlugin::new(
&names,
HostPlatformConfig {
execution: names.key().unwrap(),
toolchain: names.key().unwrap(),
exec_shell_file: None,
home: Some(alias.clone()),
},
)
.unwrap(),
);
(&plugin).await.unwrap();
let platform = root.get::<HostPlatform>().unwrap();
let output = alias.join(".dim/exec/session/branch");
std::fs::create_dir_all(&output).unwrap();
platform
.remove_output_directory(RemoveOutputDirectoryRequest {
path: path_string(&output),
})
.await
.unwrap();
assert!(!output.exists());
std::fs::remove_dir_all(dir).unwrap();
}

#[tokio::test]
async fn a_shell_burst_completes_without_a_private_subscriber() {
let dir = std::env::temp_dir().join(unique("dim-host-burst"));
Expand Down