Skip to content

Commit

Permalink
Fix artifact directories not having traversal permissions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
staticfloat committed Nov 5, 2024
1 parent e10883c commit d7ba620
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ function _mv_temp_artifact_dir(temp_dir::String, new_path::String)::Nothing
err = ccall(:jl_fs_rename, Int32, (Cstring, Cstring), temp_dir, new_path)
if err 0
# rename worked
chmod(new_path, filemode(dirname(new_path)))
new_path_mode = filemode(dirname(new_path))
if Sys.iswindows()
# If this is Windows, ensure the directory mode is executable,
# as `filemode()` is incomplete. Some day, that may not be the
# case, there exists a test that will fail if this is changes.
new_path_mode |= 0o001
end
chmod(new_path, new_path_mode)
set_readonly(new_path)
return
else
Expand Down
12 changes: 12 additions & 0 deletions test/artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,16 @@ end
end
end

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

0 comments on commit d7ba620

Please sign in to comment.