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
4 changes: 3 additions & 1 deletion bin/omarchy-apply-lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ auth required pam_faillock.so authsucc
account include system-local-login
EOF

# Pinned rather than resolved through PATH, so a root run never executes a
# user-planted fprintd-list. Enrolled prints list as " - #0: right-index-finger".
if [[ -x /usr/bin/fprintd-list ]] &&
/usr/bin/fprintd-list "$target_user" 2>/dev/null | grep -qi finger; then
/usr/bin/fprintd-list "$target_user" 2>/dev/null | grep -qE '^[[:space:]]*-[[:space:]]*#[0-9]+:'; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Enrollment checks remain duplicated

omarchy-apply-lock still has its own copy of the enrolled-entry pattern, separate from omarchy-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.

echo "Configuring lock screen fingerprint authentication..."
as_root tee /etc/pam.d/omarchy-lock-fingerprint >/dev/null <<'EOF'
#%PAM-1.0
Expand Down
16 changes: 16 additions & 0 deletions bin/omarchy-hw-fingerprint-enrolled
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]+:'
2 changes: 1 addition & 1 deletion shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ Item {

Process {
id: fingerprintCheckProc
command: ["bash", "-c", "if [[ -f /etc/pam.d/omarchy-lock-fingerprint ]] && command -v fprintd-list >/dev/null 2>&1 && fprintd-list \"$USER\" 2>/dev/null | grep -qi finger; then echo yes; else echo no; fi"]
command: ["bash", "-c", "if [[ -f /etc/pam.d/omarchy-lock-fingerprint ]] && omarchy-hw-fingerprint-enrolled; then echo yes; else echo no; fi"]
stdout: StdioCollector { id: fingerprintCheckStdout; waitForEnd: true }
onExited: {
root.fingerprintConfigured = String(fingerprintCheckStdout.text || "").trim() === "yes"
Expand Down
10 changes: 5 additions & 5 deletions test/shell.d/apply-lock-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Empty enrollment lacks apply test

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"
Expand Down Expand Up @@ -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
}
Expand Down
83 changes: 83 additions & 0 deletions test/shell.d/hw-fingerprint-enrolled-test.sh
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"