Private bus: don't take over the session's document portal mount
CI / test (push) Canceled after 24m10s
CI / test (push) Canceled after 24m10s
A nested compositor's private D-Bus kept the session's XDG_RUNTIME_DIR, so an xdg-document-portal activated on it mounted over $XDG_RUNTIME_DIR/doc and removed the mount when the bus exited. The session's portal kept running without it, and flatpak apps stopped starting. The bus now has its own config that starts the document portal with a runtime directory per compositor. scripts/test-private-bus.sh covers it. The KDE colors test gets its own runtime directory for the same reason. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50149e6b99
commit
70b24ffe47
5 files changed
+182
-4
No files matched your search
@@ -53,9 +53,12 @@ echo "kdeglobals: ok"
|
||||
for c in kwrite Xvfb import convert dbus-run-session; do
|
||||
command -v $c >/dev/null 2>&1 || { echo "skipping the KWrite check ($c not installed)"; exit 0; }
|
||||
done
|
||||
export XDG_CONFIG_HOME="$tmp/kw" HOME="$tmp/kw/home" DISPLAY=:77 QT_QPA_PLATFORM=xcb \
|
||||
QT_QPA_PLATFORMTHEME=kde KC tmp
|
||||
# Its own runtime dir: a document portal started on this private bus would otherwise take over the
|
||||
# session's $XDG_RUNTIME_DIR/doc mount, and remove it on exit.
|
||||
export XDG_CONFIG_HOME="$tmp/kw" HOME="$tmp/kw/home" XDG_RUNTIME_DIR="$tmp/run" DISPLAY=:77 \
|
||||
QT_QPA_PLATFORM=xcb QT_QPA_PLATFORMTHEME=kde KC tmp
|
||||
mkdir -p "$HOME"
|
||||
mkdir -m 700 "$XDG_RUNTIME_DIR"
|
||||
Xvfb :77 -screen 0 800x600x24 >/dev/null 2>&1 & xvfb=$!
|
||||
trap 'kill $xvfb 2>/dev/null; rm -rf "$tmp"' EXIT
|
||||
sleep 1
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the private session bus's end-to-end test (compositor/sys): a nested compositor's apps must
|
||||
# not be able to take over the session's document portal mount. A "host" xdg-document-portal
|
||||
# mounts doc/ in a throwaway runtime directory, as a login session's does; the test spawns an app
|
||||
# that asks the compositor's private bus for another one, which must mount elsewhere (and
|
||||
# xdg-desktop-portal must still work there); the host's mount must still be there after the
|
||||
# compositor (the test process) and its bus are gone. Needs FUSE, dbus-daemon, xdg-document-portal
|
||||
# and xdg-desktop-portal; skips without them. Extra arguments go to `moon test`.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
export PATH="$HOME/.moon/bin:$PATH"
|
||||
XDOC=
|
||||
for x in /usr/libexec/xdg-document-portal /usr/lib/xdg-document-portal; do
|
||||
[ -x "$x" ] && XDOC=$x && break
|
||||
done
|
||||
skip() { echo "private bus test skipped: $1"; exit 0; }
|
||||
[ -n "$XDOC" ] || skip "xdg-document-portal not installed"
|
||||
[ -x "${XDOC%/*}/xdg-desktop-portal" ] || skip "xdg-desktop-portal not installed"
|
||||
[ -w /dev/fuse ] && command -v fusermount3 >/dev/null || skip "no FUSE"
|
||||
command -v dbus-daemon >/dev/null && command -v dbus-send >/dev/null || skip "no dbus-daemon"
|
||||
tmp=$(mktemp -d)
|
||||
mkdir -m 700 "$tmp/run"
|
||||
export XDG_RUNTIME_DIR="$tmp/run" XDG_DATA_HOME="$tmp/data"
|
||||
addr_pid=$(dbus-daemon --session --fork --print-address=1 --print-pid=1)
|
||||
export DBUS_SESSION_BUS_ADDRESS=$(echo "$addr_pid" | sed -n 1p)
|
||||
DPID=$(echo "$addr_pid" | sed -n 2p)
|
||||
cleanup() {
|
||||
kill ${XPID:-} "$DPID" 2>/dev/null || true
|
||||
sleep 1
|
||||
fusermount3 -u -z "$tmp/run/doc" 2>/dev/null || true
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
mounted() { grep -q -F " $tmp/run/doc " /proc/self/mountinfo; }
|
||||
"$XDOC" -v >"$tmp/xdoc.log" 2>&1 &
|
||||
XPID=$!
|
||||
for _ in $(seq 50); do mounted && break; sleep 0.1; done
|
||||
mounted || { cat "$tmp/xdoc.log"; skip "the document portal could not mount here"; }
|
||||
# WAYLAND_DISPLAY makes the compositor "nested", which is when it starts a private bus.
|
||||
CHANDRA_PRIVATE_BUS_E2E=1 WAYLAND_DISPLAY=wayland-host \
|
||||
moon test --target native --warn-list -a compositor/sys "$@"
|
||||
sleep 2 # for the private bus, and anything it started, to exit
|
||||
mounted || { echo "FAIL: the host's $tmp/run/doc mount is gone"; cat "$tmp/xdoc.log"; exit 1; }
|
||||
echo "private bus: ok"
|
||||
@@ -53,4 +53,5 @@ fi
|
||||
XDG_CONFIG_HOME="$(mktemp -d)" CHANDRA_TEST_CONFIG=1 \
|
||||
moon test --target native --warn-list -a compositor/renderer compositor/gfx compositor/wasm \
|
||||
compositor/network compositor/portal compositor/polkit compositor/x11 compositor/host
|
||||
scripts/test-private-bus.sh
|
||||
moon build --target native --warn-list -a compositor/bin
|
||||
Reference in new issue
Block a user