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

+43
View File
@@ -993,6 +993,49 @@ impl Host for State {
}
c.spawn().is_ok()
}
fn spawn_socket(&mut self, argv: String) -> i32 {
use std::os::fd::{FromRawFd, IntoRawFd, OwnedFd};
let args: Vec<&str> = argv.split('\n').filter(|a| !a.is_empty()).collect();
if args.is_empty() || !args[0].starts_with('/') {
return -1;
}
let mut sv = [-1i32; 2];
if unsafe { libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM | libc::SOCK_CLOEXEC, 0, sv.as_mut_ptr()) } != 0 {
return -1;
}
let child_end = unsafe { OwnedFd::from_raw_fd(sv[1]) };
let out = match child_end.try_clone() {
Ok(f) => f,
Err(_) => {
unsafe { libc::close(sv[0]) };
return -1;
}
};
let mut c = Command::new(args[0]);
c.args(&args[1..]).stdin(Stdio::from(child_end)).stdout(Stdio::from(out));
unsafe {
c.pre_exec(|| {
libc::signal(libc::SIGCHLD, libc::SIG_DFL);
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
Ok(())
});
}
match c.spawn() {
Ok(mut child) => {
// Reap it when it exits, so it never lingers as a zombie.
std::thread::spawn(move || {
let _ = child.wait();
});
let fd = unsafe { OwnedFd::from_raw_fd(sv[0]) };
fd.into_raw_fd()
}
Err(_) => {
unsafe { libc::close(sv[0]) };
-1
}
}
}
}
fn main() -> Result<()> {