Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sys.isexecutable() to use new jl_fs_access() API call #35625

Merged
merged 2 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,11 @@ Change the permissions mode of `path` to `mode`. Only integer `mode`s (e.g. `0o7
currently supported. If `recursive=true` and the path is a directory all permissions in
that directory will be recursively changed.
Return `path`.

!!! note
Prior to Julia 1.5, this did not correctly manipulate filesystem ACLs
on Windows, therefore it would only set read-only bits on files. It
now is able to manipulate ACLs.
"""
function chmod(path::AbstractString, mode::Integer; recursive::Bool=false)
err = ccall(:jl_fs_chmod, Int32, (Cstring, Cint), path, mode)
Expand Down
18 changes: 10 additions & 8 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,18 @@ const WINDOWS_VISTA_VER = v"6.0"
Sys.isexecutable(path::String)

Return `true` if the given `path` has executable permissions.

!!! note
Prior to Julia 1.5, this did not correctly interrogate filesystem
ACLs on Windows, therefore it would return `true` for any
file. From Julia 1.5 on, it correctly determines whether the
file is marked as executable or not.
"""
function isexecutable(path::String)
if iswindows()
return isfile(path)
else
# We use `access()` and `X_OK` to determine if a given path is
# executable by the current user. `X_OK` comes from `unistd.h`.
X_OK = 0x01
ccall(:access, Cint, (Ptr{UInt8}, Cint), path, X_OK) == 0
end
# We use `access()` and `X_OK` to determine if a given path is
# executable by the current user. `X_OK` comes from `unistd.h`.
X_OK = 0x01
return ccall(:jl_fs_access, Cint, (Ptr{UInt8}, Cint), path, X_OK) == 0
end
isexecutable(path::AbstractString) = isexecutable(String(path))

Expand Down
2 changes: 1 addition & 1 deletion deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CURL_BB_REL = 1
LIBGIT2_VER = 0.28.2
LIBGIT2_BB_REL = 1
LIBUV_VER = 1.29.1
LIBUV_BB_REL = 0
LIBUV_BB_REL = 6
OBJCONV_VER = 2.49.0
OBJCONV_BB_REL = 0
ZLIB_VER = 1.2.11
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.aarch64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
39acc875b0e8269b80b707a36cb90c16
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
55d6dbf38a74fe90c09ea3ec6146e2d2ca020a328f4082a01be57a95c5a4e2edff6f89f723afe193ff38e70cd6dca8743c1351ca93439dc5ca19c92dbb3d6a3c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
486bd513ec1ea3eda329f7a45ba116e0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1d7fd3e31ed5d6d0829e2fccc70f413468b2d5ea2385b3ee33ba93c935f923af4f1dec61b6876fe81f0f8c8dfd2bec08002c6e4676b5301aa89f872c072fe5c7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
156e644f6bc1a32650e092a41a0794ae
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6b03f9b24e9da9e291af36c35b2049ae5051458535685bda6605a4391627e090d718020b999756610722edffb1f153a775b4504b3dc5a956d9a8264307b8c818
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0b5d7b21dfa71d4082e078f07f2e1587
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8cf244cf37fd457fb4f9e88a6a1d1ba33b77fd756897cb934cf5e0571a7dff653b97bd5a9d2aa6f0d9eef3bf10985fe9cf0c0b079043fcc8399ab09b7e5d4a31
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.i686-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4d51dac4b8905b09ba36ac22d038a0da
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.i686-linux-gnu.tar.gz/sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
38cc0c45dd1880c4a96e97b93a60017bf4acbd248f750d55489e4b46188586c3866fb7306b35767ffe4a10586bf07a71901e195fc90b33ceacbdbafe9a56f817
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.i686-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f14ee38bd7070a0c546bf3ec3b528f0e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1c3b8b74cf47d43916bec77ce839c2e3b2ac7859e5634eedfb380175eba769477c01d50aa57a124d8fe39956fcb213fe76e51dcca0129b9f0039ffa1a0aacf3
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.i686-w64-mingw32.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5345c7515926900dda116bd5280bfaf8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8159b2ddd098e37663968dec2ff6777056bbf1721593589a1bd3b9fa1eaf00ab5dbcb8ca53eb944d40ac0626603bb291f311ca336fe95968a95655421331cbaa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcae5c53fe3cf5a25e97d2de0838a016
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
525873794c7e37417773a27e1070ffbbf4193dd2da4a0be52b2d07e499da3996a4ecb8967e7e4483a775d2d4cffddc1977874cae24f98b9d5d92fa9bc3efa247
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
86b2bea0affa619bb4b9149493e8bb26
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd766d12883a8550666830f93cd6ac810ae70ac0e19dc3a595d35686c8b9c012f16b7a5dcf665d79cd962bad80a2beecc92dca508ddc487de28e35813f087d91
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.x86_64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
61e04131c92278db16f6a63eeb5769bc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0d9cbfe6eb98817d1f0ca6a8e09fdc933a8da8cfb0ad28085d7daab62e20e81fb7599cdf7954e1d6f924f97a38136797ff722f6a5c144ea307dac16a1ccde69c
1 change: 1 addition & 0 deletions deps/checksums/LibUV.v2.0.0-6.x86_64-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
77b078df21b4bc5a2a8ec35815f3e041
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
72f09dc03f5622da078adcd48ebc3b339fa76523ff855ba92e1f7d06f70c27868295f6db23f4968df7bdb2a0fc85a5fc3fa4246ce28b4d735e491164594520ff
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e0894abaa5e009c303e210bcdfe6fc30
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9e71ccdfca0d816fc6ed13da3d0fe3dba1d5643a6da9eb84088548ba6430beb12029539ad52b838a7a14098f8f59090ec0407b61382e2fcd2488adf12c587f23
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
94ec0ba6af4be3e951c76d8466d5f36f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
891bbed5d5f581d49426b1f9dae19a943ba645f38c723626249ad3cb62cb13541f25e11ab29735dd820d5c9468bb24c1d33c87674288d7015c1c37e1407cee63

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
751c4bf387545de19fe6334dd296e66e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a6f5d52f49d209b4cfd93d2af2a67712cee5fa4c97185b923ec07db31b390300caeb186aa4110ab02d3863fb544edc611e3f77b2d52b6d340c3e40483d4132bc
4 changes: 2 additions & 2 deletions deps/libuv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ fastcheck-libuv: #none
check-libuv: $(LIBUV_BUILDDIR)/build-checked

else # USE_BINARYBUILDER_LIBUV
LIBUV_BB_URL_BASE := https://github.com/JuliaPackaging/Yggdrasil/releases/download/LibUV-v2+$(LIBUV_VER)-julia+$(LIBUV_BB_REL)
LIBUV_BB_NAME := LibUV.v2.0.0+$(LIBUV_VER)-julia
LIBUV_BB_URL_BASE := https://github.com/JuliaBinaryWrappers/LibUV_jll.jl/releases/download/LibUV-v2.0.0+$(LIBUV_BB_REL)
LIBUV_BB_NAME := LibUV.v2.0.0

$(eval $(call bb-install,libuv,LIBUV,false))
endif
2 changes: 1 addition & 1 deletion deps/libuv.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LIBUV_BRANCH=julia-uv2-1.29.1
LIBUV_SHA1=35b1504507a7a4168caae3d78db54d1121b121e1
LIBUV_SHA1=4726f5ef94fe5e11335a6d6ef048b00a72110135
8 changes: 8 additions & 0 deletions src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ JL_DLLEXPORT int jl_fs_chown(char *path, int uid, int gid)
return ret;
}

JL_DLLEXPORT int jl_fs_access(char *path, int mode)
{
uv_fs_t req;
int ret = uv_fs_access(unused_uv_loop_arg, &req, path, mode, NULL);
uv_fs_req_cleanup(&req);
return ret;
}

JL_DLLEXPORT int jl_fs_write(uv_os_fd_t handle, const char *data, size_t len,
int64_t offset) JL_NOTSAFEPOINT
{
Expand Down
24 changes: 24 additions & 0 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1510,3 +1510,27 @@ end
end
end
end

@testset "chmod/isexecutable" begin
mktempdir() do dir
mkdir(joinpath(dir, "subdir"))
fpath = joinpath(dir, "subdir", "foo")

# Test that we can actually set the executable bit on all platforms.
touch(fpath)
chmod(fpath, 0o644)
@test !Sys.isexecutable(fpath)
chmod(fpath, 0o755)
@test Sys.isexecutable(fpath)

# Ensure that, on Windows, where inheritance is default,
# chmod still behaves as we expect.
if Sys.iswindows()
chmod(joinpath(dir, "subdir"), 0o666)
@test Sys.isexecutable(fpath)
end

# Reset permissions to all at the end, so it can be deleted properly.
chmod(dir, 0o777; recursive=true)
end
end