c8-shell: lock, askpass, share, polkit, wallet #
Part of the shell's notes (CLAUDE.md beside this file): the
programs built here that aren't the shell.
c8-lock (lock.c, needs pam-devel; lock feature, pam_dir option for
/etc/pam.d/c8-lock) copies the SDDM theme: clock, slide up, user tile,
password, power menu. PAM runs on a thread. --nested skips logind.
Its background is the lock picture Photos sets (c8-base background.h,
read when it locks, under a quarter black for the clock), else the
pattern; tested headless (c8 -s @lock).
c8-login-picture (login-picture.c, libexec, plain C, root through
pkexec): the sign-in screen's copy of that picture,
/var/lib/cont8nuum/login/USER.jpg (0644, dirs 0755), which the SDDM
theme shows for the chosen user (SDDM runs as sddm and can't read
homes). set reads the JPEG from stdin (no user path opened as root;
first bytes FF D8 FF, 8 MiB at most; written by rename, O_NOFOLLOW in a
root-only dir), remove deletes it; only for PKEXEC_UID's user, never
root, plain names only. Nothing decodes it: like an AccountsService
icon, the greeter does. The polkit action
org.cont8nuum.login-picture (data/polkit/*.policy.in, login_picture
option, only for /usr prefixes: polkit reads /usr/share only) lets the
active local user without a password. The shell runs it (loginpic.c):
when Start's watch sees the lock picture change (2 s settle) and 15 s
after it starts, only if the hash differs from the last one sent
($XDG_STATE_HOME/cont8nuum/login-picture), not nested, not without
the policy and helper. Tested: the helper in unshare -rm with a
scratch /var/lib bound over (set, remove twice, a PNG, 9 MB, no
PKEXEC_UID, root, a bad argument), the theme in sddm-greeter-qt6 --test-mode in a nested c8 (picture, and the pattern without). Untested:
pkexec and the policy for real (needs --install), the shell's call.
c8-askpass (askpass.c): the askpass for sudo -A, ssh and git, styled
after Windows 8's UAC: a layer-shell overlay dimming the screen (plain
window without layer shell) with a card: blue band when the caller is
known (parent is sudo, ssh, git…, and not by name alone: sudo's /proc
entry must be root's, the others root's files under /usr; sudo's
command and -u are read from /proc), yellow when not; user tile and password box, Details, Yes/No.
Prints the answer + newline, exit 1 for No/Escape; SSH_ASKPASS_PROMPT
confirm/none and ssh's "(yes/no" question (prints yes/no) are handled.
build.sh prefers it for sudo.
c8-share (share.c): the portal's picker (xdpw runs it, it prints
Monitor: NAME or Window: ID, nothing and exit 1 for Cancel/Escape).
A layer-shell overlay dimming the screen, a band in Start's colour
across it: Screens, then Windows (newest first, icon and app name from
the desktop entry), each a picture taken once over
ext-image-copy-capture (screens before the band maps, else it'd be in
them; up to a second), Share/Cancel. Click picks, a second click or
Enter shares, arrows move. Like xdpw, it sees wl_outputs out of the
layout (is_portal in xdgoutput.c), so the glasses' view is a screen
there. Narrow: two to a row. Tested headless, wide and at 480: the
pictures (a hidden window's too), keys, Escape, double click, and a
ScreenCast portal call through xdpw 0.8.5 returning a window stream.
Untested: what a consumer receives from that stream, XR.
c8-askpass and c8-polkit share the card's pieces in uac.h (shield, account
picture, band, footer, the dimmed overlay); pixels.h's
account_read_for reads any account (root's for polkit). In stealth
mode (c8-base) our own account shows the persona's name and no picture;
askpass's prompt, polkit's message, details and our login in its
account combo are scrubbed (c8_stealth_show); c8-lock calls
c8_stealth_config_dir before reading the account. All untested.
c8-polkit (polkit.c, in libexec, polkit feature, needs polkit-devel):
the session's polkit agent (libpolkit-agent-1), run by
cont8nuum-polkit-agent.service through c8-polkit-agent, which falls
back to another installed agent only when it exits 3 (no compositor or
layer shell, no session, another agent registered). It registers for
its own session, or as a user service logind's Display session of the
user; --process PID registers for one process instead (testing beside
the real agent: pkcheck --action-id ID --process PID -u). Requests
queue, one card at a time: polkit's message, Program (pkexec's
program, else the subject pid's name), Verified publisher (the
action's vendor, from EnumerateActions, reread on changed), Runs as;
Details has the action, the asker, the command and other details keys.
Our own account when polkit lists it, else root ("Administrator"), a
combo when several. A wrong password keeps the card (PAM's error, else
"The password is incorrect"), a fresh session each try; the box can be
typed in before the helper asks. No/Escape is dismissed, the caller
cancelling closes the card. Tested headless (nested c8, --process):
the card, a wrong root password, Escape, the caller giving up, two
queued requests; the session lookup as a user service. Untested: a
right password, PAM info messages (fingerprint), the account combo.
c8-wallet (wallet.c, in libexec, cont8nuum-wallet.service, wanted by
the session target) runs oo7-daemon (0.6+, from packaging/build-oo7.sh, not
Tumbleweed's 0.4.3) and opens the wallet (~/.local/share/keyrings/v1/ login.keyring). The daemon starts locked; passwords go to its PAM
socket (/run/user/UID/oo7-pam.sock, OO7_PAM_SOCKET moves it; message
format in src/oo7-pam.h, shared with the PAM module). First the login
password: pam_c8wallet.so (pam-wallet.c, by full path in
/etc/pam.d/sddm, added by data/wallet/pam-c8wallet.sh, wallet_pam
option) keeps it in auth and at session open starts c8-wallet-keeper
as the user, which gives it once to a caller whose exe is c8-wallet
over $XDG_RUNTIME_DIR/c8-wallet.sock (the installed one, by its whole path) (2 min, then forgets). If that
doesn't open it (or there's none: autologin) it asks with c8-askpass (3
tries, C8_ASKPASS_RETRY marks a retry, a new wallet asked twice); a
typed password that isn't the login one is changed to it
(ChangePassword), so the wallet follows the login password however it
was changed. pam_c8wallet's chauthtok (in /etc/pam.d/passwd too) does
the same at once when the daemon runs. Cancelled: the daemon stays,
locked. It holds the secrets name (replaceable) while starting. Test with
pam_start_confdir and a short runtime dir (socket paths max 108).
c8 sets GNOME_DESKTOP_SESSION_ID (set_wallet, session.c) so Chromium
and Electron apps use the Secret Service instead of their built-in key;
on 0.4.3 they'd hang (no /aliases/default, libsecret then calls
CreateCollection, which panics). The Secret portal is oo7-portal (a
user-unit drop-in from packaging/build-oo7.sh runs the 0.6 one).
packaging/build-oo7.sh: fetches the release (sha256 checked) into .oo7/,
applies packaging/oo7/ (0001: the PAM listener deleted its socket after
the first message; fixed on upstream main), builds with cargo, installs
into /usr/local/libexec. c8-wallet-import [--clear] (python) copies
KWallet's items in (from cont8nuum via ksecretd on a private bus; --clear
empties the wallet first, backup login.keyring.bak-DATE), gives
look-alike ones a c8:name attribute, and bridges app keys: "NAME
Keys/NAME Safe Storage" to Chromium's libsecret item, the KWallet
portal's "xdg-desktop-portal/APP_ID" to oo7-portal's.