From fe6fd0d5412bdef86cf200d664b37e05a3050966 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Thu, 22 Dec 2022 00:46:55 -0800 Subject: [PATCH] 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). --- lib/std/fs.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 8ae21259ae..573e3b17a8 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1822,6 +1822,9 @@ pub const Dir = struct { .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, .NOT_A_DIRECTORY => return error.NotDir, + // This can happen if the directory has 'List folder contents' permission set to 'Deny' + // and the directory is trying to be opened for iteration. + .ACCESS_DENIED => return error.AccessDenied, .INVALID_PARAMETER => unreachable, else => return w.unexpectedStatus(rc), }