Password dialog rebuilt: a separate polkit agent, one state machine, explicit errors
CI / test (push) Canceled after 21m14s

The first version ran polkit registration, polkit-agent-helper-1, the PAM
conversation and the drawing inside the compositor's frame loop, with
overlapping state in two layers. A helper that quit before asking was taken
for a wrong password and restarted in a loop that wiped the field (typing
seemed dead), a refused registration quietly started a third-party agent,
and the dialog and the Face unlock window each grabbed the keyboard.

Now:
- chandra-polkit-agent (compositor/authagent, /usr/local/lib/chandra) does
  polkit and PAM. Each request runs one state machine (polkit/machine.mbt:
  starting, asking, checking, failed, done). A check that quits or can't
  start is Failed with the reason and waits for Try again; only a wrong
  password starts the next check by itself. It logs each step to stderr
  (the session log), never the typed text.
- The compositor starts it on a socket pair and only draws what it says
  (host/auth.mbt, auth_draw.mbt; line protocol in polkit/wire.mbt). One
  input owner (grab_input): the dialog, else the Face unlock window.
- No silent fallback: if the agent can't run, polkit refuses it, polkit
  doesn't answer in 10 s, or it dies, a notice on screen says why (a crash
  after it ran restarts it, up to 3 times, and says so). The third-party
  agent runs only when the Settings switch is off.
- chandra-ctl auth-demo [password|face|face-ok|die|slow|users] shows the
  real dialog with a pretend check (password "demo"), no root needed;
  chandra-ctl auth-status says whether the agent is registered.
- just install builds and installs the agent (just auth-agent).

Tests: polkit_test (link, machine, view, helper Gone) and auth_test end to
end through handle_input: the agent loop in-process against a mock polkit
on a private dbus-daemon plus a mock helper, and the real agent program
spawned by the compositor (demo, and registered with the mock polkit).
Typing on a real xkb keymap, wrong password, cancel, withdrawal, helper
quitting early or missing, polkit refusing, agent not starting or crashing,
demo modes, Face unlock Apply. 170/170 host and 20/20 polkit tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgkRPrAzXECBUGmNEE
This commit is contained in:
Claude committed 2026-11-26 05:09:49 +00:00
1 parent 2c33c4a847
commit 80af76fb15
22 files changed
+3462 -1806

No files matched your search

