Skip to content
Open
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
8 changes: 7 additions & 1 deletion mac-manual/content/04-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ 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 the M1 MacBook Air and the 16-inch 2021 MacBook Pro with M1 Max, setup requires a kernel that guards the shared records during first setup. The M1 Max also requires the driver's enrollment and verification startup fixes. Setup checks the driver at every boot before permitting writes. If the driver was already running when you agreed, restart your Mac and open fingerprint setup again. If setup asks for a compatible kernel, install one with those features and restart.

Fingerprint setup and fingerprint sign-in pause if the running M1 driver cannot confirm safe storage. This also affects an attached USB reader because the fingerprint service checks every reader when it starts. Use your password while the driver starts, or restart with a compatible kernel if setup still reports the problem.

An interrupted first setup can leave a key store whose creation the Secure Enclave never confirmed. If setup reports `unsupported:recovery`, use your password and leave the keybag and guard list in place. Contact Omarchy Mac support with the setup message and your kernel version from `uname -r`. If `journalctl -b -u omarchy-mac-touchid-load` shows a load error, include it. Keep the keybag, guard list and calibration files private. A confirmed refusal can be retried automatically on the next guarded load if no shared record was pinned. Existing fingerprints and their key store are kept.

On a MacBook Neo or a 16-inch MacBook Pro with M4 Pro, setup also reads the sensor's key (and on the M4 Pro its calibration) from the factory records the installer left on the boot partition, into firmware files only root can read. Turning Touch ID off deletes those files, and turning it on again rebuilds them.

After five fingerprints that don't match, Touch ID locks, and it stays locked after a restart, as on macOS. Your password at a `sudo` prompt or an administrator dialog unlocks it again. The lock screen's password doesn't yet, so use one of those once if Touch ID keeps refusing your finger.

Turning Touch ID off later removes your fingerprints and stops the driver loading. The key store stays.
Turning Touch ID off later removes your fingerprints and the package's authorization to write. The key store stays. A kernel that uses the Secure Enclave for the M1 microphones can still load its driver read-only.

## Resetting the Mac for a new owner

