Skip to content

Commit 6d069e2

Browse files
Add auditor pass to ad-hoc codesign all products on Darwin (#996)
* Upgrade `BinaryBuilder` to work on Julia v1.6+ This updates some syntax and fixes some tests that were broken on Julia v1.6 * Add ad-hoc codesigning on all Darwin platforms All darwin executables and libraries will need to be codesigned, so we use `ldid` to automatically perform this codesigning, and check that it happens in an audit pass. * Experiment with CI fixes * Try turning PkgServer on again * Update src/auditor/codesigning.jl Co-authored-by: Mosè Giordano <[email protected]>
1 parent eb4b56a commit 6d069e2

File tree

6 files changed

+76
-32
lines changed

6 files changed

+76
-32
lines changed

.ci/install_agents.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [[ ! -f "${STORAGE_DIR}/rootfs/usr/local/bin/julia" ]]; then
2929
# Install Julia
3030
echo "Installing Julia..."
3131
mkdir -p "${STORAGE_DIR}/rootfs/depot"
32-
JULIA_URL="https://julialangnightlies-s3.julialang.org/bin/linux/x64/julia-latest-linux64.tar.gz"
32+
JULIA_URL="https://julialangnightlies-s3.julialang.org/bin/linux/x64/1.6/julia-latest-linux64.tar.gz"
3333
curl -# -L "$JULIA_URL" | tar --strip-components=1 -zx -C "${STORAGE_DIR}/rootfs/usr/local"
3434
fi
3535

Manifest.toml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ version = "0.2.0"
2727
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
2828

2929
[[BinaryBuilderBase]]
30-
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "Libdl", "Logging", "OutputCollectors", "Pkg", "Random", "SHA", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll"]
31-
git-tree-sha1 = "61cbfed1cfaa5d1486fca1784682b75e8f1986f8"
30+
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "Libdl", "Logging", "OutputCollectors", "Pkg", "Random", "SHA", "Scratch", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll", "pigz_jll"]
31+
git-tree-sha1 = "ba037f06ff8be240fcbd33c4ec4a397ebb9a9329"
3232
repo-rev = "master"
3333
repo-url = "https://github.com/JuliaPackaging/BinaryBuilderBase.jl.git"
3434
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
@@ -41,9 +41,9 @@ uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
4141
version = "0.7.0"
4242

4343
[[DataAPI]]
44-
git-tree-sha1 = "25ccd31003243d2ce83e474cf11663dddf48035f"
44+
git-tree-sha1 = "6d64b28d291cb94a0d84e6e41081fb081e7f717f"
4545
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
46-
version = "1.4.1"
46+
version = "1.5.0"
4747

4848
[[DataStructures]]
4949
deps = ["InteractiveUtils", "OrderedCollections"]
@@ -65,7 +65,7 @@ deps = ["Random", "Serialization", "Sockets"]
6565
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
6666

6767
[[Downloads]]
68-
deps = ["ArgTools", "LibCURL"]
68+
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
6969
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
7070

7171
[[FileIO]]
@@ -144,13 +144,17 @@ deps = ["LibCURL_jll", "MozillaCACerts_jll"]
144144
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
145145

146146
[[LibCURL_jll]]
147-
deps = ["Libdl"]
147+
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
148148
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
149149

150150
[[LibGit2]]
151-
deps = ["Printf"]
151+
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
152152
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
153153

154+
[[LibSSH2_jll]]
155+
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
156+
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
157+
154158
[[Libdl]]
155159
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
156160

@@ -163,9 +167,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
163167

164168
[[LoggingExtras]]
165169
deps = ["Dates"]
166-
git-tree-sha1 = "03289aba73c0abc25ff0229bed60f2a4129cd15c"
170+
git-tree-sha1 = "70518b2cce1fea30c5e9dd0c44407a90f394de47"
167171
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
168-
version = "0.4.2"
172+
version = "0.4.4"
169173

170174
[[MacroTools]]
171175
deps = ["Markdown", "Random"]
@@ -184,10 +188,8 @@ uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
184188
version = "1.0.3"
185189

186190
[[MbedTLS_jll]]
187-
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
188-
git-tree-sha1 = "47e19f64fc939b86dea2b9b5e38c29c787f0d581"
191+
deps = ["Artifacts", "Libdl"]
189192
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
190-
version = "2.24.0+1"
191193

192194
[[Mmap]]
193195
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
@@ -207,16 +209,19 @@ git-tree-sha1 = "2578b3cd03e4f568f213c7d51b2118f9e81c2617"
207209
uuid = "a975b10e-0019-58db-a62f-e48ff68538c9"
208210
version = "0.7.5"
209211

212+
[[NetworkOptions]]
213+
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
214+
210215
[[ObjectFile]]
211216
deps = ["Reexport", "StructIO", "Test"]
212217
git-tree-sha1 = "e009c49f99dac98cb79f93b26c259ebca66eff26"
213218
uuid = "d8793406-e978-5875-9003-1fc021f44a92"
214219
version = "0.3.6"
215220

216221
[[OrderedCollections]]
217-
git-tree-sha1 = "cf59cfed2e2c12e8a2ff0a4f1e9b2cd8650da6db"
222+
git-tree-sha1 = "d45739abcfc03b51f6a42712894a593f74c80a23"
218223
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
219-
version = "1.3.2"
224+
version = "1.3.3"
220225

221226
[[OutputCollectors]]
222227
git-tree-sha1 = "d86c19b7fa8ad6a4dc8ec2c726642cc6291b2941"
@@ -284,6 +289,12 @@ version = "1.5.3"
284289
[[SHA]]
285290
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
286291

292+
[[Scratch]]
293+
deps = ["Dates"]
294+
git-tree-sha1 = "ad4b278adb62d185bbcb6864dc24959ab0627bf6"
295+
uuid = "6c6a2e73-6563-6170-7368-637461726353"
296+
version = "1.0.3"
297+
287298
[[Serialization]]
288299
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
289300

@@ -374,10 +385,8 @@ uuid = "8f1865be-045e-5c20-9c9f-bfbfb0764568"
374385
version = "4.3.2+5"
375386

376387
[[Zlib_jll]]
377-
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
378-
git-tree-sha1 = "32085929ad61a5ed99abea288ec7242be392bb8b"
388+
deps = ["Libdl"]
379389
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
380-
version = "1.2.12+0"
381390

382391
[[ghr_jll]]
383392
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -391,8 +400,16 @@ git-tree-sha1 = "7127f5f40332ccfa43ee07dcd0c4d81a27d9bb23"
391400
uuid = "a9144af2-ca23-56d9-984f-0d03f7b5ccf8"
392401
version = "1.0.18+1"
393402

403+
[[nghttp2_jll]]
404+
deps = ["Artifacts", "Libdl"]
405+
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
406+
394407
[[p7zip_jll]]
395-
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
396-
git-tree-sha1 = "4b909fd780b3711197e3faa806dd631bdc5af510"
408+
deps = ["Artifacts", "Libdl"]
397409
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
398-
version = "16.2.1+0"
410+
411+
[[pigz_jll]]
412+
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
413+
git-tree-sha1 = "8c379a72c82099ceb4be53f4f427690376279052"
414+
uuid = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"
415+
version = "2.5.0+0"

azure-pipelines.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ variables:
1313
JULIA: unbuffer julia --project=$(Build.SourcesDirectory) --color=yes
1414
BINARYBUILDER_AUTOMATIC_APPLE: true
1515
BINARYBUILDER_USE_CCACHE: true
16-
JULIA_PKG_SERVER: ""
1716

1817
jobs:
1918
- job: Info
@@ -23,7 +22,7 @@ jobs:
2322
clean: true
2423
- bash: |
2524
set -e
26-
$(JULIA) -e 'using Pkg; Pkg.instantiate()'
25+
$(JULIA) -e 'using Pkg; Pkg.Registry.update(); Pkg.instantiate()'
2726
$(JULIA) -e 'using BinaryBuilder; BinaryBuilder.versioninfo()'
2827
$(JULIA) -e 'using Pkg; Pkg.status(; mode=PKGMODE_MANIFEST)'
2928
name: SystemInfo

src/Auditor.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include("auditor/compiler_abi.jl")
1616
include("auditor/soname_matching.jl")
1717
include("auditor/filesystems.jl")
1818
include("auditor/extra_checks.jl")
19+
include("auditor/codesigning.jl")
1920

2021
# AUDITOR TODO LIST:
2122
#
@@ -82,35 +83,37 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
8283
end
8384
else
8485
# Check that the ISA isn't too high
85-
all_ok &= check_isa(oh, platform, prefix; verbose=verbose, silent=silent)
86+
all_ok &= check_isa(oh, platform, prefix; verbose, silent)
8687
# Check that the OS ABI is set correctly (often indicates the wrong linker was used)
87-
all_ok &= check_os_abi(oh, platform, verbose = verbose)
88+
all_ok &= check_os_abi(oh, platform; verbose)
8889
# Make sure all binary files are executables, if libraries aren't
8990
# executables Julia may not be able to dlopen them:
9091
# https://github.com/JuliaLang/julia/issues/38993. In principle this
9192
# should be done when autofix=true, but we have to run this fix on MKL
9293
# for Windows, for which however we have to set autofix=false:
9394
# https://github.com/JuliaPackaging/Yggdrasil/pull/922.
94-
all_ok &= ensure_executability(oh; verbose=verbose, silent=silent)
95+
all_ok &= ensure_executability(oh; verbose, silent)
9596

9697
# If this is a dynamic object, do the dynamic checks
9798
if isdynamic(oh)
9899
# Check that the libgfortran version matches
99-
all_ok &= check_libgfortran_version(oh, platform; verbose=verbose, has_csl = has_csl)
100+
all_ok &= check_libgfortran_version(oh, platform; verbose, has_csl)
100101
# Check whether the library depends on any of the most common
101102
# libraries provided by `CompilerSupportLibraries_jll`.
102-
all_ok &= check_csl_libs(oh, platform; verbose=verbose, has_csl=has_csl)
103+
all_ok &= check_csl_libs(oh, platform; verbose, has_csl)
103104
# Check that the libstdcxx string ABI matches
104-
all_ok &= check_cxxstring_abi(oh, platform; verbose=verbose)
105+
all_ok &= check_cxxstring_abi(oh, platform; verbose)
105106
# Check that this binary file's dynamic linkage works properly. Note to always
106107
# DO THIS ONE LAST as it can actually mutate the file, which causes the previous
107108
# checks to freak out a little bit.
108109
all_ok &= check_dynamic_linkage(oh, prefix, bin_files;
109-
platform=platform, silent=silent,
110-
verbose=verbose, autofix=autofix)
110+
platform, silent, verbose, autofix)
111111
end
112112
end
113113
end
114+
115+
# Ensure this file is codesigned (currently only does something on Apple platforms)
116+
all_ok &= ensure_codesigned(f, prefix, platform; verbose)
114117
catch e
115118
if !isa(e, ObjectFile.MagicMismatch)
116119
rethrow(e)

