Skip to content

Commit 34c67cd

Browse files
committed
fix(isolation): validate Unix socket paths the same way on every host
Prior to this change, SandboxTransport::validate checked Unix socket paths with Path::is_absolute(). On Windows that requires a drive or UNC prefix, so a POSIX path such as /run/backend.sock was rejected as "invalid boundary control transport endpoint". The isolation backend registration work in #3898 added tests that register Unix endpoints in the core registration types, gateway config, gateway config preflight, and supervisor backend setup; all of them failed on the Windows MSVC runners. The Windows test job only runs on PRs labeled test:windows, so the break went unnoticed on main. Unix transport is refused at runtime on non-Unix hosts, so these paths are always POSIX paths regardless of where they are validated. Now, both the core registration validator and the sandbox backend protocol validator use a new openshell_core::paths::is_posix_absolute helper, which applies the POSIX rule (the path starts with '/') on every host. On Unix this matches is_absolute() exactly. Signed-off-by: Kris Hicks <khicks@nvidia.com>
1 parent 9a85667 commit 34c67cd

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎crates/openshell-core/src/isolation_registration.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ pub enum SandboxTransport {
3434
impl SandboxTransport {
3535
pub fn validate(&self) -> Result<(), &'static str> {
3636
let valid = match self {
37-
Self::Unix { socket_path } => socket_path.is_absolute(),
37+
// Unix transport only runs on Unix hosts, but validation may not.
38+
Self::Unix { socket_path } => crate::paths::is_posix_absolute(socket_path),
3839
Self::Tcp {
3940
authority,
4041
addresses,

‎crates/openshell-core/src/paths.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ pub fn is_file_permissions_too_open(path: &Path) -> bool {
167167
std::fs::metadata(path).is_ok_and(|m| m.permissions().mode() & 0o077 != 0)
168168
}
169169

170+
/// Whether `path` is absolute under POSIX rules, whatever the host platform.
171+
pub fn is_posix_absolute(path: &Path) -> bool {
172+
path.to_str().is_some_and(|path| path.starts_with('/'))
173+
}
174+
170175
/// Compatibility re-export; authored policy path normalization is owned by
171176
/// `openshell-policy-schema`.
172177
pub use openshell_policy_schema::normalize_path;
@@ -175,6 +180,15 @@ pub use openshell_policy_schema::normalize_path;
175180
mod tests {
176181
use super::*;
177182

183+
#[test]
184+
fn is_posix_absolute_ignores_host_path_syntax() {
185+
assert!(is_posix_absolute(Path::new("/run/backend.sock")));
186+
assert!(is_posix_absolute(Path::new("/")));
187+
for path in ["", "relative", "./run", r"\run", r"C:\run", "C:/run"] {
188+
assert!(!is_posix_absolute(Path::new(path)), "{path}");
189+
}
190+
}
191+
178192
#[test]
179193
fn xdg_config_dir_respects_env() {
180194
// This test checks the logic — actual env var mutation is unsafe so

‎crates/openshell-sandbox-backend/src/boundary_protocol.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl SandboxTransport {
283283
pub fn validate(&self) -> Result<(), &'static str> {
284284
let valid = match self {
285285
Self::Unix { socket_path } | Self::RuntimeInitiatedUnix { socket_path } => {
286-
socket_path.is_absolute()
286+
openshell_core::paths::is_posix_absolute(socket_path)
287287
}
288288
Self::Tcp {
289289
authority,

0 commit comments

Comments
 (0)