From 50754720d76699fd2863b33f8bb409235b2505f9 Mon Sep 17 00:00:00 2001 From: Kenta Sato Date: Mon, 3 Feb 2020 19:20:51 +0900 Subject: [PATCH] make package cache interit permission from source (#34573) * make package cache interit permission from source * remove temporary directries --- base/loading.jl | 2 ++ test/precompile.jl | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/base/loading.jl b/base/loading.jl index f8771afc58a69..1de844128d547 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -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 diff --git a/test/precompile.jl b/test/precompile.jl index f85704b393aa6..fcedee3098e87 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -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