Repository navigation
Fingerprint setup: keep working forks; silent lid-open PAM gate #12110
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
base: quattro
Are you sure you want to change the base?
Changes from 8 commits
69215e2
0b1b9ec
5a27769
66ef718
b2b51d2
f6abb11
732b209
d9f9020
eb6f8e4
f6cd159
7383339
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,18 @@ | ||
| #!/bin/bash | ||
|
|
||
| # omarchy:summary=Returns true when the laptop lid is open | ||
| # omarchy:hidden=true | ||
|
|
||
| # Inverse of omarchy-hw-laptop-closed. The fingerprint PAM gate uses this so the | ||
| # common path (lid open) exits 0 and pam_exec does not LOG_ERR on every | ||
| # sudo/polkit auth (#10254). Callers that want "is closed?" keep using | ||
| # omarchy-hw-laptop-closed. | ||
|
|
||
| for state in /proc/acpi/button/lid/*/state; do | ||
| [[ -r $state ]] || continue | ||
| [[ $(<"$state") == *"closed"* ]] && exit 1 | ||
| [[ $(<"$state") == *"open"* ]] && exit 0 | ||
| done | ||
|
|
||
| # No lid switch (desktop): treat as open so fingerprint stays available. | ||
| exit 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,24 +8,30 @@ set -e | |
|
|
||
| setup_pam_config() { | ||
| # A clamshell gate runs before pam_fprintd in every stack: when the lid is | ||
| # shut the reader is unreachable, so it skips fingerprint (success=1) and PAM | ||
| # drops straight to the password prompt instead of blocking on the reader | ||
| # until it times out. Lid open → fingerprint, then password as the fallback. | ||
| # shut the reader is unreachable, so fingerprint is skipped and PAM drops | ||
| # straight to the password prompt instead of blocking on the reader until it | ||
| # times out. Lid open → fingerprint, then password as the fallback. | ||
| # | ||
| # pam_exec needs a literal absolute path (no env expansion). Point at the | ||
| # fixed /usr/bin path the omarchy package always provides, so the gate keeps | ||
| # working across package installs and dev-link — the latter overlays | ||
| # $OMARCHY_PATH trees but leaves /usr/bin untouched. | ||
| local fprintd_gate="auth [success=1 default=ignore] pam_exec.so quiet /usr/bin/omarchy-hw-laptop-closed" | ||
| # | ||
| # Use omarchy-hw-laptop-open (exit 0 when open) so the common path does not | ||
| # make pam_exec LOG_ERR on every sudo/polkit auth (#10254). success=ignore | ||
| # continues to pam_fprintd; default=1 skips it when the lid is closed. | ||
| local fprintd_gate="auth [success=ignore default=1] pam_exec.so quiet /usr/bin/omarchy-hw-laptop-open" | ||
|
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.
|
||
|
|
||
| # Configure sudo | ||
| if ! grep -q pam_fprintd.so /etc/pam.d/sudo; then | ||
| echo "Configuring sudo for fingerprint authentication..." | ||
| sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/sudo | ||
| fi | ||
| if ! grep -q 'omarchy-hw-laptop-closed' /etc/pam.d/sudo; then | ||
| # Drop any prior polarity of the gate, then insert the silent lid-open form | ||
| # immediately before pam_fprintd so default=1 skips exactly that module. | ||
| sudo sed -i -e '/omarchy-hw-laptop-closed/d' -e '/omarchy-hw-laptop-open/d' /etc/pam.d/sudo | ||
| if ! grep -q 'omarchy-hw-laptop-open' /etc/pam.d/sudo; then | ||
| echo "Adding clamshell gate to sudo..." | ||
| # Insert immediately before pam_fprintd so success=1 skips exactly it. | ||
| sudo sed -i "/pam_fprintd\.so/i $fprintd_gate" /etc/pam.d/sudo | ||
| fi | ||
|
|
||
|
|
@@ -35,7 +41,8 @@ setup_pam_config() { | |
| echo "Configuring polkit for fingerprint authentication..." | ||
| sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/polkit-1 | ||
| fi | ||
| if ! grep -q 'omarchy-hw-laptop-closed' /etc/pam.d/polkit-1; then | ||
| sudo sed -i -e '/omarchy-hw-laptop-closed/d' -e '/omarchy-hw-laptop-open/d' /etc/pam.d/polkit-1 | ||
| if ! grep -q 'omarchy-hw-laptop-open' /etc/pam.d/polkit-1; then | ||
| echo "Adding clamshell gate to polkit..." | ||
| sudo sed -i "/pam_fprintd\.so/i $fprintd_gate" /etc/pam.d/polkit-1 | ||
| fi | ||
|
|
@@ -64,13 +71,40 @@ if ! omarchy-hw-fingerprint; then | |
| exit 1 | ||
| fi | ||
|
|
||
| # libfprint-git tracks upstream ahead of the Arch release, so a new reader only | ||
| # 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 | ||
| # Prefer libfprint-git (tracks upstream ahead of Arch). Stock libfprint is | ||
| # still replaced so a new reader only needs a pin bump in omarchy-pkgs. A | ||
| # community fork that already provides libfprint / libfprint-2 must be left | ||
| # alone — pacman -Qq is provides-aware, while omarchy-pkg-missing libfprint-git | ||
| # is not, and --ask 4 would otherwise silently evict the working driver | ||
| # (see #11899). After any package change, restart fprintd so enroll/verify | ||
| # talk to the on-disk library instead of a stale in-memory .so. | ||
| libfprint_pkgs=() | ||
| while IFS= read -r pkg; do | ||
| [[ -n $pkg ]] && libfprint_pkgs+=("$pkg") | ||
| done < <(pacman -Qq libfprint libfprint-2 libfprint-git 2>/dev/null | sort -u) | ||
|
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.
|
||
|
|
||
| need_packages=() | ||
| if ((${#libfprint_pkgs[@]} == 0)) || | ||
| { ((${#libfprint_pkgs[@]} == 1)) && [[ ${libfprint_pkgs[0]} == libfprint ]]; }; then | ||
| # Missing entirely, or only Arch stock — install / replace with libfprint-git. | ||
| need_packages+=(libfprint-git) | ||
| fi | ||
| if omarchy-pkg-missing fprintd; then | ||
| need_packages+=(fprintd) | ||
| fi | ||
| if omarchy-pkg-missing usbutils; then | ||
| need_packages+=(usbutils) | ||
| fi | ||
|
|
||
| if ((${#need_packages[@]} > 0)); then | ||
| echo "Installing required packages..." | ||
| sudo pacman -S --needed --noconfirm --ask 4 -- libfprint-git fprintd usbutils | ||
| # Conflicts with stock libfprint: --noconfirm would answer N; --ask 4 accepts | ||
| # the replacement in one transaction so a failed install leaves the existing | ||
| # driver in place. | ||
| sudo pacman -S --needed --noconfirm --ask 4 "${need_packages[@]}" | ||
| # D-Bus activation keeps a running fprintd mapped to the library that was | ||
| # just replaced; without a restart, enroll can "succeed" against the old .so. | ||
| sudo systemctl try-restart fprintd.service 2>/dev/null || true | ||
|
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.
|
||
| fi | ||
|
|
||
| # Enroll first fingerprint | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| echo "Drop the lid gate from lock-screen fingerprint PAM" | ||
|
|
||
| # An earlier revision of this migration (and setup/apply-lock) inserted | ||
| # omarchy-hw-laptop-open with [success=ignore default=1] before pam_fprintd. | ||
| # On the lock PamContext that skip is PAM success and unlocks with the lid | ||
| # closed. Remove the gate; lid policy stays in the lock service (#10393). | ||
|
|
||
| pam=/etc/pam.d/omarchy-lock-fingerprint | ||
|
|
||
| if [[ -f $pam ]] && grep -q 'omarchy-hw-laptop-open' "$pam"; then | ||
| sudo sed -i '/omarchy-hw-laptop-open/d' "$pam" | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| echo "Silence the fingerprint clamshell PAM gate on the common lid-open path" | ||
|
|
||
| # The previous gate ran omarchy-hw-laptop-closed with [success=1 default=ignore]. | ||
| # Lid open (the usual case) exited 1, and pam_exec logged that at LOG_ERR on | ||
| # every sudo/polkit auth (#10254). Flip to omarchy-hw-laptop-open with | ||
| # [success=ignore default=1] so control flow stays the same but the common | ||
| # path exits 0. | ||
| # | ||
| # Lock is a separate PamContext whose only auth module is pam_fprintd. | ||
| # Skipping it (default=1) would unlock with the lid shut. Leave that stack | ||
| # alone; lid-closed skip on the lock screen belongs in the lock service. | ||
|
|
||
| gate='auth [success=ignore default=1] pam_exec.so quiet /usr/bin/omarchy-hw-laptop-open' | ||
|
|
||
| for pam in /etc/pam.d/sudo /etc/pam.d/polkit-1; do | ||
| [[ -f $pam ]] || continue | ||
| grep -q 'pam_fprintd\.so' "$pam" || continue | ||
|
|
||
| # Already on the silent polarity. | ||
| if grep -q 'omarchy-hw-laptop-open' "$pam"; then | ||
| continue | ||
| fi | ||
|
|
||
| sudo sed -i -e '/omarchy-hw-laptop-closed/d' -e '/omarchy-hw-laptop-open/d' "$pam" | ||
| if ! grep -q 'omarchy-hw-laptop-open' "$pam"; then | ||
| sudo sed -i "/pam_fprintd\.so/i $gate" "$pam" | ||
| fi | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # The fingerprint clamshell gate must exit 0 on the common lid-open path so | ||
| # pam_exec does not fill the journal with LOG_ERR on every sudo/polkit auth. | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| helper="$ROOT/bin/omarchy-hw-laptop-open" | ||
| [[ -x $helper ]] || fail "omarchy-hw-laptop-open is executable" | ||
|
|
||
| # Match the closed helper's ACPI path convention. | ||
| grep -q '/proc/acpi/button/lid' "$helper" || | ||
| fail "omarchy-hw-laptop-open reads the ACPI lid state" | ||
|
|
||
| grep -q 'exit 1' "$helper" || | ||
| fail "omarchy-hw-laptop-open exits 1 when the lid is closed" | ||
|
|
||
| grep -q 'exit 0' "$helper" || | ||
| fail "omarchy-hw-laptop-open exits 0 when the lid is open" | ||
|
Comment on lines
+14
to
+21
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.
These checks search for exit statements without running the lid helper, so they can pass when lid detection is broken. Run the helper against open and closed lid states, check the files setup writes, and remove the migration-source checks. These repository requirements must be satisfied before merging. File Used: Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| pass "omarchy-hw-laptop-open is the silent lid-open helper" | ||
|
|
||
| setup="$ROOT/bin/omarchy-setup-security-fingerprint" | ||
| grep -q 'omarchy-hw-laptop-open' "$setup" || | ||
| fail "fingerprint setup installs the lid-open PAM gate" | ||
|
|
||
| grep -q '\[success=ignore default=1\]' "$setup" || | ||
| fail "fingerprint setup uses success=ignore default=1 for the lid-open gate" | ||
|
|
||
| ! grep -q 'omarchy-hw-laptop-closed' <<<"$(grep fprintd_gate= "$setup")" || | ||
| fail "fingerprint setup gate line must not call omarchy-hw-laptop-closed" | ||
|
|
||
| pass "fingerprint setup installs the silent lid-open PAM gate" | ||
|
|
||
| remove="$ROOT/bin/omarchy-remove-security-fingerprint" | ||
| grep -q 'omarchy-hw-laptop-open' "$remove" || | ||
| fail "fingerprint remove strips the lid-open PAM gate" | ||
|
|
||
| pass "fingerprint remove strips both gate polarities" | ||
|
|
||
| migration="$ROOT/migrations/1789400300.sh" | ||
| [[ -f $migration ]] || fail "a migration rewrites existing PAM gates to the silent polarity" | ||
| grep -q 'omarchy-hw-laptop-open' "$migration" || | ||
| fail "migration installs the lid-open PAM gate" | ||
| grep -q 'omarchy-hw-laptop-closed' "$migration" || | ||
| fail "migration removes the lid-closed PAM gate" | ||
| grep -q '/etc/pam.d/sudo' "$migration" || | ||
| fail "migration rewrites sudo" | ||
| grep -q '/etc/pam.d/polkit-1' "$migration" || | ||
| fail "migration rewrites polkit" | ||
| ! grep -q 'omarchy-lock-fingerprint' "$migration" || | ||
| fail "migration must not gate the lock PAM stack (skipping pam_fprintd unlocks)" | ||
|
|
||
| pass "migration flips sudo/polkit fingerprint PAM gates to the silent polarity" | ||
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-hw-laptop-opentreats every laptop without an ACPI lid file as open. The existingomarchy-hw-laptop-closedalso checks input lid switches through logind, including on supported Apple Silicon MacBooks.After setup or migration switches PAM to this helper, those laptops stop skipping fingerprint authentication when closed. Sudo and polkit can wait for an unreachable reader instead of going straight to the password prompt. Preserve the existing helper’s non-ACPI check when reversing its result.
Knowledge Base Used: Hardware, devices, and power