authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-12-22 00:46:55-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-09 15:10:24-07:00
logfe6fd0d5412bdef86cf200d664b37e05a3050966
tree7b42068b5a5ff8d93e949cca2dbfc535cefbe4ee
parent433709a78864cf65e1686d3178a05605e4c61c66

Dir.openDirAccessMaskW: Add ACCESS_DENIED as a possible error

Can occur when trying to open a directory for iteration but the 'List folder contents' permission of the directory is set to 'Deny'. This was found because it was being triggered during PATH searching in ChildProcess.spawnWindows if a PATH entry did not have 'List folder contents' permission, so this fixes that as well (note: the behavior on hitting this during PATH searching is to treat it as the directory not existing and therefore will fail to find any executables in a directory in the PATH without 'List folder contents' permission; this matches Windows behavior which also fails to find commands in directories that do not have 'List folder contents' permission).

1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/fs.zig+3
......@@ -1822,6 +1822,9 @@ pub const Dir = struct {
18221822 .OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
18231823 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
18241824 .NOT_A_DIRECTORY => return error.NotDir,
1825 // This can happen if the directory has 'List folder contents' permission set to 'Deny'
1826 // and the directory is trying to be opened for iteration.
1827 .ACCESS_DENIED => return error.AccessDenied,
18251828 .INVALID_PARAMETER => unreachable,
18261829 else => return w.unexpectedStatus(rc),
18271830 }