[PATCH v2 3/6] host/rootfs: move Wayland out of XDG_RUNTIME_DIR

Alyssa Ross
2025-12-09T12:11:38Z

XDG_RUNTIME_DIR doesn't play well with running the compositor as a
different user to clients.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
Message-ID: <20251209085628.603316-3-hi@alyssa.is>
---
v2: no change

host/rootfs/image/etc/s6-linux-init/env/WAYLAND_DISPLAY | 2 +-
.../vm-services/template/data/service/vhost-user-gpu/run | 6 ++++--
host/rootfs/image/etc/s6-rc/weston/run | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/host/rootfs/image/etc/s6-linux-init/env/WAYLAND_DISPLAY b/host/rootfs/image/etc/s6-linux-init/env/WAYLAND_DISPLAY
index 5ff1a409..bbd390c4 100644
--- a/host/rootfs/image/etc/s6-linux-init/env/WAYLAND_DISPLAY
+++ b/host/rootfs/image/etc/s6-linux-init/env/WAYLAND_DISPLAY
@@ -1 +1 @@
-wayland-1
+/run/wayland
diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
index 73d6caed..6ee99599 100755
--- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
+++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-gpu/run
@@ -5,12 +5,14 @@

s6-ipcserver -1a 0700 -c 1 -b 1 env/crosvm.sock

+importas -Si WAYLAND_DISPLAY
+
bwrap
--unshare-all
# --unshare-all only implies --unshare-user-try.
# Make this more than a "try".
--unshare-user
- --bind /run/user/0/wayland-1 /run/user/0/wayland-1
+ --bind $WAYLAND_DISPLAY $WAYLAND_DISPLAY
--ro-bind /usr /usr
--ro-bind /lib /lib
--tmpfs /tmp
@@ -35,5 +37,5 @@ bwrap
--
crosvm --no-syslog device gpu
--fd 0
- --wayland-sock /run/user/0/wayland-1
+ --wayland-sock $WAYLAND_DISPLAY
--params "{\"context-types\":\"cross-domain\"}"
diff --git a/host/rootfs/image/etc/s6-rc/weston/run b/host/rootfs/image/etc/s6-rc/weston/run
index 41e42e6b..16479909 100644
--- a/host/rootfs/image/etc/s6-rc/weston/run
+++ b/host/rootfs/image/etc/s6-rc/weston/run
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>

-unexport WAYLAND_DISPLAY
+importas -Siu WAYLAND_DISPLAY

if { mkdir -p -m 0700 /run/user/0 }

@@ -18,4 +18,4 @@ importas -i home HOME
cd $home
if { udevadm wait /dev/dri/card0 }
unshare --cgroup --ipc --net --uts
-weston
+weston -S $WAYLAND_DISPLAY
--
2.51.0