src/auditor/codesigning.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function check_codesigned(path::AbstractString, platform::AbstractPlatform)
2+
# We only perform ad-hoc codesigning on Apple platforms
3+
if !Sys.isapple(platform)
4+
return true
5+
end
6+
7+
ur = preferred_runner()(dirname(path); cwd="/workspace/", platform=platform)
8+
return run(ur, `/usr/local/bin/ldid -d $(basename(path))`)
9+
end
10+
11+
function ensure_codesigned(path::AbstractString, prefix::Prefix, platform::AbstractPlatform; verbose::Bool = false)
12+
# We only perform ad-hoc codesigning on Apple platforms
13+
if !Sys.isapple(platform)
14+
return true
15+
end
16+
17+
rel_path = relpath(path, prefix.path)
18+
ur = preferred_runner()(prefix.path; cwd="/workspace/", platform=platform)
19+
with_logfile(prefix, "ldid_$(basename(rel_path)).log") do io
20+
run(ur, `/usr/local/bin/ldid -S -d $(rel_path)`, io; verbose=verbose)
21+
end
22+
end

test/auditing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ end
2727
@test compatible_marchs(Platform("x86_64", "linux"; march="avx2")) == ["x86_64", "avx", "avx2"]
2828
@test compatible_marchs(Platform("x86_64", "linux"; march="avx512")) == ["x86_64", "avx", "avx2", "avx512"]
2929
@test compatible_marchs(Platform("armv7l", "linux")) == ["armv7l"]
30-
@test compatible_marchs(Platform("i686", "linux"; march="prescott")) == ["i686", "prescott"]
30+
@test compatible_marchs(Platform("i686", "linux"; march="prescott")) == ["pentium4", "prescott"]
3131
@test compatible_marchs(Platform("aarch64", "linux"; march="armv8_1")) == ["armv8_0", "armv8_1"]
3232

3333
product = ExecutableProduct("main", :main)
@@ -368,6 +368,9 @@ end
368368
wrong_id_path = locate(wrong_id, prefix; platform=platform)
369369
@test any(startswith.(wrong_id_path, libdirs(prefix)))
370370
@test get_dylib_id(wrong_id_path) == "@rpath/totally_different.dylib"
371+
372+
# Ensure that this bianry is codesigned
373+
@test BinaryBuilder.Auditor.check_codesigned(right_id_path, platform)
371374
end
372375
end
373376

0 commit comments

Comments
 (0)