Password dialog rebuilt: a separate polkit agent, one state machine, explicit errors
CI / test (push) Canceled after 21m14s
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:
22 files changed
+3462
-1806
No files matched your search
@@ -256,22 +256,26 @@ pub(all) struct ChandraCompositor {
|
||||
mut last_recording : String
|
||||
/// `--kiosk`: one fullscreen app, locked down (kiosk.mbt). None: a normal desktop.
|
||||
mut kiosk : Kiosk?
|
||||
/// Chandra's polkit agent (auth.mbt), while it is registered; the system bus socket it uses
|
||||
/// ("" finds it); the dialog while it is up; key releases it swallows; how to reach polkit's
|
||||
/// helper (empty: the usual routes; tests set their own); the keymap typing goes through.
|
||||
mut polkit : @polkit.PolkitAgent?
|
||||
mut polkit_bus : String
|
||||
/// The password dialog (auth.mbt): the session's chandra-polkit-agent and demo agents
|
||||
/// (`chandra-ctl auth-demo`), the dialog while it is up, key releases the dialog or the Face
|
||||
/// unlock window swallow, a notice about the dialog itself, how agents are started (tests run
|
||||
/// them in-process), restarts after crashes, and whether "still waiting for polkit" was said.
|
||||
mut auth_agent : AuthLink?
|
||||
auth_demos : Array[AuthLink]
|
||||
mut auth : AuthUi?
|
||||
auth_swallow : Array[UInt]
|
||||
mut auth_notice : AuthNotice?
|
||||
mut auth_notice_press : Bool
|
||||
mut auth_spawner : ((Array[String]) -> Int)?
|
||||
mut auth_restarts : Int
|
||||
mut auth_slow_said : Bool
|
||||
/// The Face unlock window (face_window.mbt): where its controls were drawn, and the change of
|
||||
/// it last drawn.
|
||||
face_hits : Array[(@scene.Rect, FaceHit)]
|
||||
mut face_rev : Int
|
||||
mut auth_routes : Array[@polkit.HelperRoute]
|
||||
/// The keymap the dialog types through (parsed from the one clients get).
|
||||
mut keymap : (Bytes, @polkit.Keymap)?
|
||||
/// How requests are put into words (tests pass their own process lookups); None: the usual.
|
||||
mut auth_describe : ((@polkit.AuthRequest) -> @polkit.Description)?
|
||||
/// A third-party polkit agent was started (when ours is off or couldn't register).
|
||||
/// Another polkit agent was started (the Settings switch for Chandra's dialog is off).
|
||||
mut fallback_agent_started : Bool
|
||||
/// The rest of the xkb modifier state (`mods` holds the depressed modifiers).
|
||||
mut mods_latched : UInt
|
||||
@@ -313,15 +317,18 @@ pub fn ChandraCompositor::new(
|
||||
theme,
|
||||
dark_theme: theme,
|
||||
sync_system_theme: false,
|
||||
polkit: None,
|
||||
polkit_bus: "",
|
||||
auth_agent: None,
|
||||
auth_demos: [],
|
||||
auth: None,
|
||||
auth_swallow: [],
|
||||
auth_notice: None,
|
||||
auth_notice_press: false,
|
||||
auth_spawner: None,
|
||||
auth_restarts: 0,
|
||||
auth_slow_said: false,
|
||||
face_hits: [],
|
||||
face_rev: -1,
|
||||
auth_routes: [],
|
||||
keymap: None,
|
||||
auth_describe: None,
|
||||
fallback_agent_started: false,
|
||||
mods_latched: 0U,
|
||||
mods_locked: 0U,
|
||||
@@ -447,11 +454,7 @@ pub fn ChandraCompositor::close(self : ChandraCompositor) -> Unit {
|
||||
release_snapshot(win.surface)
|
||||
}
|
||||
self.stop_control()
|
||||
self.close_auth(Some(Err("The session is ending")))
|
||||
match self.polkit {
|
||||
Some(a) => a.stop()
|
||||
None => ()
|
||||
}
|
||||
self.auth_shutdown()
|
||||
self.shell.shutdown()
|
||||
match self.settings_portal {
|
||||
Some(p) => p.close()
|
||||
@@ -1108,6 +1111,7 @@ fn ChandraCompositor::build_scene(
|
||||
panel_ops.append(self.screenshot_ops())
|
||||
panel_ops.append(self.face_window_ops())
|
||||
panel_ops.append(self.auth_ops())
|
||||
panel_ops.append(self.auth_notice_ops())
|
||||
self.frames_built = self.frames_built + 1
|
||||
self.run_shell_actions()
|
||||
// The wallpaper (the first ops) is cached by the renderer; the desktop card after it changes.
|
||||
@@ -1869,12 +1873,8 @@ pub fn ChandraCompositor::handle_input(
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
// The authentication dialog takes all input while it is up.
|
||||
if self.auth_input(ev) {
|
||||
return
|
||||
}
|
||||
// So does the Face unlock window (below the password dialog it opens on Apply).
|
||||
if self.face_window_input(ev) {
|
||||
// The password dialog takes all input while it is up; else the Face unlock window does.
|
||||
if self.grab_input(ev) {
|
||||
return
|
||||
}
|
||||
match ev {
|
||||
|
||||
Reference in new issue
Block a user