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
@@ -211,10 +211,46 @@ pub fn ChandraCompositor::control_command(self : ChandraCompositor, line : Strin
|
||||
"shortcut ID do what shortcut ID does (launcher, overview, show-desktop, ...)",
|
||||
"kiosk [lock|unlock|status] kiosk mode (--kiosk): lock it down or unlock it for admin work",
|
||||
"windows each window: frame, layout, box, shadow, size limits; and what is under the pointer",
|
||||
"auth-demo [MODE] show the password dialog with a pretend check (password \"demo\"); MODE: " +
|
||||
@polkit.demo_modes.join(", "),
|
||||
"auth-status the password dialog's agent: running, registered, or why not",
|
||||
"ok",
|
||||
],
|
||||
true,
|
||||
)
|
||||
"auth-demo" => {
|
||||
if words.length() > 2 {
|
||||
return (["error usage: auth-demo [" + @polkit.demo_modes.join("|") + "]"], false)
|
||||
}
|
||||
match self.start_auth_demo(if words.length() == 2 { words[1] } else { "" }) {
|
||||
Ok(_) => (["ok the demo dialog opens; the password is \"" + @polkit.demo_password + "\""], true)
|
||||
Err(why) => (["error " + why], false)
|
||||
}
|
||||
}
|
||||
"auth-status" => {
|
||||
let out : Array[String] = []
|
||||
match self.auth_agent {
|
||||
Some(l) => out.push(if l.ready { "agent: registered with polkit" } else { "agent: started, waiting for polkit" })
|
||||
None =>
|
||||
out.push(
|
||||
if self.fallback_agent_started {
|
||||
"agent: off in Settings; another polkit agent was started"
|
||||
} else {
|
||||
"agent: not running"
|
||||
},
|
||||
)
|
||||
}
|
||||
match self.auth_notice {
|
||||
Some(n) => out.push("notice: " + n.text)
|
||||
None => ()
|
||||
}
|
||||
match self.auth {
|
||||
Some(ui) => out.push("dialog: up (" + @polkit.phase_name(ui.view.phase) + ")")
|
||||
None => out.push("dialog: not shown")
|
||||
}
|
||||
out.push("ok")
|
||||
(out, true)
|
||||
}
|
||||
"list" => {
|
||||
let mods = self.shell.loaded_modules()
|
||||
let out = mods.map(m => m.0 + " " + m.1 + " " + m.2)
|
||||
|
||||
Reference in new issue
Block a user