Skip to content

Commit d7ba620

Browse files
committed
Fix artifact directories not having traversal permissions
It turns out that Windows requires the executable bit set if the `BYPASS_TRAVERSE_CHECKING` privilege is not attached to a user's account. It's simply more correct to ensure that our directories have this bit set, and unfortunately our `filemode()` function call is not complete on Windows and does not include this bit, so we manually add it in on Windows.
1 parent e10883c commit d7ba620

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Artifacts.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ function _mv_temp_artifact_dir(temp_dir::String, new_path::String)::Nothing
8484
err = ccall(:jl_fs_rename, Int32, (Cstring, Cstring), temp_dir, new_path)
8585
if err 0
8686
# rename worked
87-
chmod(new_path, filemode(dirname(new_path)))
87+
new_path_mode = filemode(dirname(new_path))
88+
if Sys.iswindows()
89+
# If this is Windows, ensure the directory mode is executable,
90+
# as `filemode()` is incomplete. Some day, that may not be the
91+
# case, there exists a test that will fail if this is changes.
92+
new_path_mode |= 0o001
93+
end
94+
chmod(new_path, new_path_mode)
8895
set_readonly(new_path)
8996
return
9097
else

test/artifacts.jl

+12
Original file line numberDiff line numberDiff line change
@@ -823,4 +823,16 @@ end
823823
end
824824
end
825825

826+
if Sys.iswindows()
827+
@testset "filemode(dir) non-executable on windows" begin
828+
mktempdir() do dir
829+
touch(joinpath(dir, "foo"))
830+
@test !isempty(readdir(dir))
831+
# This technically should be true, the fact that it's not is
832+
# a wrinkle of libuv, it would be nice to fix it and so if we
833+
# do, this test will let us know.
834+
@test filemode(dir) & 0o001 == 0
835+
end
836+
end
837+
end
826838
end # module

0 commit comments

Comments
 (0)