summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/wayland/weston-init/weston.service
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-11-19 16:58:53 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-11-24 10:27:38 +0000
commitdd83fb40f76749c6689807afabc63b9d5c2a4065 (patch)
tree944b8188c95f60d2f89c69b9471d8a51024bca56 /meta/recipes-graphics/wayland/weston-init/weston.service
parent38e499e04d04934b40a29af469592754842d92d3 (diff)
downloadopenembedded-core-contrib-dd83fb40f76749c6689807afabc63b9d5c2a4065.tar.gz
weston-init: Stop running weston as root
Running the weston compositor as the root user is an insecure default behavior for OE-core. We can do much better, at least when using systemd. Change the recipe to create a dedicated "weston" user and start weston as this user. The systemd service and socket units are no longer template units, as there were several inconsistencies in the templates. Instead, there is now a global /run/wayland-0 socket that gets created, and systemd will start weston on demand when a client connects to that socket or when attempting to reach graphical.target, whichever comes first. This also allows downstream users to easily change the behavior so that weston *only* starts on demand by adding a drop file. Access to the global socket is controlled by a "wayland" group; any user that is a member of the group can use the socket to talk to the compositor. This also satisfies another use case where another systemd service might start a graphical application that needs to display with weston (e.g. a single function device in kiosk mode). Finally, the udev rules for starting weston with the existance of a DRM device have been removed. Being WantedBy= a graphical target should eliminate the need for this behavior, and having it present makes it difficult for downstream users to start weston on demand (having to override the udev rules). Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-graphics/wayland/weston-init/weston.service')
-rw-r--r--meta/recipes-graphics/wayland/weston-init/weston.service71
1 files changed, 71 insertions, 0 deletions
diff --git a/meta/recipes-graphics/wayland/weston-init/weston.service b/meta/recipes-graphics/wayland/weston-init/weston.service
new file mode 100644
index 0000000000..e09625b31c
--- /dev/null
+++ b/meta/recipes-graphics/wayland/weston-init/weston.service
@@ -0,0 +1,71 @@
+# This is a system unit for launching Weston with auto-login as the
+# user configured here.
+#
+# Weston must be built with systemd support, and your weston.ini must load
+# the plugin systemd-notify.so.
+[Unit]
+Description=Weston, a Wayland compositor, as a system service
+Documentation=man:weston(1) man:weston.ini(5)
+Documentation=http://wayland.freedesktop.org/
+
+# Make sure we are started after logins are permitted.
+Requires=systemd-user-sessions.service
+After=systemd-user-sessions.service
+
+# If Plymouth is used, we want to start when it is on its way out.
+After=plymouth-quit-wait.service
+
+# D-Bus is necessary for contacting logind. Logind is required.
+Wants=dbus.socket
+After=dbus.socket
+
+# Ensure the socket is present
+Requires=weston.socket
+
+# Since we are part of the graphical session, make sure we are started before
+# it is complete.
+Before=graphical.target
+
+# Prevent starting on systems without virtual consoles, Weston requires one
+# for now.
+ConditionPathExists=/dev/tty0
+
+[Service]
+# Requires systemd-notify.so Weston plugin.
+Type=notify
+EnvironmentFile=/etc/default/weston
+ExecStart=/usr/bin/weston --modules=systemd-notify.so
+
+# Optional watchdog setup
+TimeoutStartSec=60
+WatchdogSec=20
+
+# The user to run Weston as.
+User=weston
+Group=weston
+
+# Make sure the working directory is the users home directory
+WorkingDirectory=/home/weston
+
+# Set up a full user session for the user, required by Weston.
+PAMName=weston-autologin
+
+# A virtual terminal is needed.
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+# Fail to start if not controlling the tty.
+StandardInput=tty-fail
+StandardOutput=journal
+StandardError=journal
+
+# Log this user with utmp, letting it show up with commands 'w' and 'who'.
+UtmpIdentifier=tty7
+UtmpMode=user
+
+[Install]
+# Note: If you only want weston to start on-demand, remove this line with a
+# service drop file
+WantedBy=graphical.target