Skip to content

Commit

Permalink
Windows extract: always chmod files (JuliaIO#85)
Browse files Browse the repository at this point in the history
This actually changes the logic to be the same on all platforms.
It just happens that on non-Windows platforms files should not be
created with execute bits set; if they are, we'll now handle it
properly, i.e. by turning them off for non-executable files.
  • Loading branch information
StefanKarpinski authored Dec 4, 2020
1 parent 0e9d388 commit 3ff3375
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ function extract_tarball(
elseif hdr.type == :file
read_data(tar, sys_path, size=hdr.size, buf=buf)
# change executable bit if necessary
if Sys.iswindows() !iszero(0o100 & hdr.mode)
tar_exec = !iszero(0o100 & hdr.mode)
sys_exec = Sys.isexecutable(sys_path)
if tar_exec != sys_exec
mode = filemode(sys_path)
if Sys.iswindows()
# turn off all execute bits
mode &= 0o666
else
if tar_exec
# copy read bits to execute bits with
# at least the user execute bit on
mode |= 0o100 | (mode & 0o444) >> 2
else
# turn off all execute bits
mode &= 0o666
end
chmod(sys_path, mode)
end
Expand Down

0 comments on commit 3ff3375

Please sign in to comment.