Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Sign the peel tool's class data in a release build

Țugui Dragoșf5ecdc4652cc
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index fddf3af6..2c2bf4c2 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -50,20 +50,27 @@ jobs:
-derivedDataPath build/DerivedData CODE_SIGNING_ALLOWED=NO build
# Release builds every binary for Apple silicon, with pointer authentication (arm64e) and without, and for Intel,
- # with the optimizer a Debug build leaves off. The setting is given here too, since only the command line reaches
- # the Swift packages.
+ # with the optimizer a Debug build leaves off. The settings are given here too, since only the command line
+ # reaches the Swift packages: a package that names no platform would be built for an older macOS, with its class
+ # data unsigned, and the linker then leaves the class data of the whole binary unsigned.
- name: Build the app for release
run: |
xcodebuild -project Peel.xcodeproj -scheme Peel -configuration Release \
- -derivedDataPath build/Release CODE_SIGNING_ALLOWED=NO ENABLE_POINTER_AUTHENTICATION=YES build
+ -derivedDataPath build/Release CODE_SIGNING_ALLOWED=NO ENABLE_POINTER_AUTHENTICATION=YES \
+ MACOSX_DEPLOYMENT_TARGET=26.0 build
for binary in MacOS/Peel MacOS/PeelHelper Helpers/peel PlugIns/PeelFinder.appex/Contents/MacOS/PeelFinder; do
- archs=$(lipo -archs "build/Release/Build/Products/Release/Peel.app/Contents/$binary")
+ path="build/Release/Build/Products/Release/Peel.app/Contents/$binary"
+ archs=$(lipo -archs "$path")
for arch in arm64e arm64 x86_64; do
case " $archs " in
*" $arch "*) ;;
*) echo "::error::$binary is built for $archs, without $arch."; exit 1 ;;
esac
done
+ flags=$(otool -arch arm64e -s __DATA_CONST __objc_imageinfo "$path" | awk 'END { print $3 }')
+ if [ -z "$flags" ] || [ $(( 0x$flags & 0x10 )) -eq 0 ]; then
+ echo "::error::$binary has its class data unsigned."; exit 1
+ fi
done
# The accessibility audit drives the pointer, so it runs by hand before a release. Here it is only built.
diff --git a/Scripts/release.sh b/Scripts/release.sh
index bd609768..a1bd7461 100755
--- a/Scripts/release.sh
+++ b/Scripts/release.sh
@@ -47,7 +47,9 @@ grep -E "Test run with" "$build/test.log" || true
echo "== Archiving"
# The output goes to a log, not through a pipe, so the `if` checks xcodebuild's own exit status. Pointer
# authentication is set here as well as in the project, since Xcode gives the Swift packages only the settings
-# of the command line, and every binary imports them.
+# of the command line, and every binary imports them. So is macOS 26: a package that names no platform, such as
+# swift-argument-parser, would be built for an older macOS, with its class data unsigned, and the linker then
+# leaves the class data of the whole `peel` tool unsigned.
if ! xcodebuild archive \
-project Peel.xcodeproj \
-scheme Peel \
@@ -55,6 +57,7 @@ if ! xcodebuild archive \
-archivePath "$archive" \
-derivedDataPath "$build/DerivedData" \
ENABLE_POINTER_AUTHENTICATION=YES \
+ MACOSX_DEPLOYMENT_TARGET=26.0 \
> "$build/archive.log" 2>&1
then
grep -E "error:" "$build/archive.log" || tail -20 "$build/archive.log"
@@ -130,6 +133,20 @@ do
done
echo "Every binary: arm64e, arm64, x86_64"
+echo "== Signed class data"
+# In the arm64e slice, pointer authentication also signs each class's read-only data, which the Objective-C image
+# info marks with its flag 0x10; one object built without it turns it off for the whole binary.
+for executable in \
+ "$app/Contents/MacOS/Peel" \
+ "$app/Contents/MacOS/PeelHelper" \
+ "$app/Contents/PlugIns/PeelFinder.appex/Contents/MacOS/PeelFinder" \
+ "$app/Contents/Helpers/peel"
+do
+ flags="$(otool -arch arm64e -s __DATA_CONST __objc_imageinfo "$executable" | awk 'END { print $3 }')"
+ [[ -n "$flags" ]] && (( 16#$flags & 16#10 )) || { echo "REFUSED: $executable has its class data unsigned"; exit 1; }
+done
+echo "Every binary: class data signed"
+
echo "== Languages"
# Every language in the project's `knownRegions` (besides `en` and `Base`) must ship in the app and in the Finder
# extension. Without this check, a language missing from the build would quietly fall back to English.