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> 2022-12-22 14:03:05-05:00
log71668fc4e3c7963d3cd434888deea4700a5ab27c
tree3fc32a1befbf405d058a1872fb1940ebd2ade717
parent266e2e9a313de6345e459fe8c1fd5f647e9132eb

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
...@@ -1794,6 +1794,9 @@ pub const Dir = struct {...@@ -1794,6 +1794,9 @@ pub const Dir = struct {
1794 .OBJECT_NAME_NOT_FOUND => return error.FileNotFound,1794 .OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
1795 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,1795 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
1796 .NOT_A_DIRECTORY => return error.NotDir,1796 .NOT_A_DIRECTORY => return error.NotDir,
1797 // This can happen if the directory has 'List folder contents' permission set to 'Deny'
1798 // and the directory is trying to be opened for iteration.
1799 .ACCESS_DENIED => return error.AccessDenied,
1797 .INVALID_PARAMETER => unreachable,1800 .INVALID_PARAMETER => unreachable,
1798 else => return w.unexpectedStatus(rc),1801 else => return w.unexpectedStatus(rc),
1799 }1802 }