Skip to content

Commit

Permalink
Tar.extract: slight mode improvement (#98)
Browse files Browse the repository at this point in the history
The reason for using `filemode` to read the created mode was to respect
the umask or equivalent mechanism for default permissions. Since the
umask can only take permissions away, it is always correct to AND the
default permissions with the desired permissions, since that will be
more constrained than both the default and what the tarball requests.
  • Loading branch information
StefanKarpinski authored Apr 9, 2021
1 parent 91a28ed commit 61adcb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function extract_tarball(
copy_symlinks || symlink(hdr.link, sys_path)
elseif hdr.type == :file
read_data(tar, sys_path, size=hdr.size, buf=buf)
mode = Sys.iswindows() ? hdr.mode : filemode(sys_path)
mode = hdr.mode & filemode(sys_path)
if 0o100 & hdr.mode == 0
# turn off all execute bits
mode &= 0o666
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ if Sys.iswindows() && Sys.which("icacls") !== nothing && VERSION >= v"1.6"
x_path = joinpath(dir, "0-xxxxxxxx")
@test isfile(x_path)
@test Sys.isexecutable(x_path)

f_acl = readchomp(`icacls $(f_path)`)
@test occursin("Everyone:(R,WA)", f_acl)
x_acl = readchomp(`icacls $(x_path)`)
Expand Down

0 comments on commit 61adcb8

Please sign in to comment.