Skip to content
Closed
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
14 changes: 12 additions & 2 deletions bin/omarchy-setup-security-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 10 additions & 1 deletion test/shell.d/fingerprint-driver-migration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
25 changes: 25 additions & 0 deletions test/shell.d/fingerprint-package-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down