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

+26 -32
View File
@@ -130,38 +130,32 @@ if [ -n "$XDG_SESSION_ID" ] && command -v loginctl >/dev/null 2>&1; then
fi
fi
# A polkit authentication agent, so `chandra-root APP`, run0 and pkexec started from the launcher
# or a shortcut (no terminal to ask in) can show a password prompt. Uses the first one installed,
# once the compositor's socket is up (the agents are GTK/Qt apps that need it at startup).
# CHANDRA_POLKIT_AGENT names one explicitly, or "none" to start none (say, when a systemd user
# unit already starts one).
agent=${CHANDRA_POLKIT_AGENT:-}
if [ -z "$agent" ]; then
for a in \
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 \
/usr/libexec/polkit-gnome-authentication-agent-1 \
/usr/lib/mate-polkit/polkit-mate-authentication-agent-1 \
/usr/libexec/polkit-mate-authentication-agent-1 \
/usr/lib/x86_64-linux-gnu/polkit-mate/polkit-mate-authentication-agent-1 \
/usr/lib/polkit-kde-authentication-agent-1 \
/usr/libexec/polkit-kde-authentication-agent-1 \
/usr/libexec/kf6/polkit-kde-authentication-agent-1 \
/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1 \
/usr/lib/hyprpolkitagent/hyprpolkitagent \
/usr/libexec/hyprpolkitagent \
/usr/libexec/xfce-polkit \
/usr/lib/xfce-polkit/xfce-polkit \
"$(command -v lxpolkit 2>/dev/null)"; do
if [ -n "$a" ] && [ -x "$a" ]; then agent=$a; break; fi
done
fi
if [ -n "$agent" ] && [ "$agent" != none ]; then
(
i=0
while [ ! -S "$sock" ] && [ $i -lt 200 ]; do sleep 0.1; i=$((i + 1)); done
WAYLAND_DISPLAY="$sock" GDK_BACKEND=wayland exec "$agent"
) >>"$log" 2>&1 &
fi
# Password prompts for `chandra-root APP`, run0 and pkexec started from the launcher or a shortcut
# (no terminal to ask in): the compositor is its own polkit authentication agent and asks in a
# dialog it draws itself (compositor/host/auth.mbt; Settings > Session > "Chandra password
# dialog"). When that switch is off, or polkit won't take Chandra's agent, the compositor starts
# the first third-party agent installed, found here and passed as CHANDRA_POLKIT_FALLBACK.
# CHANDRA_POLKIT_AGENT=none starts no agent at all (say, when a systemd user unit already starts
# one); a path starts that agent instead of Chandra's.
fallback=
for a in \
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 \
/usr/libexec/polkit-gnome-authentication-agent-1 \
/usr/lib/mate-polkit/polkit-mate-authentication-agent-1 \
/usr/libexec/polkit-mate-authentication-agent-1 \
/usr/lib/x86_64-linux-gnu/polkit-mate/polkit-mate-authentication-agent-1 \
/usr/lib/polkit-kde-authentication-agent-1 \
/usr/libexec/polkit-kde-authentication-agent-1 \
/usr/libexec/kf6/polkit-kde-authentication-agent-1 \
/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1 \
/usr/lib/hyprpolkitagent/hyprpolkitagent \
/usr/libexec/hyprpolkitagent \
/usr/libexec/xfce-polkit \
/usr/lib/xfce-polkit/xfce-polkit \
"$(command -v lxpolkit 2>/dev/null)"; do
if [ -n "$a" ] && [ -x "$a" ]; then fallback=$a; break; fi
done
export CHANDRA_POLKIT_FALLBACK="$fallback"
exec "$@" --drm --socket "$sock" \
--theme "$share/config/themes/moon-night.json" >>"$log" 2>&1