Face unlock: a Howdy-style PAM module, shown in the password dialog and set up in Settings
CI / test (push) Successful in 2m6s
CI / test (push) Successful in 2m6s
- face/pam_chandra_face.so (`-auth sufficient`): runs `chandra-face compare` as root with a clean
environment, forwards what it says as PAM_TEXT_INFO / PAM_ERROR_MSG, and maps its exit status
to success / auth error / unavailable, so the password always still works. Skips remote
sessions (PAM_RHOST, SSH_CONNECTION), a closed lid and users without faces; refuses a helper
that isn't root's; kills one that hangs (timeout + 6 s).
- face/chandra-face (Python + OpenCV): YuNet finds the face, SFace embeds it, cosine similarity
against the enrolled embeddings (threshold 0.42, two matching frames, dark IR warm-up frames
skipped, optional require_ir). enroll / list / remove / clear / test / status / pam
enable|disable / fetch-models (sha256-pinned opencv_zoo models). Embeddings only, in
/var/lib/chandra-face/USER/faces.json (root, 0600); labels in faces.list (0644). Store, config
and models must be root's and not writable by others. Root commands re-run through run0 (or
pkexec), so polkit asks first. Settings in /etc/chandra/face.conf.
- `just install-face [--pam]`, `just uninstall-face [--purge]` (face/install.py; uninstall takes
the module out of every PAM service first). `pam enable` inserts before the first auth or
@include line (Debian's sudo has only @include common-auth), keeping a .bak.
- Password dialog: a face row ("Looking for your face…" with a sweeping ring, "Face
recognized", or why not, "Type your password instead"); typing and Enter during the scan go in
when PAM asks for the password. Howdy's pam_howdy.so messages are understood too.
- Settings > Session > Face unlock: "Use my face for passwords" (polkit-1 + sudo), the enrolled
faces (Remove takes a second click), "Add a face…", and the tool's progress. New `face-unlock`
capability: tables 24 (status) and 25 (faces), request 44, in the wasmer/wasmtime stub, the Rust
host, the MoonBit wasmhost and chandra:host/plasmoids. compositor/shell/face.mbt runs the tool
on a socket so the compositor never waits.
- Tests: face/test_face.py (fake camera of PGM frames + fake recognizer; --pam builds the module
and runs it through pamtester), dialog states and message parsing (polkit_test), the dialog via
a mock helper (auth_test, shots 14/15), Settings against a fake chandra-face (face_test).
scripts/test.sh runs them (compositor/polkit was missing from its native list), CI installs
libpam0g-dev + pamtester. Also regenerated two stale desktop-module bindings (doc comments).
- docs/face-unlock.md, including the limits of 2D face recognition.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
This commit is contained in:
47 files changed
+2781
-29
No files matched your search
@@ -334,3 +334,41 @@ interface network {
|
||||
set-wifi-enabled: func(on: bool);
|
||||
set-airplane-mode: func(on: bool);
|
||||
}
|
||||
|
||||
/// Face unlock (docs/face-unlock.md): the session user's enrolled faces and whether the password
|
||||
/// dialog and sudo try the face first. Every change runs chandra-face through run0 or pkexec, so
|
||||
/// polkit asks for an administrator's password before anything happens; the module never sees a
|
||||
/// camera picture or any face data, only labels.
|
||||
interface face-unlock {
|
||||
record face-status {
|
||||
/// Why face unlock can't work yet ("python3-opencv is not installed"), or empty.
|
||||
problem: string,
|
||||
/// PAM services that use Howdy's pam_howdy.so, comma-separated, or empty.
|
||||
howdy: string,
|
||||
/// What the running change said last ("Look at the camera… 3/5"), or how the last one
|
||||
/// ended; empty when none ran.
|
||||
message: string,
|
||||
/// chandra-face is installed (`just install-face`).
|
||||
installed: bool,
|
||||
/// The password dialog (PAM service polkit-1) and sudo try the face first.
|
||||
in-use: bool,
|
||||
/// A change (enroll, remove, set-in-use) is running.
|
||||
busy: bool,
|
||||
}
|
||||
record face {
|
||||
label: string,
|
||||
/// When it was enrolled (YYYY-MM-DD).
|
||||
added: string,
|
||||
}
|
||||
status: func() -> face-status;
|
||||
/// The enrolled faces, oldest first.
|
||||
faces: func() -> list<face>;
|
||||
/// Add a face: after the password, the camera looks for about ten seconds.
|
||||
enroll: func();
|
||||
/// Forget face `index` of `faces`.
|
||||
remove: func(index: u32);
|
||||
/// Try the face first in the password dialog and sudo, or stop.
|
||||
set-in-use: func(on: bool);
|
||||
/// Read the status and the faces again.
|
||||
refresh: func();
|
||||
}
|
||||
@@ -69,7 +69,8 @@ interface plasmoids {
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
|
||||
/// shortcuts (ssssi: name binding default-binding conflict capturing), 11 default-app
|
||||
/// categories (sss: name current missing), 12 default-app choices (issii: category id name icon current),
|
||||
/// 20 desktops (s: name) served by `wallpaper.desktops`.
|
||||
/// 20 desktops (s: name) served by `wallpaper.desktops`, 24 face unlock status (sssiii: problem howdy
|
||||
/// message installed in-use busy; one row), 25 enrolled faces (ss: label added).
|
||||
publish-table: func(which: u32, rows: list<u8>);
|
||||
/// Layout mode (0 tiling, 1 monocle, 2 floating) and whether the Interface Explorer is on.
|
||||
publish-state: func(layout-mode: s32, inspector-on: bool);
|
||||
@@ -161,6 +162,9 @@ interface plasmoids {
|
||||
default-app(s32),
|
||||
/// The wallpaper capability's `set-desktop`: an index into the desktops table.
|
||||
set-desktop(s32),
|
||||
/// The face-unlock capability: an index removes that face; -1 reads the status again, -2
|
||||
/// enrolls a face, -3 / -4 stop / start using it for the password dialog and sudo.
|
||||
face-unlock(s32),
|
||||
}
|
||||
/// The next pending request, oldest first.
|
||||
next-request: func() -> option<request>;
|
||||
|
||||
+4
-2
@@ -101,13 +101,14 @@ world plasmoid-host {
|
||||
import network;
|
||||
import shortcuts;
|
||||
import default-apps;
|
||||
import face-unlock;
|
||||
export plasmoid;
|
||||
}
|
||||
|
||||
/// The settings module: session switches (restore, window places, dark mode), the wallpaper, the
|
||||
/// panel's modules (load, unload, browse; the panel menu's "Modules..." opens that tab), and power
|
||||
/// (idle timeouts, battery, suspend / restart / power off), keyboard shortcuts (rebind, reset) and
|
||||
/// default apps (browser, email, files, terminal, editor, viewers and players).
|
||||
/// (idle timeouts, battery, suspend / restart / power off), keyboard shortcuts (rebind, reset),
|
||||
/// default apps (browser, email, files, terminal, editor, viewers and players) and face unlock.
|
||||
world session-settings-widget {
|
||||
include widget;
|
||||
import session-settings;
|
||||
@@ -117,6 +118,7 @@ world session-settings-widget {
|
||||
import system;
|
||||
import shortcuts;
|
||||
import default-apps;
|
||||
import face-unlock;
|
||||
}
|
||||
|
||||
/// Screenshot and screen recording launcher.
|
||||
|
||||
Reference in new issue
Block a user