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
108 lines
5.1 KiB
Plaintext
108 lines
5.1 KiB
Plaintext
package chandra:host@0.1.0;
|
|
|
|
/// The operating-system surface the compositor component needs, nothing more. The native host
|
|
/// implements it with real syscalls; the component holds only integer handles (fds) and bytes.
|
|
/// Mirrors compositor/sys.
|
|
interface sys {
|
|
/// Listen on a unix socket at `path`; -1 on failure.
|
|
unix-listen: func(path: string) -> s32;
|
|
/// Accept a pending client (non-blocking); -1 when none.
|
|
unix-accept: func(listen-fd: s32) -> s32;
|
|
unix-connect: func(path: string) -> s32;
|
|
close-fd: func(fd: s32);
|
|
unlink: func(path: string);
|
|
/// 1 when `fd` is readable within `timeout-ms`, 0 on timeout, <0 on error.
|
|
poll-read: func(fd: s32, timeout-ms: s32) -> s32;
|
|
/// Block until one of `fds` is readable or `timeout-ms` passes: how an idle compositor sleeps.
|
|
/// While the login-session display is open (display.open) its own seat, DRM and input fds are
|
|
/// waited on too. The number of ready fds, 0 on timeout, <0 on error.
|
|
wait-readable: func(fds: list<s32>, timeout-ms: s32) -> s32;
|
|
|
|
/// Result of `recvmsg`: byte count (-1 would-block, -2 error, 0 EOF), an fd received over
|
|
/// SCM_RIGHTS (-1 when none), and the bytes read.
|
|
record received {
|
|
count: s32,
|
|
fd: s32,
|
|
data: list<u8>,
|
|
}
|
|
recvmsg: func(fd: s32, max-len: u32) -> received;
|
|
/// The next further fd that arrived with the last `recvmsg` on `sock` (a client can send
|
|
/// several in one message), -1 when none is left.
|
|
take-fd: func(sock: s32) -> s32;
|
|
/// Send `data`, with `send-fd` (or -1) as SCM_RIGHTS; bytes sent or <0.
|
|
sendmsg: func(fd: s32, data: list<u8>, send-fd: s32) -> s32;
|
|
|
|
memfd-create: func(name: string, size: s32) -> s32;
|
|
/// Write at `offset` (shm pools). A negative offset writes at the current position without
|
|
/// blocking (a clipboard pipe): the byte count, 0 when the pipe is full, -1 on error.
|
|
pwrite: func(fd: s32, data: list<u8>, offset: s32) -> s32;
|
|
/// Copy `size` bytes of the file behind `fd` (mapped read-only by the host).
|
|
mmap-read: func(fd: s32, size: s32) -> list<u8>;
|
|
/// Copy `len` bytes starting at `offset` of the file behind `fd` (a client's buffer inside its
|
|
/// shared pool; a pool can be far larger than any one buffer, so never read from byte 0).
|
|
mmap-read-at: func(fd: s32, offset: s32, len: s32) -> list<u8>;
|
|
|
|
read-file: func(path: string) -> list<u8>;
|
|
write-file: func(path: string, data: list<u8>) -> s32;
|
|
/// Append `data` to the file at `path` (created if missing): 0, or -1 on error. Large files go
|
|
/// out as write-file plus appends of at most 1 MiB, because a host built on wasmtime's C API
|
|
/// moves list<u8> as one dynamic value per byte and wasmtime caps what one call may copy.
|
|
append-file: func(path: string, data: list<u8>) -> s32;
|
|
/// Contents of a small /proc or /sys file ("" when unreadable).
|
|
read-proc: func(path: string) -> list<u8>;
|
|
mkdir-p: func(path: string) -> bool;
|
|
/// Names of the *.desktop files directly in `dir`.
|
|
list-desktop-files: func(dir: string) -> list<string>;
|
|
|
|
sleep-ms: func(ms: s32);
|
|
/// Milliseconds on a monotonic clock (event timestamps).
|
|
monotonic-ms: func() -> u64;
|
|
/// Print a line to the host's stderr.
|
|
log: func(message: string);
|
|
getpid: func() -> s32;
|
|
/// 0 year, 1 month (1-12), 2 day, 3 hour, 4 minute, 5 second, 6 weekday (0 = Sunday).
|
|
wall-time-field: func(which: s32) -> s32;
|
|
getenv: func(name: string) -> string;
|
|
has-exe: func(name: string) -> bool;
|
|
/// Launch `cmd` detached with WAYLAND_DISPLAY set to `display`.
|
|
spawn: func(cmd: string, display: string) -> bool;
|
|
/// Run a program with its stdin and stdout on one end of a socket pair; our end, or -1.
|
|
/// `argv` is the absolute program path then its arguments, separated by newlines. Its stderr
|
|
/// is the host's. Not waited for. Used for polkit's setuid authentication helper.
|
|
spawn-socket: func(argv: string) -> s32;
|
|
/// True once after the host process got SIGUSR1 (a request to reload the panel modules from
|
|
/// disk; see docs/reloading.md). The first call installs the handler; until then SIGUSR1 keeps
|
|
/// its default action. A signal interrupts `wait-readable`, so an idle loop wakes for it.
|
|
take-sigusr1: func() -> bool;
|
|
}
|
|
|
|
/// Glyph rasterisation. The component has no C rasteriser, so the host draws glyphs from TTF files
|
|
/// it loads (mirrors compositor/font's native backend: sizes are em sizes in pixels).
|
|
interface font {
|
|
/// Load the TTF file at `path` into `slot` (0..3). False when it can't be read or parsed.
|
|
load: func(slot: u32, path: string) -> bool;
|
|
|
|
/// One rendered glyph: an 8-bit coverage bitmap `width` x `height`, whose top-left sits at
|
|
/// (`xoff`, `yoff`) from the pen on the baseline (y grows downward), and the pen advance.
|
|
record glyph {
|
|
width: s32,
|
|
height: s32,
|
|
xoff: s32,
|
|
yoff: s32,
|
|
advance: s32,
|
|
coverage: list<u8>,
|
|
}
|
|
rasterise: func(slot: u32, codepoint: u32, size: u32) -> glyph;
|
|
}
|
|
|
|
/// The compositor as one component: it imports the OS surface and exports its entry point.
|
|
world compositor {
|
|
import sys;
|
|
import font;
|
|
import plasmoids;
|
|
import display;
|
|
import raster;
|
|
/// Run the compositor until it exits. `args` are the command-line arguments (without argv[0]).
|
|
export run: func(args: list<string>) -> s32;
|
|
}
|