Repository navigation
Serialize Touch ID setup, check the Neo's sensor key, bound its archive - #55
Conversation
The docstring said an archive from another Mac, or one swapped on the ESP, is refused. The check finds each record byte for byte somewhere in this Mac's iBoot System Container; that proves the record is present there, not that it is the active or an authentic one.
Each record was capped at 16 MiB, but nothing bounded how many entries the archive could hold or how many record bytes were kept in memory across them. factory_records() now refuses an archive past 16384 entries, or whose records total more than 32 MiB. Tests: an archive at the entry limit still gives the key; one entry more, or three 12 MiB trust bundles, are refused and say why.
Two fingerprint setups at once could race on the Neo's sensor key: touchid-root-key writes it through the shared msrk-j700.bin.new and unlinks a stale copy first, so one run could delete the other's open temporary file and install its unfinished key. touchid-enable and disable-fingerprint now take one lock, /run/omarchy-mac/touchid.lock, waiting up to five minutes for a run in progress. touchid-enable trusted any msrk-j700.bin that existed. It now checks each copy's envelope with touchid-root-key --check: a broken one in the updates directory is rebuilt, and one elsewhere, which would shadow or outlive a rebuild there, stops the setup and names the file. Without Python an existing key can't be checked, so the setup stops and says so. Tests: a held lock makes a setup or removal touch nothing and one that waits goes on; a broken key in updates is rebuilt, one in vendor stops the setup, and one that can't be checked is not trusted.
[Medium impact] The PR appears safe to merge, with one non-blocking error-message issue. Findings
SummaryThe PR serializes Touch ID setup and removal, checks installed Neo sensor keys, and caps archive entries and retained record bytes.
Reviews (2) · Last reviewed commit: "Tell a broken sensor key from a failed c..." · Reviewed by Greptile |
…pair - touchid-root-key --check exits 3 for a key that is not whole and 1 when it could not tell. touchid-enable rebuilds only on 3; any other failure stops setup and leaves the key alone, where before it took a checker that failed to run for a broken key and could delete a good one. - A lock that can't be opened is reported as such, in touchid-enable and disable-fingerprint, not as another setup still running. - enable-fingerprint's repair of an agreed Mac's driver options takes the Touch ID lock and checks the agreement again under it, so a removal running at the same time can't be undone. Tests: a check that fails to run keeps the key and turns nothing on; a broken key in updates that can't be rebuilt is removed; an unopenable lock says so; an agreed Mac's options wait for the lock; and the waiting test releases the lock only once the setup is seen blocked in flock, so a setup that never waits can't pass it.
| if ! { mkdir -p -m 0755 "${lock%/*}" && exec {lock_fd}>>"$lock"; } 2>/dev/null || ! 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 |
There was a problem hiding this comment.
Lock errors get blamed elsewhere
If Touch ID is already enabled but the driver options are missing, enable-fingerprint reports that another setup is running even when it could not open the lock. The actual error is hidden, so retrying will not help when the lock path cannot be opened.
Separate the open-failure message from the timeout message, as disable-fingerprint and touchid-enable already do.
| if ! { mkdir -p -m 0755 "${lock%/*}" && exec {lock_fd}>>"$lock"; } 2>/dev/null || ! 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 ! { 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 |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed in #61 (merged here before this was addressed), with a test for the unopenable lock.
Summary
Three hardening follow-ups to Touch ID from the review of #12, in
omarchy-mac0.2.1. Nothing changes for a Mac whose setup already works.touchid-root-keywrites the Neo's key through a sharedmsrk-j700.bin.newand unlinks a stale copy first, so two setups at once could delete each other's open temporary file, or install the other's unfinished key.touchid-enableanddisable-fingerprintnow take oneflockon/run/omarchy-mac/touchid.lock, waiting up to five minutes for a run in progress, then fail without touching anything.enable-fingerprintrepairs an agreed Mac's missing driver options under the same lock, so a removal running at the same time can't be undone. A lock that can't be opened is reported as such, not as a setup still running.touchid-enabletrusted anyapple/msrk-j700.binthat existed. Each copy is now checked withtouchid-root-key --check, which reuses the envelope check a rebuilt key already passes:updatesis rebuilt, and is removed if the rebuild fails;--checkexits other than 0 or 3) stops setup and leaves the key alone;vendordirectory stops setup and names the file, since a rebuild inupdateswould not replace it;factory_records()capped each record at 16 MiB, but not the number of entries or the total kept in memory. It now refuses an archive past 16384 entries, or whose records total more than 32 MiB. asahi-installer's archive holds the recovery's whole/usr/share/firmwaretree, the FUD firmware and the factory cache. On an M4 Pro MacBook Pro (macOS 26.6.2) that tree has 3,564 entries, the factory cache 25, and the MSRk, seal and trust records about 16 KB, so the caps leave about 4× and 2,000× headroom. These numbers come from the host macOS, not a Neo's archive.Evidence
omarchy-mac/test/allon Arch Linux ARM (aarch64 container), 2026-10-24: 108 ok, exit 0. The Touch ID suite also passes at each of the four commits.New tests:
updatesis rebuilt, root-only;vendorstops setup and is left alone;More tests:
updateskey that can't be rebuilt is removed;The waiting test releases the lock only once the setup is seen blocked in
flock, so a setup that never waits can't pass it.Every new test fails against a deliberate break (10 in all):
Review: GPT-6 Astra (high) found no correctness blocker. Its four P3s are fixed in 8b76938: a checker failure taken for a broken key, a waiting test that could falsely pass, the misleading lock-open error, and the unlocked options repair. It also asked for real-archive sizing, now above. The manual doesn't describe Touch ID setup, so it has no change.
Not run on hardware. No setup path changes for a Mac with no key, or with a whole one.
Needs maintainer opt-in
Two restrictions are deliberate, and the review flagged them as policy rather than plain hardening:
vendorfirmware directory, where it went ahead before.Both stop a Mac that would have loaded a broken key. If either should warn and go on instead, say so and I'll change it.
Merge Danger
Door: two-way
Setup can now stop where it went ahead before: on a Neo whose installed key is broken outside
updates, or whose key exists but Python doesn't. Either Mac would have loaded a broken key.Blast Radius: Macs with Touch ID; on the key check, MacBook Neo only