Skip to content

Commit 4459c74

Browse files
committed
chore: canonical exe path before validating.
We validate that the dpd path lives at the expected location on start. However, this check can throw a false positive if we point to the exe via a symlink. This patch canonicalizes the exe path before validating so that we validate the real exe path, which may differ from env::current_exe().
1 parent fa210df commit 4459c74

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

asic/src/tofino_common/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Copyright 2025 Oxide Computer Company
66

7+
use std::fs;
78
use std::collections::HashMap;
89
use std::ffi::OsStr;
910
use std::path::PathBuf;
@@ -240,6 +241,10 @@ fn infer_p4_dir() -> AsicResult<String> {
240241
let mut exe_path = std::env::current_exe().map_err(|e| {
241242
AsicError::P4Missing(format!("looking up dpd path: {e:?}"))
242243
})?;
244+
// Canonicalize the path in case we're using a symlinked exe.
245+
exe_path = fs::canonicalize(exe_path).map_err(|e| {
246+
AsicError::P4Missing(format!("canonicalizing dpd path: {e:?}"))
247+
})?;
243248

244249
// Pop off the trailing "dpd":
245250
exe_path = expect_name(exe_path, "dpd")?;

0 commit comments

Comments
 (0)