[PATCH v2 5/6] host/rootfs: add wayland group

Alyssa Ross
2025-12-09T12:12:27Z

This will allow clients running as unprivileged users to connect to
the compositor.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
Message-ID: <20251209085628.603316-5-hi@alyssa.is>
---
v2: avoid widening umask for weston
v1: https://spectrum-os.org/lists/archives/spectrum-devel/20251209085628.603316-5-hi@alyssa.is/

.../etc/s6-linux-init/run-image/etc/group | 1 +
.../image/etc/s6-rc/weston/notification-fd | 2 +-
.../etc/s6-rc/weston/notification-fd.license | 2 +-
host/rootfs/image/etc/s6-rc/weston/run | 21 +++++++++++++++++++
4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/etc/group b/host/rootfs/image/etc/s6-linux-init/run-image/etc/group
index e3ade468..fe72eb76 100644
--- a/host/rootfs/image/etc/s6-linux-init/run-image/etc/group
+++ b/host/rootfs/image/etc/s6-linux-init/run-image/etc/group
@@ -13,3 +13,4 @@ disk:x:11:
cdrom:x:12:
tape:x:13:
kvm:x:14:
+wayland:x:15:
diff --git a/host/rootfs/image/etc/s6-rc/weston/notification-fd b/host/rootfs/image/etc/s6-rc/weston/notification-fd
index 00750edc..7ed6ff82 100644
--- a/host/rootfs/image/etc/s6-rc/weston/notification-fd
+++ b/host/rootfs/image/etc/s6-rc/weston/notification-fd
@@ -1 +1 @@
-3
+5
diff --git a/host/rootfs/image/etc/s6-rc/weston/notification-fd.license b/host/rootfs/image/etc/s6-rc/weston/notification-fd.license
index c49c11b6..0d3d47ca 100644
--- a/host/rootfs/image/etc/s6-rc/weston/notification-fd.license
+++ b/host/rootfs/image/etc/s6-rc/weston/notification-fd.license
@@ -1,2 +1,2 @@
SPDX-License-Identifier: CC0-1.0
-SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+SPDX-FileCopyrightText: 2025 Alyssa Ross <hi@alyssa.is>
diff --git a/host/rootfs/image/etc/s6-rc/weston/run b/host/rootfs/image/etc/s6-rc/weston/run
index aa1e7b61..167675de 100644
--- a/host/rootfs/image/etc/s6-rc/weston/run
+++ b/host/rootfs/image/etc/s6-rc/weston/run
@@ -4,6 +4,26 @@

importas -Siu WAYLAND_DISPLAY

+piperw 4 3
+background {
+ fdclose 3
+
+ if {
+ fdmove -c 0 4
+ redirfd -w 1 /dev/null
+ head -c 1
+ }
+ fdclose 4
+
+ if { chmod -- 0770 $WAYLAND_DISPLAY }
+ if { chgrp -- wayland $WAYLAND_DISPLAY }
+
+ fdmove -c 1 5
+ echo
+}
+fdclose 4
+fdclose 5
+
# Workaround for
# https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/1911
if { mkdir -p -m 0700 /run/user/0 }
@@ -20,4 +40,5 @@ importas -i home HOME
cd $home
if { udevadm wait /dev/dri/card0 }
unshare --cgroup --ipc --net --uts
+
weston -S $WAYLAND_DISPLAY
--
2.51.0