Skip to content

Commit 71668fc

Browse files
squeek502andrewrk
authored andcommitted
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 parent 266e2e9 commit 71668fc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/std/fs.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,9 @@ pub const Dir = struct {
17941794
.OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
17951795
.OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
17961796
.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,
17971800
.INVALID_PARAMETER => unreachable,
17981801
else => return w.unexpectedStatus(rc),
17991802
}

0 commit comments

Comments
 (0)