Skip to content

Commit

Permalink
make package cache interit permission from source (#34573)
Browse files Browse the repository at this point in the history
* make package cache interit permission from source

* remove temporary directries
  • Loading branch information
bicycle1885 authored Feb 3, 2020
1 parent 8a08400 commit 5075472
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,8 @@ function compilecache(pkg::PkgId, path::String)
open(cachefile, "a+") do f
write(f, _crc32c(seekstart(f)))
end
# inherit permission from the source file
chmod(cachefile, filemode(path) & 0o777)
elseif p.exitcode == 125
return PrecompilableError()
else
Expand Down
23 changes: 23 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -797,4 +797,27 @@ let
end
end

# Issue #25971
let
load_path = mktempdir()
load_cache_path = mktempdir()
try
pushfirst!(LOAD_PATH, load_path)
pushfirst!(DEPOT_PATH, load_cache_path)
sourcefile = joinpath(load_path, "Foo25971.jl")
write(sourcefile, "module Foo25971 end")
chmod(sourcefile, 0o666)
cachefile = Base.compilecache(Base.PkgId("Foo25971"))
@test filemode(sourcefile) == filemode(cachefile)
chmod(sourcefile, 0o600)
cachefile = Base.compilecache(Base.PkgId("Foo25971"))
@test filemode(sourcefile) == filemode(cachefile)
finally
rm(load_path, recursive=true)
rm(load_cache_path, recursive=true)
filter!(()(load_path), LOAD_PATH)
filter!(()(load_cache_path), DEPOT_PATH)
end
end

end # !withenv

0 comments on commit 5075472

Please sign in to comment.