Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions mac-manual/content/04-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ If a bug ever writes that shared state wrongly, the enclave stops accepting it a
- With FileVault on, macOS can't unlock its disk and won't start, and the startup picker may not open. Getting the Mac back takes a DFU restore, which erases it.
- With FileVault off, macOS resets its keychain and Touch ID fingerprints and shows a warning.

On a MacBook Air M1, the first setup rewrites three records in that shared state that macOS created. Setup offers Touch ID there only with a kernel whose Secure Enclave driver lets exactly those three through and keeps refusing changes to every other macOS record. Back up macOS before you turn Touch ID on there too.

On a MacBook Neo, setup also reads the sensor's key from the factory records the installer left on the boot partition, into a firmware file only root can read. Turning Touch ID off deletes that file.

Turning Touch ID off later removes your fingerprints and stops the driver loading. The key store stays.
Expand Down
2 changes: 1 addition & 1 deletion omarchy-mac/README.md

Large diffs are not rendered by default.

29 changes: 27 additions & 2 deletions omarchy-mac/entrypoints/enable-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ if [[ -e /etc/omarchy-mac/touchid-on ]]; then
echo "Touch ID was turned off while this ran, so setup goes on without it."
exit 0
elif [[ ! -e $options ]]; then
{ mkdir -p -m 0755 "${options%/*}" &&
{ option_line=$(/usr/lib/omarchy-mac/touchid-options) && mkdir -p -m 0755 "${options%/*}" &&
printf '%s\n' "# The owner turned on Touch ID; omarchy-mac's disable-fingerprint removes this." \
"options apple_sep xart_writes=1 provision_keybag=1" >"$options.new" &&
"$option_line" >"$options.new" &&
chmod 0644 "$options.new" && mv -fT "$options.new" "$options"; } ||
{ rm -f "$options.new" 2>/dev/null; echo "Touch ID's driver options could not be written to $options" >&2; exit 1; }
fi
Expand All @@ -41,6 +41,31 @@ if [[ -e /etc/omarchy-mac/touchid-on ]]; then
# The owner agreed already, so they are never asked again: a Touch ID that
# isn't ready yet needs a restart, and setup goes on with any other reader.
if [[ $status != "ready" ]]; then
if [[ $(/usr/lib/omarchy-mac/touchid-eligibility 2>/dev/null) == "unsupported:kernel" ]]; then
echo "Touch ID is turned on, but this kernel can't set it up on this Mac."
echo "Boot a kernel whose Secure Enclave driver has xart_guard_pins, then set"
echo "up the fingerprint again. Setup goes on with any other fingerprint reader."
exit 0
fi
# A recorded status that isn't ready ends a setup, a crashed one included, so
# its state is set aside for the restart; with none recorded, or while the
# activation runs, the setup may still be going and is left alone.
if [[ $recorded_status != "no status" ]]; then
lock=/run/omarchy-mac/touchid.lock
if ! { mkdir -p -m 0755 "${lock%/*}" && exec {lock_fd}>>"$lock"; } 2>/dev/null || ! flock -w 300 "$lock_fd"; then
echo "Touch ID's earlier try could not be set aside: its lock, $lock, is unavailable." >&2
exit 1
fi
if [[ ! -e /etc/omarchy-mac/touchid-on ]]; then
echo "Touch ID was turned off while this ran, so setup goes on without it."
exit 0
fi
if [[ $(cat /run/omarchy-mac/touchid 2>/dev/null) != "ready" ]] &&
! systemctl is-active --quiet omarchy-mac-touchid-activate.service; then
/usr/lib/omarchy-mac/touchid-retry-aside || exit 1
fi
exec {lock_fd}>&-
fi
echo "Touch ID is turned on but isn't ready yet ($recorded_status)."
echo "Restart this Mac, then set up the fingerprint again. If it still isn't"
echo "ready, see journalctl -u omarchy-mac-touchid-activate."
Expand Down
14 changes: 12 additions & 2 deletions omarchy-mac/lib/touchid-eligibility
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

tree=${OMARCHY_MAC_TOUCHID_TREE:-/proc/device-tree}
firmware=${OMARCHY_MAC_TOUCHID_FIRMWARE:-/usr/lib/firmware}
modinfo=${OMARCHY_MAC_TOUCHID_MODINFO:-modinfo}
extractors=${OMARCHY_MAC_TOUCHID_EXTRACTORS:-/usr/lib/linux-aurora}
python=${OMARCHY_MAC_TOUCHID_PYTHON:-python3}
esp=${OMARCHY_MAC_TOUCHID_ESP:-/boot/efi}
Expand Down Expand Up @@ -46,8 +47,17 @@ elif [[ -z $sensor ]]; then
fi

# The boards the aurora driver has a profile for. M1-family Macs cold-boot
# their enclave behind an xART guard that blocks matching, so they wait.
if compatible apple,t8103 || compatible apple,t6000 || compatible apple,t6001; then
# their enclave behind an xART guard that blocks matching; the M1 Air (J313)
# sets up with the guard pinning its setup lockers (touchid-options), the others wait.
if compatible apple,t8103 && compatible apple,j313; then
# Only a kernel whose guard pins those lockers (omacom/linux-aurora#506) can
# finish the setup; a built-in driver shows no parameters and is refused too.
params=$("$modinfo" -p apple_sep 2>/dev/null)
if ! grep -q '^xart_guard_pins:' <<<"$params"; then
echo unsupported:kernel
exit 0
fi
elif compatible apple,t8103 || compatible apple,t6000 || compatible apple,t6001; then
echo unsupported:m1-family
exit 0
elif ! compatible apple,t8112 && ! compatible apple,t6020 && ! compatible apple,t6021 && ! compatible apple,t8140 &&
Expand Down
6 changes: 5 additions & 1 deletion omarchy-mac/lib/touchid-enable
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ if [[ -d $module && ! -e $options && ! -e $loaded ]]; then
fi
# A write that fails partway never replaces the options, since a file without
# them would load a read-only driver at every boot.
option_line=$("$helpers/touchid-options") || fail "this Mac's driver options could not be worked out"
# A try that failed under the guard keeps the pin window shut until its state
# is set aside.
"$helpers/touchid-retry-aside" || fail "an earlier Touch ID try's state could not be set aside"
{ mkdir -p -m 0755 "${options%/*}" &&
printf '%s\n' "# The owner turned on Touch ID; omarchy-mac's disable-fingerprint removes this." \
"options apple_sep xart_writes=1 provision_keybag=1" >"$options.new" &&
"$option_line" >"$options.new" &&
chmod 0644 "$options.new" && mv -fT "$options.new" "$options"; } ||
{ rm -f "$options.new" 2>/dev/null; fail "the driver's options could not be written to $options"; }
mkdir -p -m 0755 "${loaded%/*}"
Expand Down
18 changes: 18 additions & 0 deletions omarchy-mac/lib/touchid-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Prints the modprobe.d line that lets the Secure Enclave driver set up Touch ID
# on this Mac, for touchid-enable and enable-fingerprint to write.

tree=${OMARCHY_MAC_TOUCHID_TREE:-/proc/device-tree}
omarchy-hw-apple-silicon || exit 0

compatible() {
[[ -r $tree/compatible ]] && tr '\0' '\n' <"$tree/compatible" | grep -Fxq "$1"
}

options="xart_writes=1 provision_keybag=1"
# The M1 Air's first setup rewrites key-store session records macOS created, which
# the xART guard refuses; xart_guard_pins pins those, keeping the guard on (#506).
if compatible apple,t8103 && compatible apple,j313; then
options+=" xart_guard_pins=1"
fi
printf 'options apple_sep %s\n' "$options"
31 changes: 31 additions & 0 deletions omarchy-mac/lib/touchid-retry-aside
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Sets aside an earlier Touch ID try's guard list and uncommitted keybag, which
# keep xart_guard_pins's one-time pin window shut. A committed keybag keeps its
# list. The caller holds the Touch ID lock.

helpers=${OMARCHY_MAC_TOUCHID_HELPERS:-/usr/lib/omarchy-mac}
keybag=${OMARCHY_MAC_TOUCHID_KEYBAG:-/var/lib/aurora-sep-keybag.bin}
guard_list=${OMARCHY_MAC_TOUCHID_GUARD_LIST:-/var/lib/aurora-sep-xart-owned.bin}
omarchy-hw-apple-silicon || exit 0

[[ $("$helpers/touchid-options") == *xart_guard_pins=1* ]] || exit 0
# Committed, as the driver writes it: its magic, then state 1 or 3 at 0x14.
if [[ -f $keybag && $(head -c 16 "$keybag" 2>/dev/null) == "APPLE-SEP-KBAG01" ]] &&
[[ $(od -An -tu4 -j20 -N4 "$keybag" 2>/dev/null | tr -d ' ') == [13] ]]; then
exit 0
fi
if [[ ! -e $guard_list && ! -e $keybag ]]; then
exit 0
fi
aside=${guard_list%/*}/aurora-sep-touchid-retry-$(date +%Y%m%d-%H%M%S)
if ! mkdir -p -m 0700 "$aside"; then
echo "An earlier Touch ID try's state could not be set aside in $aside." >&2
exit 1
fi
for stale in "$guard_list" "$keybag"; do
if [[ -e $stale ]] && ! mv -f "$stale" "$aside/"; then
echo "An earlier Touch ID try's $stale could not be set aside in $aside." >&2
exit 1
fi
done
echo "An earlier Touch ID try's state is kept in $aside."
Loading
Loading