Skip to content

Commit 880b9b1

Browse files
bicycle1885KristofferC
authored andcommitted
make package cache interit permission from source (#34573)
* make package cache interit permission from source * remove temporary directries (cherry picked from commit 5075472)
1 parent 9850ec4 commit 880b9b1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

base/loading.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,8 @@ function compilecache(pkg::PkgId, path::String)
12641264
open(cachefile, "a+") do f
12651265
write(f, _crc32c(seekstart(f)))
12661266
end
1267+
# inherit permission from the source file
1268+
chmod(cachefile, filemode(path) & 0o777)
12671269
elseif p.exitcode == 125
12681270
return PrecompilableError()
12691271
else

test/precompile.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,4 +797,27 @@ let
797797
end
798798
end
799799

800+
# Issue #25971
801+
let
802+
load_path = mktempdir()
803+
load_cache_path = mktempdir()
804+
try
805+
pushfirst!(LOAD_PATH, load_path)
806+
pushfirst!(DEPOT_PATH, load_cache_path)
807+
sourcefile = joinpath(load_path, "Foo25971.jl")
808+
write(sourcefile, "module Foo25971 end")
809+
chmod(sourcefile, 0o666)
810+
cachefile = Base.compilecache(Base.PkgId("Foo25971"))
811+
@test filemode(sourcefile) == filemode(cachefile)
812+
chmod(sourcefile, 0o600)
813+
cachefile = Base.compilecache(Base.PkgId("Foo25971"))
814+
@test filemode(sourcefile) == filemode(cachefile)
815+
finally
816+
rm(load_path, recursive=true)
817+
rm(load_cache_path, recursive=true)
818+
filter!(()(load_path), LOAD_PATH)
819+
filter!(()(load_cache_path), DEPOT_PATH)
820+
end
821+
end
822+
800823
end # !withenv

0 commit comments

Comments
 (0)