diff --git a/bin/omarchy-setup-security-fingerprint b/bin/omarchy-setup-security-fingerprint index 0367cefae079..c4252f39d9e0 100755 --- a/bin/omarchy-setup-security-fingerprint +++ b/bin/omarchy-setup-security-fingerprint @@ -68,9 +68,18 @@ fi # needs a pin bump in omarchy-pkgs. It conflicts with stock libfprint, and # --noconfirm answers that prompt with N; --ask 4 accepts the replacement in # one transaction, so a failed install leaves the existing driver in place. -if omarchy-pkg-missing libfprint-git fprintd usbutils; then +# Some readers need a vendor TOD module instead of upstream libfprint's drivers. +# Preserve either explicitly installed TOD library so setup does not replace it. +fingerprint_packages=(fprintd usbutils) +if omarchy-pkg-present libfprint-tod || omarchy-pkg-present libfprint-tod-git; then + echo "Keeping the installed fingerprint TOD driver." +else + fingerprint_packages=(libfprint-git "${fingerprint_packages[@]}") +fi + +if omarchy-pkg-missing "${fingerprint_packages[@]}"; then echo "Installing required packages..." - sudo pacman -S --needed --noconfirm --ask 4 -- libfprint-git fprintd usbutils + sudo pacman -S --needed --noconfirm --ask 4 -- "${fingerprint_packages[@]}" fi # Enroll first fingerprint @@ -98,6 +107,7 @@ if sudo fprintd-enroll "$USER"; then echo "You can use your fingerprint for sudo, polkit, and lock screen (Super + Ctrl + L)." else echo -e "\e[31m\nVerification failed. You may want to try enrolling again.\e[0m" + exit 1 fi else echo -e "\e[31m\nEnrollment failed. Please try again.\e[0m" diff --git a/test/shell.d/fingerprint-driver-migration-test.sh b/test/shell.d/fingerprint-driver-migration-test.sh index 3164c2dd4389..53a03e8ad9ac 100755 --- a/test/shell.d/fingerprint-driver-migration-test.sh +++ b/test/shell.d/fingerprint-driver-migration-test.sh @@ -30,7 +30,10 @@ case "$1" in else shift fi - if grep -qx -- "$1" <<< "${INSTALLED:-}"; then + # pacman -Q also resolves provides: both TOD packages provide libfprint. + if [[ $1 == "libfprint" ]] && grep -Eq '^libfprint-tod(-git)?$' <<< "${INSTALLED:-}"; then + : + elif grep -qx -- "$1" <<< "${INSTALLED:-}"; then : else grep -qx -- "$1" "$INSTALLED_LOG" @@ -69,6 +72,12 @@ INSTALLED=$'libfprint\nfprintd' run_migration [[ ! -s $CALL_LOG ]] || fail "an installed stock libfprint is left alone" "$(<"$CALL_LOG")" pass "an installed stock libfprint is left alone" +for library in libfprint-tod libfprint-tod-git; do + INSTALLED="$library"$'\nfprintd' run_migration + [[ ! -s $CALL_LOG ]] || fail "an installed $library is left alone" "$(<"$CALL_LOG")" + pass "an installed $library is left alone" +done + INSTALLED='' run_migration [[ ! -s $CALL_LOG ]] || fail "a machine without fprintd is left alone" "$(<"$CALL_LOG")" pass "a machine without fprintd is left alone" diff --git a/test/shell.d/fingerprint-package-test.sh b/test/shell.d/fingerprint-package-test.sh index cf67e347f4a2..e8aec21522fe 100755 --- a/test/shell.d/fingerprint-package-test.sh +++ b/test/shell.d/fingerprint-package-test.sh @@ -105,6 +105,31 @@ fi grep -qx enroll "$CALL_LOG" || fail "a rerun with everything installed reaches enrollment" pass "a rerun with everything installed goes straight to enrollment" +for library in libfprint-tod libfprint-tod-git; do + INSTALLED="$library"$'\nfprintd\nusbutils' run_setup + if grep -q '^pacman' "$CALL_LOG"; then + fail "setup preserves an explicitly installed $library" + fi + grep -qx enroll "$CALL_LOG" || fail "an installed $library stack reaches enrollment" + pass "setup preserves an explicitly installed $library stack" + + INSTALLED="$library" run_setup + grep -qx 'pacman -S --needed --noconfirm --ask 4 -- fprintd usbutils' "$CALL_LOG" || + fail "missing clients are installed without replacing $library" + pass "a $library setup installs only its missing clients and USB tools" + + INSTALLED="$library"$'\nfprintd\nusbutils' ENROLL_STATUS=0 VERIFY_STATUS=1 run_setup + [[ $(grep -E '^(enroll|verify)$' "$CALL_LOG") == $'enroll\nverify' ]] || + fail "$library enrollment is verified before authentication changes" + grep -q 'Verification failed' "$scratch/output" || fail "$library verification failure is explained" + pass "failed verification on $library leaves authentication untouched and exits nonzero" +done + +INSTALLED=$'libfprint-git\nfprintd\nusbutils' ENROLL_STATUS=0 VERIFY_STATUS=1 run_setup +grep -qx verify "$CALL_LOG" || fail "default enrollment must also be verified" +grep -q 'Verification failed' "$scratch/output" || fail "default verification failure is explained" +pass "failed verification on the default stack leaves authentication untouched and exits nonzero" + INSTALL_STATUS=1 run_setup if grep -qx enroll "$CALL_LOG"; then fail "a failed package transaction prevents enrollment"