Password dialog: Chandra is its own polkit agent, drawn in the shell layer
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:
Claude committed 2026-11-26 00:17:04 +00:00
1 parent 2a67bc83d4
commit 0feea23a06
32 files changed
+3930 -43

No files matched your search

+18
View File
@@ -523,3 +523,21 @@ fn DesktopShell::publish_icons(self : DesktopShell) -> Unit {
@wasm.publish(Icons, t)
}
///| The image handle of theme icon `name` (say "drive-harddisk"; 0: none), cached.
pub fn DesktopShell::theme_icon(self : DesktopShell, name : String) -> UInt {
if name == "" {
return 0U
}
let key = "icon:" + name
match self.icon_handles.get(key) {
Some(h) => return h
None => ()
}
let h = match self.icon_search().find(name, @sys.host_raster()) {
Some(path) => @raster.load_image(path)
None => 0U
}
self.icon_handles.set(key, h)
h
}
+6
View File
@@ -155,6 +155,8 @@ pub(all) enum ShellAction {
Logout
/// The Dark mode setting changed: the compositor swaps the theme (see `dark_mode`).
ThemeChanged
/// The password dialog setting changed: the compositor registers its polkit agent or leaves.
AuthAgentChanged
/// The screenshot module asked for a screenshot or recording (code: see the compositor's
/// screenshot_request).
Screenshot(Int)
@@ -272,6 +274,9 @@ pub(all) struct DesktopShell {
/// The network service (network.mbt), while a module imports `network`.
mut net : @network.NetService?
mut remember_windows : Bool
/// Chandra's own password dialog answers polkit (run0, pkexec, ...); off: the system's polkit
/// agent does. Saved as state.edn `:auth-agent :system` when off.
mut native_auth_agent : Bool
/// Dark mode (the configured theme) or light (Moon Day); saved as `:theme :light` when off.
mut dark_mode : Bool
/// Power: minutes without input before the login session turns the screen off / suspends
@@ -406,6 +411,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
screenshot_state: 2,
net: None,
remember_windows: true,
native_auth_agent: true,
dark_mode: true,
screen_off_min: default_screen_off_min,
suspend_min: default_suspend_min,
+19 -2
View File
@@ -19,7 +19,9 @@
/// ; the next start (see session.mbt in compositor/host)
/// :restore-session false ; don't reopen them (absent: reopen); the session settings module
/// ; or a hand edit sets it
/// :remember-windows false} ; don't place windows where they were left (absent: do)
/// :remember-windows false ; don't place windows where they were left (absent: do)
/// :auth-agent :system} ; passwords for run0/pkexec/polkit go to the system's polkit
/// ; agent instead of Chandra's own dialog (absent: :chandra)
///
/// Saving merges into what is already in the file, so keys this build doesn't know (a future
/// widget's state, hand-written notes) survive. Everything is a no-op unless `persist` is on
@@ -47,6 +49,8 @@ pub(all) struct SavedState {
shortcuts : Array[(String, String)]
/// From `:terminal`: the chosen terminal's desktop id.
terminal : String?
/// From `:auth-agent`: true for :chandra, false for :system.
native_auth_agent : Bool?
}
///|
@@ -60,7 +64,7 @@ let layout_names : Array[String] = ["tiling", "monocle", "floating"]
///| The keys this build owns; everything else in the file is kept as it is.
let owned_keys : Array[String] = [
"layout", "recent", "desktop-card", "windows", "wallpaper", "restore-session", "remember-windows",
"theme", "power", "shortcuts", "terminal",
"theme", "power", "shortcuts", "terminal", "auth-agent",
]
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
@@ -108,6 +112,7 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
power: (None, None),
shortcuts: [],
terminal: None,
native_auth_agent: None,
}
}
let entries = read_state_file()
@@ -223,6 +228,11 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
Some(Text(t)) if t.length() > 0 => Some(t)
_ => None
},
native_auth_agent: match lookup_key(entries, "auth-agent") {
Some(Keyword("system")) => Some(false)
Some(Keyword("chandra")) => Some(true)
_ => None
},
shortcuts: match lookup_key(entries, "shortcuts") {
Some(Mapping(m)) => {
let out : Array[(String, String)] = []
@@ -274,6 +284,10 @@ pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
_ => ()
}
self.shortcuts.apply_saved(st.shortcuts)
match st.native_auth_agent {
Some(b) => self.native_auth_agent = b
None => ()
}
match st.terminal {
Some(t) => {
self.terminal = t
@@ -371,6 +385,9 @@ pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
changed.map(c => (@edn.Value::Keyword(c.0), @edn.Value::Text(c.1))),
)))
}
if !self.native_auth_agent {
entries.insert(2, (@edn.Value::Keyword("auth-agent"), @edn.Value::Keyword("system")))
}
if !self.dark_mode {
entries.insert(2, (@edn.Value::Keyword("theme"), @edn.Value::Keyword("light")))
}
+8 -2
View File
@@ -733,14 +733,15 @@ pub fn DesktopShell::set_wallpaper(self : DesktopShell, i : Int) -> Unit {
///| The session settings the session settings module lists, in index order.
let session_setting_names : Array[String] = [
"Reopen windows at login", "Remember window positions", "Dark mode",
"Reopen windows at login", "Remember window positions", "Dark mode", "Chandra password dialog",
]
///| Which session settings are on: bit i for `session_setting_names[i]`.
fn DesktopShell::session_settings_bits(self : DesktopShell) -> Int {
(if self.restore_session { 1 } else { 0 }) |
(if self.remember_windows { 2 } else { 0 }) |
(if self.dark_mode { 4 } else { 0 })
(if self.dark_mode { 4 } else { 0 }) |
(if self.native_auth_agent { 8 } else { 0 })
}
///| Turn session setting `i` on or off (ignored when out of range) and remember it in state.edn.
@@ -753,6 +754,11 @@ pub fn DesktopShell::set_session_setting(self : DesktopShell, i : Int, on : Bool
self.dark_mode = on
self.actions.push(ThemeChanged)
}
3 =>
if self.native_auth_agent != on {
self.native_auth_agent = on
self.actions.push(AuthAgentChanged)
}
_ => return
}
@wasm.publish_session_settings(self.session_settings_bits())