Expand Down
5 changes: 4 additions & 1 deletion omarchy-mac/README.md

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions omarchy-mac/entrypoints/disable-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ fi
rebuilt=(/usr/lib/firmware/updates/apple/msrk-j700.bin /usr/lib/firmware/updates/apple/msrk-j616s.bin
/usr/lib/firmware/updates/apple/mesacal-j616s.bin /usr/lib/firmware/updates/apple/msrk-j616c.bin
/usr/lib/firmware/updates/apple/mesacal-j616c.bin)
records=(/etc/omarchy-mac/touchid-on /etc/modprobe.d/omarchy-mac-touchid.conf)
present=()
for file in "${records[@]}" "${rebuilt[@]}" "${rebuilt[@]/%/.new}"; do
for file in /etc/omarchy-mac/touchid-on "${rebuilt[@]}" "${rebuilt[@]/%/.new}"; do
[[ -e $file ]] && present+=("$file")
done
# Keep administrator settings (including OS identity and read-only denials)
# across opt-out, even when an earlier setup already removed its consent.
if ! /usr/lib/omarchy-mac/touchid-options --remove; then
echo "Touch ID could not be turned off: its driver options could not be cleared." >&2
exit 1
fi
if (( ${#present[@]} )); then
# A record left behind, on a read-only root say, loads the driver again.
if ! rm -f "${present[@]}"; then
Expand All @@ -36,8 +41,11 @@ if (( ${#present[@]} )); then
echo "Touch ID could not be turned off: remove ${left[*]}" >&2
exit 1
fi
echo "Touch ID stops loading at the next boot. The key store for Linux stays on this Mac."
echo "Touch ID setup stops at the next boot. The key store for Linux stays on this Mac."
fi
# An enrolled reader may still be open in fprintd following fingerprint
# removal. Revoke its access as soon as the owner's agreement is gone.
/usr/lib/omarchy-mac/touchid-status --withdraw || exit 1
# Without the record this takes the re-arm out of sudo's and polkit's stacks.
/usr/lib/omarchy-mac/touchid-pam || exit 1
exit 0
95 changes: 57 additions & 38 deletions omarchy-mac/entrypoints/enable-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
# omarchy-lifecycle-dispatch enable-fingerprint: Omarchy's fingerprint setup runs
# this as root before enrolling. It asks the owner before Touch ID is turned on,
# since that leaves state in the Secure Enclave that can't be removed.
omarchy-hw-apple-silicon || exit 0
recovery_help() {
echo "Touch ID kept the keybag and guard list. Leave both files in place and use your password."
echo "For help, report this setup message and your kernel version (uname -r). Include any error from journalctl -b -u omarchy-mac-touchid-load."
}

can_enumerate() {
/usr/lib/omarchy-mac/touchid-kernel-ready reader && return 0
echo "Fingerprint setup paused because the running Touch ID driver cannot confirm safe storage." >&2
echo "If the driver is still starting, try again after it binds. Otherwise restart this Mac with a compatible kernel." >&2
return 1
}
if ! omarchy-hw-apple-silicon; then
can_enumerate
exit $?
fi

status=$(cat /run/omarchy-mac/touchid 2>/dev/null)
recorded_status=${status:-no status}
Expand All @@ -12,53 +26,57 @@ if [[ -z $status ]]; then
status=$(/usr/lib/omarchy-mac/touchid-eligibility 2>/dev/null)
fi
if [[ -e /etc/omarchy-mac/touchid-on ]]; then
# A Mac turned on before the record came with driver options gets them now,
# whatever its status: on a kernel that loads the driver read-only, the
# options are what lets it reach ready after a restart.
options=/etc/modprobe.d/omarchy-mac-touchid.conf
if [[ ! -e $options ]]; then
# Under the Touch ID lock, so a removal running now can't be undone here.
lock=/run/omarchy-mac/touchid.lock
if ! { mkdir -p -m 0755 "${lock%/*}" && exec {lock_fd}>>"$lock"; } 2>/dev/null; then
echo "Touch ID's driver options could not be written: its lock, $lock, could not be opened." >&2
exit 1
elif ! flock -w 300 "$lock_fd"; then
echo "Touch ID's driver options could not be written: another Touch ID setup or removal is still running." >&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
elif [[ ! -e $options ]]; then
# The 16-inch M4 Max's kernel profile leaves the xART guard off (aurora
# 7.3.0.aurora1-40), and Touch ID was tried there only with it on, so keep
# Linux to its own xART records. Other Macs keep the kernel's level: the guard
# blocks matching on M1-family Macs.
driver_options="xart_writes=1 provision_keybag=1"
if tr '\0' '\n' </proc/device-tree/compatible 2>/dev/null | grep -Fxq apple,j616c; then
driver_options+=" xart_guard=1"
fi
{ mkdir -p -m 0755 "${options%/*}" &&
printf '%s\n' "# The owner turned on Touch ID; omarchy-mac's disable-fingerprint removes this." \
"options apple_sep $driver_options" >"$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
exec {lock_fd}>&-
# An earlier agreement may still have writable M1 autoload options.
lock=/run/omarchy-mac/touchid.lock
if ! { mkdir -p -m 0755 "${lock%/*}" && exec {lock_fd}>>"$lock"; } 2>/dev/null; then
echo "Touch ID's driver options could not be written: its lock, $lock, could not be opened." >&2
exit 1
elif ! flock -w 300 "$lock_fd"; then
echo "Touch ID's driver options could not be written: another Touch ID setup or removal is still running." >&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."
can_enumerate
exit $?
fi
/usr/lib/omarchy-mac/touchid-options --ensure || {
echo "Touch ID's driver options could not be written." >&2
exit 1
}
exec {lock_fd}>&-
can_enumerate || exit 1
# A Mac agreed before the re-arm existed gets its PAM lines here too.
/usr/lib/omarchy-mac/touchid-pam || echo "Touch ID is on, but a password won't end a lockout until its PAM lines are fixed (see above)." >&2
# 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
eligibility=$(/usr/lib/omarchy-mac/touchid-eligibility 2>/dev/null)
if [[ $status != "ready" || $eligibility == unsupported:* ]]; then
case $eligibility in
unsupported:kernel)
echo "Touch ID is turned on, but this kernel can't set it up on this Mac."
echo "Boot a kernel with the guarded Touch ID driver for this Mac, then set"
echo "up the fingerprint again. Setup goes on with any other fingerprint reader."
exit 0 ;;
unsupported:restart)
echo "The running Touch ID driver cannot confirm guarded setup. Restart this Mac to load the checked driver."
exit 0 ;;
unsupported:recovery)
recovery_help
exit 0 ;;
esac
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."
fi
exit 0
fi
# Only a Touch ID that can be set up stops the setup: anywhere else it goes on,
# so a USB reader enrols as it would without Touch ID.
can_enumerate || exit 1
# A status recorded while a driver was binding or before an update can change.
case $status in
unsupported:restart|unsupported:kernel|unsupported:recovery)
status=$(/usr/lib/omarchy-mac/touchid-eligibility 2>/dev/null) ;;
esac
case $status in
available | ready) ;;
none | "")
Expand All @@ -69,7 +87,8 @@ case $status in
echo "any other fingerprint reader."
# A driver that came up wrong this boot stays so until a restart.
case $status in
failed | not-ready | unproven | blocked) echo "Restart this Mac, then set up the fingerprint again to retry Touch ID." ;;
unsupported:recovery) recovery_help ;;
failed | not-ready | unproven | blocked | unsupported:restart) echo "Restart this Mac, then set up the fingerprint again to retry Touch ID." ;;
esac
exit 0
;;
Expand Down
5 changes: 4 additions & 1 deletion omarchy-mac/install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
destination=${1:?Usage: ./install DESTDIR}
[[ $destination == /* && $destination != "/" ]] || { echo "Use an absolute staging directory" >&2; exit 1; }
for file in bin/*; do install -Dm755 "$file" "$destination/usr/bin/${file##*/}"; done
for file in lib/*; do install -Dm755 "$file" "$destination/usr/lib/omarchy-mac/${file##*/}"; done
for file in lib/*; do
if [[ -x $file ]]; then mode=755; else mode=644; fi
install -Dm"$mode" "$file" "$destination/usr/lib/omarchy-mac/${file##*/}"
done
for file in entrypoints/*; do install -Dm755 "$file" "$destination/usr/lib/omarchy/mac/${file##*/}"; done
while IFS= read -r -d '' file; do
install -Dm644 "$file" "$destination/usr/lib/${file#vendor/}"
Expand Down
7 changes: 6 additions & 1 deletion omarchy-mac/lib/touchid-activate
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ for ((attempt = 1; attempt <= attempts && SECONDS < 45; attempt++)); do
finish unproven "the enrolled fingerprints could not be proven (restore unproven)"
elif [[ $matching == "blocked" ]]; then
finish blocked "a match could not save its state (matching blocked)"
elif [[ $sensor_attach == "attached" && ($previous == "ready" || ($touchid == "ready" && ($restore == "restored" || $restore == "empty") && ($matching == "usable" || $matching == "unverified"))) ]]; then
# The driver recognized this historical bag and its existing pins. It
# can enroll its first print or try a real verify without a new pin window.
elif [[ $matching == "legacy" && $touchid == "ready" && $sensor_attach == "attached" &&
($restore == "restored" || $restore == "empty") ]]; then
finish ready
elif [[ $matching != "legacy" && $sensor_attach == "attached" && ($previous == "ready" || ($touchid == "ready" && ($restore == "restored" || $restore == "empty") && ($matching == "usable" || $matching == "unverified"))) ]]; then
finish ready
elif [[ $sensor_attach == "not-ready" ]]; then
finish not-ready "the sensor did not come online (sensor_attach not-ready)"
Expand Down
38 changes: 38 additions & 0 deletions omarchy-mac/lib/touchid-board.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# Board predicates shared by the Touch ID helpers.
tree=${OMARCHY_MAC_TOUCHID_TREE:-/proc/device-tree}

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

