run0: install via scripts/as-root, chandra-root for GUI apps as root, session refuses root
CI / test (push) Failing after 16s
CI / test (push) Failing after 16s
- scripts/as-root runs a command as root with run0 (systemd PID 1 + run0 present), else sudo, doas or pkexec; resolves the program to an absolute path since run0 doesn't inherit PATH. The install-session recipes use it and pass install.py by absolute path. - session/chandra-root (installed to /usr/local/bin): run a graphical app as root inside Chandra, passing WAYLAND_DISPLAY (absolute) and the Wayland toolkit variables through run0 --setenv (or sudo/doas/pkexec env). - chandra-session: refuses to run as root (CHANDRA_ALLOW_ROOT=1 overrides), fills in HOME and XDG_RUNTIME_DIR when started without a login environment, logs when the logind session has no seat (run0 --user / su / ssh), and starts an installed polkit agent once the socket is up so run0/pkexec from the launcher can prompt (CHANDRA_POLKIT_AGENT picks one or 'none'). - install.py: checks for root before --remove too; installs chandra-root. - docs/run0.md: invocations for installing, starting from a TTY, apps as root, polkit agents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hkq6Hq7AXG85g5HyJU
This commit is contained in:
7 files changed
+254
-8
No files matched your search
@@ -5,6 +5,27 @@
|
||||
# WebAssembly component, run by chandra-host; if only the native binary was installed
|
||||
# (session/install.py --native), it runs that instead.
|
||||
share=/usr/local/share/chandra
|
||||
|
||||
# The desktop runs as the user who logged in, never as root: as root (say `run0 chandra-session`
|
||||
# or `sudo chandra-session`) every app would run as root, its socket would live in root's runtime
|
||||
# dir where your apps can't see it, and settings would land in /root. For one app that needs
|
||||
# root, use `chandra-root APP` inside the session. CHANDRA_ALLOW_ROOT=1 overrides this.
|
||||
if [ "$(id -u)" = 0 ] && [ -z "$CHANDRA_ALLOW_ROOT" ]; then
|
||||
echo "chandra-session: refusing to run the desktop as root; start it as yourself" \
|
||||
"(use chandra-root APP for single apps that need root)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Started from a login without the usual session environment (run0 --user=..., su, a bare
|
||||
# `env -i`): fill in HOME and the runtime directory from the system instead of falling back to
|
||||
# /tmp, so the socket lands where apps and chandra-root look for it.
|
||||
if [ -z "$HOME" ]; then
|
||||
HOME=$(getent passwd "$(id -u)" | cut -d: -f6)
|
||||
export HOME
|
||||
fi
|
||||
if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$(id -u)" ] && [ -O "/run/user/$(id -u)" ]; then
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
fi
|
||||
case "$0" in /*) self="$0" ;; *) self="$PWD/$0" ;; esac # for the dbus-run-session re-exec
|
||||
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
@@ -65,5 +86,49 @@ if command -v gnome-keyring-daemon >/dev/null 2>&1; then
|
||||
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
|
||||
fi
|
||||
|
||||
# A logind session without a seat (made by run0 --user=..., su - or ssh rather than by logging in
|
||||
# on the VT) can't open the screen and input devices through logind; say so in the log, since
|
||||
# the compositor's own error ("could not take control of the session") doesn't explain why.
|
||||
if [ -n "$XDG_SESSION_ID" ] && command -v loginctl >/dev/null 2>&1; then
|
||||
seat=$(loginctl show-session "$XDG_SESSION_ID" -p Seat --value 2>/dev/null)
|
||||
if [ -z "$seat" ]; then
|
||||
echo "chandra-session: login session $XDG_SESSION_ID has no seat (started by run0, su or" \
|
||||
"ssh?); log in on the VT itself, or DRM/input access through logind will fail" >>"$log"
|
||||
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
|
||||
|
||||
exec "$@" --drm --socket "$sock" \
|
||||
--theme "$share/config/themes/moon-night.json" >>"$log" 2>&1
|
||||
Reference in new issue
Block a user