From 8c394af535623310fbcf1b9f5300b7f39526330b Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 10 Nov 2025 14:45:03 -0500 Subject: [PATCH] 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(). --- asic/src/tofino_common/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/asic/src/tofino_common/mod.rs b/asic/src/tofino_common/mod.rs index 104f91d..be63bec 100644 --- a/asic/src/tofino_common/mod.rs +++ b/asic/src/tofino_common/mod.rs @@ -6,6 +6,7 @@ use std::collections::HashMap; use std::ffi::OsStr; +use std::fs; use std::path::PathBuf; use serde::Deserialize; @@ -240,6 +241,10 @@ fn infer_p4_dir() -> AsicResult { let mut exe_path = std::env::current_exe().map_err(|e| { AsicError::P4Missing(format!("looking up dpd path: {e:?}")) })?; + // Canonicalize the path in case we're using a symlinked exe. + exe_path = fs::canonicalize(exe_path).map_err(|e| { + AsicError::P4Missing(format!("canonicalizing dpd path: {e:?}")) + })?; // Pop off the trailing "dpd": exe_path = expect_name(exe_path, "dpd")?;