touchid_sensor() {
local node
for node in "$tree"/soc/*/fingerprint@* "$tree"/*/fingerprint@*; do
if [[ -r $node/compatible ]] && tr '\0' '\n' <"$node/compatible" | grep -Fxq apple,mesa-fingerprint &&
[[ ! -r $node/status || $(tr -d '\0' <"$node/status") == "okay" ]]; then
printf '%s\n' "$node"
return 0
fi
done
return 1
}

guarded_m1() {
{ compatible apple,t8103 && compatible apple,j313; } ||
{ compatible apple,t6001 && compatible apple,j316c; }
}

m1_family() {
compatible apple,t8103 || compatible apple,t6000 || compatible apple,t6001
}

sealed_board() {
{ compatible apple,t6040 && compatible apple,j616s; } ||
{ compatible apple,t6041 && compatible apple,j616c; }
}

other_touchid_board() {
compatible apple,t8112 || compatible apple,t6020 || compatible apple,t6021 || compatible apple,t8140 ||
{ compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; } || sealed_board
}
42 changes: 18 additions & 24 deletions omarchy-mac/lib/touchid-eligibility
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

tree=${OMARCHY_MAC_TOUCHID_TREE:-/proc/device-tree}
firmware=${OMARCHY_MAC_TOUCHID_FIRMWARE:-/usr/lib/firmware}
helpers=${OMARCHY_MAC_TOUCHID_HELPERS:-/usr/lib/omarchy-mac}
extractors=${OMARCHY_MAC_TOUCHID_EXTRACTORS:-/usr/lib/linux-aurora}
python=${OMARCHY_MAC_TOUCHID_PYTHON:-python3}
esp=${OMARCHY_MAC_TOUCHID_ESP:-/boot/efi}
omarchy-hw-apple-silicon || exit 0

