Repository navigation
Detect fingerprint enrollment by the enrolled entries, not the word "finger" #9551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f5ea640
942a5ee
b172596
520a9cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
|
|
||
| # omarchy:summary=Returns true when a user has fingerprints enrolled | ||
| # omarchy:hidden=true | ||
|
|
||
| user=${1:-$USER} | ||
|
|
||
| # fprintd arrives with the fingerprint setup, so a machine that never ran it has | ||
| # nothing to ask. | ||
| omarchy-cmd-present fprintd-list || exit 1 | ||
|
|
||
| # fprintd-list states an empty enrollment in prose — "User kalle has no fingers | ||
| # enrolled for Goodix MOC Fingerprint Sensor." — so matching the word "finger" | ||
| # reads as enrolled either way. Enrolled fingers are listed one per line as | ||
| # " - #0: right-index-finger"; that shape is what separates the two. | ||
| fprintd-list "$user" 2>/dev/null | grep -qE '^[[:space:]]*-[[:space:]]*#[0-9]+:' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,15 +85,15 @@ cat >"$trusted_fprintd" <<'EOF' | |
|
|
||
| printf '%s\n' "$EUID" >"$TEST_TRUSTED_UID" | ||
| printf '%s\n' "$*" >"$TEST_TRUSTED_ARGS" | ||
| echo "Fingerprints are enrolled" | ||
| echo " - #0: right-index-finger" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This fixture always prints an enrolled finger, so the apply-lock test never checks that an empty enrollment leaves the fingerprint PAM file absent or removes an existing one. The new helper test checks only the helper; a regression in apply-lock’s separate check could therefore go unnoticed. |
||
| EOF | ||
|
|
||
| cat >"$poison_bin/fprintd-list" <<'EOF' | ||
| #!/bin/bash | ||
|
|
||
| printf '%s\n' "$EUID" >"$TEST_ATTACK_MARKER" | ||
| printf '%s\n' "$*" >"$TEST_ATTACK_ARGS" | ||
| echo "Fingerprints are enrolled" | ||
| echo " - #0: right-index-finger" | ||
| EOF | ||
|
|
||
| chmod +x "$trusted_fprintd" "$poison_bin/fprintd-list" | ||
|
|
@@ -129,11 +129,11 @@ prepare_helper() { | |
| } | ||
| next | ||
| } | ||
| if (line == " /usr/bin/fprintd-list \"$target_user\" 2>/dev/null | grep -qi finger; then") { | ||
| if (line == " /usr/bin/fprintd-list \"$target_user\" 2>/dev/null | grep -qE \047^[[:space:]]*-[[:space:]]*#[0-9]+:\047; then") { | ||
| if (use_absolute_fprintd == 1) { | ||
| print " \"" trusted_fprintd "\" \"$target_user\" 2>/dev/null | grep -qi finger; then" | ||
| print " \"" trusted_fprintd "\" \"$target_user\" 2>/dev/null | grep -qE \047^[[:space:]]*-[[:space:]]*#[0-9]+:\047; then" | ||
| } else { | ||
| print " fprintd-list \"$target_user\" 2>/dev/null | grep -qi finger; then" | ||
| print " fprintd-list \"$target_user\" 2>/dev/null | grep -qE \047^[[:space:]]*-[[:space:]]*#[0-9]+:\047; then" | ||
| } | ||
| next | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| tmp_dir=$(mktemp -d) | ||
| trap 'rm -rf "$tmp_dir"' EXIT | ||
|
|
||
| mkdir -p "$tmp_dir/bin" | ||
|
|
||
| # Only the stub and what the helper needs, so an installed fprintd-list never | ||
| # answers for the stub, or for its absence. | ||
| for helper in cat grep; do | ||
| ln -s "$(command -v "$helper")" "$tmp_dir/bin/$helper" | ||
| done | ||
|
|
||
| # The fixture prints what fprintd-list prints, format strings and all: | ||
| # " - #%d: %s" per enrolled finger, and "User %s has no fingers enrolled for | ||
| # %s." when there are none. | ||
| stub_fprintd_list() { | ||
| cat >"$tmp_dir/bin/fprintd-list" | ||
| chmod +x "$tmp_dir/bin/fprintd-list" | ||
| } | ||
|
|
||
| drop_fprintd_list() { | ||
| rm -f "$tmp_dir/bin/fprintd-list" | ||
| } | ||
|
|
||
| fingerprint_enrolled() { | ||
| PATH="$tmp_dir/bin:$ROOT/bin" "$ROOT/bin/omarchy-hw-fingerprint-enrolled" "$@" | ||
| } | ||
|
|
||
| assert_enrolled() { | ||
| local description="$1" | ||
|
|
||
| fingerprint_enrolled alice || fail "$description" | ||
| pass "$description" | ||
| } | ||
|
|
||
| assert_not_enrolled() { | ||
| local description="$1" | ||
|
|
||
| if fingerprint_enrolled alice; then | ||
| fail "$description" | ||
| fi | ||
| pass "$description" | ||
| } | ||
|
|
||
| stub_fprintd_list <<'STUB' | ||
| #!/bin/bash | ||
| cat <<'OUT' | ||
| found 1 devices | ||
| Device at /net/reactivated/Fprint/Device/0 | ||
| Using device /net/reactivated/Fprint/Device/0 | ||
| Fingerprints for user alice on Goodix MOC Fingerprint Sensor (press): | ||
| - #0: right-index-finger | ||
| OUT | ||
| STUB | ||
| assert_enrolled "a user with an enrolled finger reads as enrolled" | ||
|
|
||
| # The reason this command exists: the empty-enrollment message names fingers | ||
| # too, so any match on the word alone reports the opposite of the truth. | ||
| stub_fprintd_list <<'STUB' | ||
| #!/bin/bash | ||
| cat <<'OUT' | ||
| found 1 devices | ||
| Device at /net/reactivated/Fprint/Device/0 | ||
| Using device /net/reactivated/Fprint/Device/0 | ||
| User alice has no fingers enrolled for Goodix MOC Fingerprint Sensor. | ||
| OUT | ||
| STUB | ||
| assert_not_enrolled "an empty enrollment does not read as enrolled" | ||
|
|
||
| stub_fprintd_list <<'STUB' | ||
| #!/bin/bash | ||
| echo "found 0 devices" >&2 | ||
| exit 1 | ||
| STUB | ||
| assert_not_enrolled "a machine with no reader does not read as enrolled" | ||
|
|
||
| drop_fprintd_list | ||
| assert_not_enrolled "a machine without fprintd does not read as enrolled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omarchy-apply-lockstill has its own copy of the enrolled-entry pattern, separate fromomarchy-hw-fingerprint-enrolled. If one pattern changes without the other, PAM configuration and the lock screen could disagree about whether fingerprints are enrolled. Sharing the parsing would prevent that drift while preserving the apply script’s trusted executable lookup.