From ee3829a7787b337b2a7e98251b40d5937b2c255b Mon Sep 17 00:00:00 2001 From: snek Date: Tue, 10 Sep 2024 12:35:41 -0700 Subject: [PATCH] fix: linux canonicalization checks (#24641) --- ext/fs/std_fs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/fs/std_fs.rs b/ext/fs/std_fs.rs index 3cbd154d59..d8d5f65027 100644 --- a/ext/fs/std_fs.rs +++ b/ext/fs/std_fs.rs @@ -1069,8 +1069,10 @@ fn open_with_access_check( }; (*access_check)(false, &path, &options)?; // On Linux, /proc may contain magic links that we don't want to resolve - let needs_canonicalization = !is_windows_device_path - && (!cfg!(target_os = "linux") || path.starts_with("/proc")); + let is_linux_special_path = cfg!(target_os = "linux") + && (path.starts_with("/proc") || path.starts_with("/dev")); + let needs_canonicalization = + !is_windows_device_path && !is_linux_special_path; let path = if needs_canonicalization { match path.canonicalize() { Ok(path) => path,