compatible() {
[[ -r $tree/compatible ]] && tr '\0' '\n' <"$tree/compatible" | grep -Fxq "$1"
}
source "$helpers/touchid-board.sh" || exit 1

installed() {
local directory
Expand All @@ -29,16 +28,9 @@ can_extract() {
[[ -x $extractors/$1 ]] && command -v "$python" >/dev/null
}

sensor=""
# The sensor sits on an SPI controller under /soc, or at the root on the M4 Pro
# and M4 Max.
for node in "$tree"/soc/*/fingerprint@* "$tree"/*/fingerprint@*; do
if [[ -r $node/compatible ]] && tr '\0' '\n' <"$node/compatible" | grep -Fxq apple,mesa-fingerprint &&
[[ ! -r $node/status || $(tr -d '\0' <"$node/status") == "okay" ]]; then
sensor=$node
break
fi
done
sensor=$(touchid_sensor)
if [[ ${1:-} == "sensor" ]]; then
printf '%s\n' "$sensor"
exit 0
Expand All @@ -47,21 +39,23 @@ elif [[ -z $sensor ]]; then
exit 0
fi

# The 16-inch M4 Pro and M4 Max: on each, Touch ID has enrolled, matched, and
# matched again after a restart. Their sensor loads a calibration and a root key that are both
# rebuilt from sealed factory records.
sealed_board() {
{ compatible apple,t6040 && compatible apple,j616s; } || { compatible apple,t6041 && compatible apple,j616c; }
}

# 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
# These cold-boot Macs need a kernel that can pin setup records under the guard.
if guarded_m1; then
"$helpers/touchid-kernel-ready" 2>/dev/null
case $? in
0) ;;
2) echo unsupported:restart; exit 0 ;;
*) echo unsupported:kernel; exit 0 ;;
esac
if [[ ! -d ${OMARCHY_MAC_TOUCHID_MODULE:-/sys/module/apple_sep} ]] &&
! "$helpers/touchid-retry-aside" --check 2>/dev/null; then
echo unsupported:recovery
exit 0
fi
elif m1_family; then
echo unsupported:m1-family
exit 0
elif ! compatible apple,t8112 && ! compatible apple,t6020 && ! compatible apple,t6021 && ! compatible apple,t8140 &&
! { compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; } &&
! sealed_board; then
elif ! other_touchid_board; then
echo unsupported:board
exit 0
fi
Expand Down
Loading
Loading