Password dialog: Chandra is its own polkit agent, drawn in the shell layer
CI / test (push) Failing after 18s
CI / test (push) Failing after 18s
run0, pkexec and other polkit prompts used whatever third-party agent was
installed: a plain toolkit window saying "start transient unit
'run-p15802-i1990.service'". The compositor now registers as the session's
polkit authentication agent and asks in its own dialog:
- a centered card over a dimmed screen, above all windows and client menus,
themed (dark/light follow the Dark mode switch), keyboard-first: Enter,
Esc, Tab order, Alt+R show/hide, Alt+D details, Ctrl+U clear
- for run0 it shows the command it will run ("gparted /dev/sda", as root)
from run0's command line (pid from polkit's details or the unit name),
pkexec's command from its details, polkit's message otherwise; Details
lists the requester, target user, unit and action id
- account picker when several admins can answer (group members expanded)
- the PAM conversation through polkit-agent-helper-1: polkit 126's socket
first, else the setuid helper on a socket pair (new sys spawn-socket on the
native, Rust and MoonBit hosts); password, echo-on prompts, info (fingerprint)
and errors (faillock) shown as they come; wrong password shakes and retries;
spinner while PAM checks; Caps Lock warning
- typing through the clients' xkb keymap (groups, Shift, AltGr, Caps Lock),
US layout when there is none
- no client has keyboard focus or input while it is up; the password is
wiped after sending and never logged
Settings > Session > "Chandra password dialog" (state.edn :auth-agent
:system when off) switches back to the third-party agent, which
chandra-session now finds and the compositor starts (also when polkit
refuses our agent). Tests: polkit_test (keymaps, helper protocol, run0
parsing, dialog states, the socket-pair route) and auth_test (mock polkit
Authority on a private dbus-daemon, mock helper; CHANDRA_AUTH_SHOTS writes
a PNG per state). Docs: docs/auth-dialog.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgkRPrAzXECBUGmNEE
This commit is contained in:
32 files changed
+3930
-43
No files matched your search
@@ -145,6 +145,23 @@ pub(all) struct ChandraCompositor {
|
||||
mut rec_pointer : Bool
|
||||
mut rec_press : Bool
|
||||
mut last_recording : String
|
||||
/// 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
|
||||
mut auth : AuthUi?
|
||||
auth_swallow : Array[UInt]
|
||||
mut auth_routes : Array[@polkit.HelperRoute]
|
||||
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).
|
||||
mut fallback_agent_started : Bool
|
||||
/// The rest of the xkb modifier state (`mods` holds the depressed modifiers).
|
||||
mut mods_latched : UInt
|
||||
mut mods_locked : UInt
|
||||
mut mods_group : UInt
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -174,6 +191,17 @@ pub fn ChandraCompositor::new(
|
||||
theme,
|
||||
dark_theme: theme,
|
||||
sync_system_theme: false,
|
||||
polkit: None,
|
||||
polkit_bus: "",
|
||||
auth: None,
|
||||
auth_swallow: [],
|
||||
auth_routes: [],
|
||||
keymap: None,
|
||||
auth_describe: None,
|
||||
fallback_agent_started: false,
|
||||
mods_latched: 0U,
|
||||
mods_locked: 0U,
|
||||
mods_group: 0U,
|
||||
settings_portal: None,
|
||||
control: None,
|
||||
login_session: false,
|
||||
@@ -283,6 +311,11 @@ 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.shell.shutdown()
|
||||
match self.settings_portal {
|
||||
Some(p) => p.close()
|
||||
@@ -389,6 +422,7 @@ fn ChandraCompositor::flush_configures(self : ChandraCompositor) -> Unit {
|
||||
pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
|
||||
self.flush_configures()
|
||||
self.portal_tick()
|
||||
self.auth_tick()
|
||||
self.control_tick()
|
||||
let events = self.server.poll_events()
|
||||
for ev in events {
|
||||
@@ -598,6 +632,7 @@ pub fn ChandraCompositor::has_timed_work(self : ChandraCompositor) -> Bool {
|
||||
self.shot_request is Some(_) ||
|
||||
self.rec_request is Some(_) ||
|
||||
self.shot_toast is Some(_) ||
|
||||
self.auth_animating() ||
|
||||
self.thumbs_pending() ||
|
||||
self.shell.animating()
|
||||
}
|
||||
@@ -669,7 +704,8 @@ fn ChandraCompositor::build_scene(
|
||||
}
|
||||
}
|
||||
|
||||
for p in self.popups {
|
||||
// Client menus would draw above the auth dialog: none while it is up.
|
||||
for p in (if self.auth is Some(_) { [] } else { self.popups }) {
|
||||
match p.surface {
|
||||
Some(snap) => scene.popups.push((self.popup_rect(p), snap))
|
||||
None => ()
|
||||
@@ -729,6 +765,7 @@ fn ChandraCompositor::build_scene(
|
||||
panel_ops.append(self.switcher_ops())
|
||||
}
|
||||
panel_ops.append(self.screenshot_ops())
|
||||
panel_ops.append(self.auth_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.
|
||||
@@ -1201,6 +1238,7 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
@shell.ShellAction::FocusWindow(wid) => self.activate_task(wid)
|
||||
@shell.ShellAction::Logout => self.quit_requested = true
|
||||
@shell.ShellAction::ThemeChanged => self.apply_theme()
|
||||
@shell.ShellAction::AuthAgentChanged => self.auth_agent_setting_changed()
|
||||
@shell.ShellAction::Screenshot(code) => self.screenshot_request(code)
|
||||
@shell.ShellAction::SystemPower(a) => self.system_power(a)
|
||||
@shell.ShellAction::Window(wid, cmd) => self.window_command(wid, cmd)
|
||||
@@ -1292,6 +1330,21 @@ pub fn ChandraCompositor::handle_input(
|
||||
time_ms : UInt,
|
||||
) -> Unit {
|
||||
self.note_activity(@sys.monotonic_ms())
|
||||
match ev {
|
||||
Modifiers(dep, lat, lock, group) => {
|
||||
self.mods_latched = lat
|
||||
self.mods_locked = lock
|
||||
self.mods_group = group
|
||||
if self.auth is Some(_) {
|
||||
self.mods = dep
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
// The authentication dialog takes all input while it is up.
|
||||
if self.auth_input(ev) {
|
||||
return
|
||||
}
|
||||
match ev {
|
||||
Key(code, pressed) => {
|
||||
self.track_modifier_key(code, pressed)
|
||||
@@ -1584,6 +1637,10 @@ pub fn ChandraCompositor::handle_input(
|
||||
///| Cursor shape (wp_cursor_shape_v1 value) for the current pointer position: shell UI
|
||||
/// decides over the launcher; a client window decides inside its client area; otherwise default.
|
||||
pub fn ChandraCompositor::desired_cursor(self : ChandraCompositor) -> UInt {
|
||||
match self.auth {
|
||||
Some(ui) => return self.auth_cursor(ui)
|
||||
None => ()
|
||||
}
|
||||
match self.shot {
|
||||
Some(o) => return self.overlay_cursor(o)
|
||||
None => ()
|
||||
|
||||
Reference in new issue
Block a user