+4 -1
View File
@@ -8,6 +8,9 @@
chandra-ctl shortcut ID do what a keyboard shortcut does (overview, launcher, show-desktop...)
chandra-ctl kiosk [lock|unlock|status] kiosk mode (--kiosk, docs/kiosk.md)
chandra-ctl windows how Chandra sees each window, and what is under the pointer
chandra-ctl auth-demo [MODE] show the password dialog with a pretend check (password "demo");
MODE: password, face, face-ok, die, slow, users (docs/auth-dialog.md)
chandra-ctl auth-status the password dialog's agent: registered with polkit, or why not
The socket is $XDG_RUNTIME_DIR/chandra/<wayland socket name>.sock (the session's is
wayland-moon-0.sock). It is found in this order: --socket PATH, $CHANDRA_CONTROL, the one for
@@ -20,7 +23,7 @@ import os
import socket
import sys
USAGE = "usage: chandra-ctl [--socket PATH] [--quiet] {reload [NAME] | list | ping | shortcut ID | kiosk [lock|unlock|status] | windows | help}"
USAGE = "usage: chandra-ctl [--socket PATH] [--quiet] {reload [NAME] | list | ping | shortcut ID | kiosk [lock|unlock|status] | windows | auth-demo [MODE] | auth-status | help}"
def runtime_dir():
+5 -4
View File
@@ -170,10 +170,11 @@ if [ "$backend" = --drm ] && [ -n "$XDG_SESSION_ID" ] && command -v loginctl >/d
fi
# Password prompts for `chandra-root APP`, run0 and pkexec started from the launcher or a shortcut
# (no terminal to ask in): the compositor is its own polkit authentication agent and asks in a
# dialog it draws itself (compositor/host/auth.mbt; Settings > Session > "Chandra password
# dialog"). When that switch is off, or polkit won't take Chandra's agent, the compositor starts
# the first third-party agent installed, found here and passed as CHANDRA_POLKIT_FALLBACK.
# (no terminal to ask in): the compositor starts Chandra's polkit agent
# (/usr/local/lib/chandra/chandra-polkit-agent) and draws its dialog itself (docs/auth-dialog.md).
# If that can't start, a notice on screen says why; nothing else takes over. Only when the user
# turns Settings > Session > "Chandra password dialog" off does the compositor start the first
# third-party agent installed, found here and passed as CHANDRA_POLKIT_FALLBACK.
# CHANDRA_POLKIT_AGENT=none starts no agent at all (say, when a systemd user unit already starts
# one); a path starts that agent instead of Chandra's.
fallback=
+13
View File
@@ -24,6 +24,8 @@ Installs:
/usr/local/bin/chandra (--native) release native compositor binary
/usr/local/bin/chandra-session session launcher (starts the host if installed)
/usr/local/bin/chandra-root run one graphical app as root in the session (run0)
/usr/local/lib/chandra/chandra-polkit-agent the password dialog's polkit agent; the compositor
starts it (docs/auth-dialog.md)
/usr/local/bin/chandra-ctl talk to the running session: `chandra-ctl reload` loads
the panel modules again (docs/reloading.md)
/usr/local/bin/chandra-kde-colors Dark mode for KDE/Qt apps: copies a color scheme into
@@ -44,6 +46,9 @@ root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
native = "--native" in sys.argv
linked = "--link" in sys.argv
exe = os.path.join(root, "_build/native/release/build/compositor/bin/bin.exe")
# Chandra's polkit agent (just auth-agent): the compositor starts it for the password dialog.
auth_agent = os.path.join(root, "_build/native/release/build/compositor/authagent/authagent.exe")
auth_agent_dst = "/usr/local/lib/chandra/chandra-polkit-agent"
if "--rust" in sys.argv or "--rust-host" in sys.argv:
sys.exit("install.py: --rust is gone: the Rust host (host-wasm) was removed on 2026-11-26; "
"the MoonBit host (build/wasmhost) is the only one, so drop the flag")
@@ -57,6 +62,7 @@ targets = [
"/usr/local/bin/chandra-host",
"/usr/local/bin/chandra-session",
"/usr/local/bin/chandra-root",
"/usr/local/lib/chandra/chandra-polkit-agent",
"/usr/local/bin/chandra-ctl",
"/usr/local/bin/chandra-kde-colors",
"/usr/local/share/color-schemes/ChandraDark.colors",
@@ -97,6 +103,8 @@ if "--remove" in sys.argv:
print("removed", share)
sys.exit(1 if face_rc else 0)
if not os.path.exists(auth_agent):
sys.exit("missing %s - run `just auth-agent` first (the password dialog needs it)" % auth_agent)
if native:
if not os.path.exists(exe):
sys.exit("missing %s - run `just build-release` first" % exe)
@@ -159,6 +167,11 @@ if not native:
install(component, os.path.join(share, "compositor.wasm"))
install(os.path.join(root, "session/chandra-session"), "/usr/local/bin/chandra-session")
install(os.path.join(root, "session/chandra-root"), "/usr/local/bin/chandra-root")
# Executable wherever it lives (install() only marks /bin/ paths executable).
if linked:
link(auth_agent, auth_agent_dst)
else:
put(auth_agent, auth_agent_dst, 0o755)
install(os.path.join(root, "session/chandra-ctl"), "/usr/local/bin/chandra-ctl")
install(os.path.join(root, "session/chandra-kde-colors"), "/usr/local/bin/chandra-kde-colors")
for f in ("ChandraDark.colors", "ChandraLight.colors"):