omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Gate sudo fingerprint behind lid state (clamshell)

Open ocewers opened this issue 6 months ago • 0 comments

Problem

When fingerprint auth is set up, omarchy-setup-security-fingerprint inserts auth sufficient pam_fprintd.so at the top of /etc/pam.d/sudo. Because it is first and sufficient, pam_fprintd grabs stdin with "Place your finger…" and blocks the password prompt until it times out.

In clamshell mode (laptop lid closed, docked to an external display) the reader is physically unreachable, so every sudo forces an awkward wait before you can type your password.

Fix (sudo only)

Run pam_fprintd only when the lid is open. PAM can't read lid state, so a tiny pam_exec helper (/usr/local/bin/omarchy-lid-open) gates it:

auth    [success=ignore default=1] pam_exec.so quiet /usr/local/bin/omarchy-lid-open
auth    sufficient                 pam_fprintd.so
auth    include                    system-auth        # (unchanged)
  • Lid open → helper exits 0 → success=ignore → falls through to pam_fprintd → fingerprint as before.
  • Lid closed → helper exits 1 → default=1 → jumps over the fprintd line → straight to the password stack.
  • Helper missing / errors / lid state unknown → non-success → default=1 → password. Fail-safe: never a lockout.

Scope & safety

  • sudo only. /etc/pam.d/polkit-1 is intentionally left as-is — the polkit agent shows a password field in parallel with fingerprint, so it never blocks the way terminal sudo does.
  • Desktops / non-laptops untouched. has_lid() is false when there is no /proc/acpi/button/lid/*/state, so setup inserts only the plain pam_fprintd line (today's behavior), no helper is installed, and the migration no-ops. A laptop with no ACPI lid button is treated like a desktop (fix simply doesn't engage).
  • pam_exec ships with the base pam package — no new dependency.
  • The helper lives in /usr/local/bin (not repo bin/, which is only on the user's $PATH) so PAM as root has a stable absolute path. Installed via sudo tee, mirroring the existing polkit-1 heredoc.

Changes

  • bin/omarchy-setup-security-fingerprint: has_lid(), install_lid_helper(); on laptops insert the lid guard above the sudo pam_fprintd line. polkit untouched.
  • bin/omarchy-remove-security-fingerprint: strip the guard from sudo and remove the helper.
  • migrations/1780152390.sh: upgrade existing laptop installs idempotently; no-op on desktops.

Testing

Verified locally on a ThinkPad X1 Carbon gen 14 (Omarchy 3.8.2):

  • bash -n clean on all three scripts.
  • Helper tested against real /proc (lid open → exit 0), simulated closed lid (exit 1), and no-lid/desktop (exit 0).
  • Applied the migration on a live /etc/pam.d/sudo (with backup) and exercised sudo -k; sudo true in both lid states: lid open prompts for fingerprint as before; lid closed (clamshell on external monitor) goes straight to the password prompt with no fingerprint wait. Toggled back and forth repeatedly with consistent results.

🤖 Generated with Claude Code

ocewers avatar May 30 '26 14:05 ocewers