Exclude unrelated network shares from MXC default reads (#57783)

Default read access on Windows now excludes network shares unless they contain
the policy or command working directory. Skip object-identity probes and
implicit read enumeration for unrelated shares while preserving explicit
read/write grants.

GitOrigin-RevId: 869bacd578989f5348a449277ffbea795494f487
This commit is contained in:
iceweasel-oai
2026-10-28 16:48:02 +00:00
committed by copyberry
parent 5fdb50af95
commit c8bd6c1da9
2 changed files with 5 additions and 5 deletions
+3
View File
@@ -95,6 +95,9 @@ to 4096 bytes; the helper removes them before native process creation. Use
- Windows volume-root grants do not recurse. The adapter grants the root and
its immediate children; directories added or newly mounted during a running
command are not implicitly granted.
- Default read access excludes network shares unrelated to the policy or command
cwd. Explicit read/write grants remain supported. Unrelated shares are not
probed for object identity or enumerated for implicit reads.
- The native API represents paths and environment values as Unicode strings.
Non-Unicode values fail instead of undergoing lossy conversion.
- An empty child environment still uses the Windows user-profile defaults.
+2 -5
View File
@@ -8,8 +8,6 @@ use std::path::PathBuf;
use anyhow::Result;
use anyhow::ensure;
use codex_utils_path_uri::PathUri;
use mxc_sdk::mxc_common::filesystem_object::ExistingObjectComparison;
use mxc_sdk::mxc_common::filesystem_object::compare_existing_filesystem_objects;
use windows_sys::Win32::Foundation::RPC_E_CHANGED_MODE;
use windows_sys::Win32::Storage::FileSystem::GetDriveTypeW;
use windows_sys::Win32::Storage::FileSystem::GetLogicalDrives;
@@ -92,8 +90,8 @@ pub(super) fn volume_roots(
Ok(volumes)
}
// Omit only implicit network roots whose object identity MXC cannot inspect.
// Keep healthy shares and cwd volumes; explicit grants follow the normal path.
// Default reads cover local volumes and cwd shares, not unrelated network shares.
// Explicit grants follow the normal policy path.
pub(super) fn implicit_read_roots(
volume_roots: &[PathBuf],
policy_cwd: &Path,
@@ -111,7 +109,6 @@ pub(super) fn implicit_read_roots(
drive_type != DRIVE_REMOTE
|| policy_cwd.starts_with(root)
|| command_cwd.starts_with(root)
|| compare_existing_filesystem_objects(root, root) == ExistingObjectComparison::Same
})
.map(PathUri::from_host_native_path)
.collect()