From 0b1c7e8d586c397d5fb8c1366bfb49a41b19c29a Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Fri, 23 Oct 2026 08:08:51 -0500 Subject: [PATCH 1/2] Delete the reader's own copy of the prints when removing fingerprints A match-on-chip reader keeps the enrolled prints in the device as well as in /var/lib/fprint, and fprintd finds the device's copies only through its local records. So removal now deletes them with fprintd-delete while fprintd still runs, before the local files go. It authenticates sudo in view first, since the delete's output is captured; a refusal changes nothing. A delete that finds no reader is said plainly, and one that fails is reported without stopping the removal. The enrolment instructions also move to short lines, since the setup terminal wraps a long one mid-word. Split out of omacom/omarchy#16360, which builds the Touch ID hooks on it. Co-Authored-By: Claude Opus 5.5 --- bin/omarchy-remove-security-fingerprint | 18 +++++++ bin/omarchy-setup-security-fingerprint | 7 +-- docs/file-layout.md | 2 +- test/shell.d/fingerprint-package-test.sh | 15 ++++-- .../security-fingerprint-remove-test.sh | 52 ++++++++++++++++++- 5 files changed, 84 insertions(+), 10 deletions(-) diff --git a/bin/omarchy-remove-security-fingerprint b/bin/omarchy-remove-security-fingerprint index 7c2254bea7b2..e4fefe742699 100755 --- a/bin/omarchy-remove-security-fingerprint +++ b/bin/omarchy-remove-security-fingerprint @@ -59,6 +59,24 @@ remove_resume_hook() { echo -e "\e[32mRemoving fingerprint scanner from authentication.\n\e[0m" +# A match-on-chip reader (Touch ID among them) keeps the prints in the device as +# well, so fprintd deletes them there first, while it still runs. A reader with +# no prints, or no fprintd, leaves nothing to delete. Authenticating first keeps +# sudo's own prompt in view, since the delete's output is not. +if ! sudo -n true 2>/dev/null && ! sudo -v; then + echo -e "\e[31mRemoving fingerprint authentication needs administrator rights.\e[0m" + exit 1 +fi +# fprintd finds no reader when it is off or unplugged: then nothing could be +# deleted from it, which is said plainly rather than as a failure. +if omarchy-cmd-present fprintd-delete && ! delete_output=$(sudo fprintd-delete "$fingerprint_user" 2>&1); then + if [[ $delete_output == *"No devices available"* ]]; then + echo -e "\e[33mNo fingerprint reader is available now, so any fingerprints stored on the reader itself stay there.\e[0m" + else + echo -e "\e[33mThe reader's own copy of $fingerprint_user's fingerprints may not have been deleted: $(tail -n 1 <<<"$delete_output")\e[0m" + fi +fi + remove_pam_config remove_lock_fingerprint_pam remove_resume_hook diff --git a/bin/omarchy-setup-security-fingerprint b/bin/omarchy-setup-security-fingerprint index 8bb5fe520b5a..ceb05682f19c 100755 --- a/bin/omarchy-setup-security-fingerprint +++ b/bin/omarchy-setup-security-fingerprint @@ -168,11 +168,12 @@ fi echo -e "\e[32m\nLet's set up your right index finger as the first fingerprint.\e[0m" # A press sensor needs a touch for each sample; a swipe sensor a moving finger. -# When fprintd can't say which, the prompts name neither. +# When fprintd can't say which, the prompts name neither. Each line stays short, +# since the setup terminal wraps a long one mid-word. case $(fingerprint_reader scan-type) in press) start="Touch the sensor." again="Keep lifting your finger and touching the sensor." - echo -e "Touch the sensor, lift your finger and touch it again, and keep going until it says Enrolled. A step can take a few touches.\n" + echo -e "Touch the sensor, lift your finger and touch it again.\nKeep going until it says Enrolled. A step can take a few touches.\n" ;; swipe) start="Swipe your finger across the sensor." again="Swipe it again." @@ -180,7 +181,7 @@ case $(fingerprint_reader scan-type) in ;; *) start="Touch or swipe the sensor." again="Touch or swipe it again." - echo -e "Touch or swipe the sensor, and keep going until it says Enrolled. A step can take a few tries.\n" + echo -e "Touch or swipe the sensor, and keep going until it says Enrolled.\nA step can take a few tries.\n" ;; esac diff --git a/docs/file-layout.md b/docs/file-layout.md index 3f297b9d9faa..de99280a2cae 100644 --- a/docs/file-layout.md +++ b/docs/file-layout.md @@ -183,7 +183,7 @@ No environment variable moves the file: these commands also run under `sudo` and `omarchy-hw-fingerprint` finds USB readers by their product string or vendor. A reader the kernel drives some other way (a Mac's Touch ID sensor, behind its Secure Enclave) is named by the platform package in `/usr/share/omarchy-platform/fingerprint-readers`; Omarchy ships none. Each line is an absolute path, a shell glob, then the value that file reads once the reader is usable; the reader is present when any file the glob matches reads that value. The value must be the file's whole content, not part of it (Touch ID reads `not-ready` before it reads `ready`). Three details decide a match: the file's trailing newlines are dropped before comparing (sysfs ends every value with one), fields are split on whitespace (so neither the glob nor the value can contain a space), and the file is read as the user running the check, the session user, so it must be readable by that user and not only by root. Blank lines, whole-line `#` comments, relative paths and lines with a missing or extra word are ignored. A platform file never hides a USB reader: when no platform-named file matches, the USB scan still runs. On Apple Silicon, omarchy-mac names `/sys/bus/platform/drivers/apple_sep/*/diag/touchid ready`. That file is `0444 root:root`, so the session user can read it. The line follows the kernel's names for the Secure Enclave driver (`apple_sep`) and its `diag/touchid` attribute: if a kernel renames either, the reader and the first-run invitation quietly stop appearing, so the platform package changes the line along with its kernel. -The rest of the fingerprint path is the same for every reader: the setup's first-run invitation follows `omarchy-hw-fingerprint`, so it reaches a machine once its platform's reader is usable, and `omarchy-setup-security-fingerprint` installs `libfprint-git`. Setup can only enroll a platform's reader once that package carries its driver; for a Mac's Touch ID that is the aarch64 build from omacom/omarchy-pkgs#806. `test/shell.d/hw-fingerprint-test.sh` runs a copy rewritten to read a fixture in place of the file. +The rest of the fingerprint path is the same for every reader: the setup's first-run invitation follows `omarchy-hw-fingerprint`, so it reaches a machine once its platform's reader is usable, and `omarchy-setup-security-fingerprint` installs `libfprint-git`. Removal (`omarchy-remove-security-fingerprint`) authenticates `sudo` in view, then deletes the user's prints through `fprintd-delete` while fprintd still runs, since a match-on-chip reader (a Mac's Touch ID among them) keeps them in the device too; a delete that fails, or finds no reader, is reported and doesn't stop the removal. Setup can only enroll a platform's reader once that package carries its driver; for a Mac's Touch ID that is the aarch64 build from omacom/omarchy-pkgs#806. `test/shell.d/hw-fingerprint-test.sh` runs a copy rewritten to read a fixture in place of the file. #### Audio hints (`audio.json`) diff --git a/test/shell.d/fingerprint-package-test.sh b/test/shell.d/fingerprint-package-test.sh index ba599f4fc9f0..9664b481f576 100755 --- a/test/shell.d/fingerprint-package-test.sh +++ b/test/shell.d/fingerprint-package-test.sh @@ -153,19 +153,24 @@ pass "an inconclusive lock installer cannot report successful lock setup" # A press sensor, such as a Mac's Touch ID, takes a touch per sample, so setup # says to lift and touch again; a swipe sensor keeps the moving-finger # instruction, and one fprintd can't name is told neither. -press_text="Touch the sensor, lift your finger and touch it again, and keep going until it says Enrolled. A step can take a few touches." +press_text=$'Touch the sensor, lift your finger and touch it again.\nKeep going until it says Enrolled. A step can take a few touches.' swipe_text="Keep moving the finger around on sensor until it says Enrolled." -unnamed_text="Touch or swipe the sensor, and keep going until it says Enrolled. A step can take a few tries." +unnamed_text=$'Touch or swipe the sensor, and keep going until it says Enrolled.\nA step can take a few tries.' check_instruction() { INSTALLED=$'libfprint-git\nfprintd\nusbutils' SCAN_TYPE=$1 run_setup - local text + local text output + output=$(<"$scratch/output") for text in "$press_text" "$swipe_text" "$unnamed_text"; do if [[ $text == "$2" ]]; then - grep -qF "$text" "$scratch/output" || fail "$3" "$(cat "$scratch/output")" + [[ $output == *"$text"* ]] || fail "$3" "$output" else - ! grep -qF "$text" "$scratch/output" || fail "$3" "$(cat "$scratch/output")" + [[ $output != *"$text"* ]] || fail "$3" "$output" fi done + # The setup terminal wraps a long line mid-word. + while IFS= read -r text; do + (( ${#text} <= 80 )) || fail "$3: the instruction fits on an 80-column line" "$text" + done <<<"$2" } check_instruction press "$press_text" "a press sensor is told to lift and touch again" check_instruction swipe "$swipe_text" "a swipe sensor keeps the moving-finger instruction" diff --git a/test/shell.d/security-fingerprint-remove-test.sh b/test/shell.d/security-fingerprint-remove-test.sh index 1a8e0fe18941..d089fc7df5d9 100755 --- a/test/shell.d/security-fingerprint-remove-test.sh +++ b/test/shell.d/security-fingerprint-remove-test.sh @@ -38,11 +38,23 @@ printf 'bob\n' SH cat >"$test_tmp/bin/sudo" <<'SH' #!/bin/bash +case $1 in + -n) exit "${TEST_SUDO_CACHED:-0}" ;; + -v) printf 'sudo -v\n' >>"$TEST_LOG"; exit "${TEST_SUDO_V_FAIL:-0}" ;; +esac printf 'sudo %s\n' "$*" >>"$TEST_LOG" +if [[ $* == "fprintd-delete $TEST_EXPECTED_USER" ]]; then + (( ${TEST_PRINTS_FAIL:-0} == 0 )) || echo "${TEST_PRINTS_OUTPUT:-delete failed}" + exit "${TEST_PRINTS_FAIL:-0}" +fi [[ $# == 4 && $1 == rm && $2 == -rf && $3 == -- && $4 == "$TEST_FPRINT/$TEST_EXPECTED_USER" ]] || exit 91 [[ ${TEST_DELETE_FAIL:-0} == 0 ]] || exit 92 exec /usr/bin/rm -rf -- "$4" SH +cat >"$test_tmp/bin/omarchy-cmd-present" <<'SH' +#!/bin/bash +[[ $1 == fprintd-delete && ${TEST_FPRINTD:-1} == 1 ]] +SH cat >"$test_tmp/bin/omarchy-pkg-drop" <<'SH' #!/bin/bash printf 'package %s\n' "$*" >>"$TEST_LOG" @@ -73,7 +85,9 @@ run_remove() { "TEST_LOG=$log" "TEST_FPRINT=$test_tmp/fprint" "TEST_EXPECTED_USER=$expected" "TEST_DIRECT_USER=$direct_user" "TEST_SUDO_USER=$sudo_user" "TEST_SUDO_UID=${SUDO_UID:-}" "TEST_ID_FAIL=${id_fail:-0}" "TEST_DELETE_FAIL=${delete_fail:-0}" - "TEST_PACKAGE_FAIL=${package_fail:-0}" "USER=spoofed" "SUDO_USER=spoofed" + "TEST_PACKAGE_FAIL=${package_fail:-0}" "TEST_PRINTS_FAIL=${prints_fail:-0}" "TEST_FPRINTD=${fprintd:-1}" + "TEST_PRINTS_OUTPUT=${prints_output:-}" "TEST_SUDO_CACHED=${sudo_cached:-0}" "TEST_SUDO_V_FAIL=${sudo_v_fail:-0}" + "USER=spoofed" "SUDO_USER=spoofed" "PATH=$test_tmp/bin:/usr/bin:/bin" ) if (( EUID == 0 )); then @@ -99,6 +113,42 @@ grep -Fq "sudo rm -rf -- $test_tmp/fprint/alice" "$log" || fail "deletion preced grep -Fq "alice's local saved fingerprints have been removed" "$output" || fail "success describes local saved files" pass "direct user ignores spoofed USER and leaves other accounts alone" +# A match-on-chip reader keeps prints in the device too: fprintd deletes them +# there before anything else goes. +[[ $(grep -m1 '^sudo ' "$log") == 'sudo fprintd-delete alice' ]] || fail "fprintd deletes the prints first" "$(cat "$log")" +! grep -q 'may' "$output" || fail "a delete that worked warns about nothing" "$(cat "$output")" +prints_fail=1 +mkdir -p "$test_tmp/fprint/alice" +run_remove || fail "a failed fprintd delete does not stop removal" "$(cat "$output")" +grep -q "may not have been deleted: delete failed" "$output" && [[ ! -e $test_tmp/fprint/alice ]] || + fail "a failed delete is reported, and the local files still go" "$(cat "$output")" +prints_output="No devices available" +run_remove || fail "removal with no reader available succeeds" "$(cat "$output")" +grep -q 'No fingerprint reader is available now' "$output" && ! grep -q 'may not have been deleted' "$output" || + fail "no reader to delete from is said plainly, not as a failed delete" "$(cat "$output")" +unset prints_fail prints_output +fprintd=0 +run_remove || fail "removal without fprintd succeeds" "$(cat "$output")" +! grep -q '^sudo fprintd-delete' "$log" || fail "without fprintd nothing asks it to delete" +unset fprintd +pass "prints are deleted in the reader first, and a delete that can't run doesn't stop removal" + +# sudo asks in view before the silenced delete, and a refusal changes nothing. +sudo_cached=1 +run_remove || fail "removal with sudo to authenticate succeeds" "$(cat "$output")" +[[ $(grep -m2 '^sudo ' "$log") == $'sudo -v\nsudo fprintd-delete alice' ]] || fail "sudo authenticates before the delete" "$(cat "$log")" +mkdir -p "$test_tmp/fprint/alice" +printf 'auth sufficient pam_fprintd.so\n' >"$test_tmp/etc/pam.d/sudo" +sudo_v_fail=1 +if run_remove; then + fail "removal stops when sudo won't authenticate" +fi +! grep -Eq '^sudo [^-]|^package ' "$log" && grep -Fq pam_fprintd.so "$test_tmp/etc/pam.d/sudo" && [[ -d $test_tmp/fprint/alice ]] && + grep -q 'needs administrator rights' "$output" || fail "a refused sudo changes nothing, and removal says why" "$(cat "$log"; cat "$output")" +: >"$test_tmp/etc/pam.d/sudo" +unset sudo_cached sudo_v_fail +pass "sudo authenticates in view before the delete, and a refusal changes nothing" + SUDO_UID=12345 run_remove || fail "unprivileged caller ignores forged SUDO_UID" "$(cat "$output")" grep -Fxq 'id -un' "$log" || fail "unprivileged caller must resolve itself" From f157fec3ce31e2313f2d902f519a80028a9d8e09 Mon Sep 17 00:00:00 2001 From: Omarchybot <317366263+omarchybot@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:33:39 +0200 Subject: [PATCH 2/2] Drop the width check that measured the test's own text The loop read the expected instruction the test passes in, not what setup printed, so it could only fail if someone edited the test's string; the exact-output match above already holds setup to that text. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Codex Medium --- test/shell.d/fingerprint-package-test.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/shell.d/fingerprint-package-test.sh b/test/shell.d/fingerprint-package-test.sh index 9664b481f576..a3fff9546a23 100755 --- a/test/shell.d/fingerprint-package-test.sh +++ b/test/shell.d/fingerprint-package-test.sh @@ -167,10 +167,6 @@ check_instruction() { [[ $output != *"$text"* ]] || fail "$3" "$output" fi done - # The setup terminal wraps a long line mid-word. - while IFS= read -r text; do - (( ${#text} <= 80 )) || fail "$3: the instruction fits on an 80-column line" "$text" - done <<<"$2" } check_instruction press "$press_text" "a press sensor is told to lift and touch again" check_instruction swipe "$swipe_text" "a swipe sensor keeps the moving-finger instruction"