summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/wayland/weston-init.bb
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.bb
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.bb')
-rw-r--r--meta/recipes-graphics/wayland/weston-init.bb33
1 files changed, 21 insertions, 12 deletions
diff --git a/meta/recipes-graphics/wayland/weston-init.bb b/meta/recipes-graphics/wayland/weston-init.bb
index a616c473ec..65d7b81dc5 100644
--- a/meta/recipes-graphics/wayland/weston-init.bb
+++ b/meta/recipes-graphics/wayland/weston-init.bb
@@ -7,9 +7,8 @@ PACKAGE_ARCH = "${MACHINE_ARCH}"
SRC_URI = "file://init \
file://weston.env \
file://weston.ini \
- file://weston@.service \
- file://weston@.socket \
- file://71-weston-drm.rules \
+ file://weston.service \
+ file://weston.socket \
file://weston-autologin \
file://weston-start"
@@ -36,17 +35,15 @@ do_install() {
install -Dm644 ${WORKDIR}/weston.env ${D}${sysconfdir}/default/weston
# Install Weston systemd service and accompanying udev rule
- install -D -p -m0644 ${WORKDIR}/weston@.service ${D}${systemd_system_unitdir}/weston@.service
- install -D -p -m0644 ${WORKDIR}/weston@.socket ${D}${systemd_system_unitdir}/weston@.socket
+ install -D -p -m0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}/weston.service
+ install -D -p -m0644 ${WORKDIR}/weston.socket ${D}${systemd_system_unitdir}/weston.socket
if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
install -D -p -m0644 ${WORKDIR}/weston-autologin ${D}${sysconfdir}/pam.d/weston-autologin
fi
sed -i -e s:/etc:${sysconfdir}:g \
-e s:/usr/bin:${bindir}:g \
-e s:/var:${localstatedir}:g \
- ${D}${systemd_unitdir}/system/weston@.service
- install -D -p -m0644 ${WORKDIR}/71-weston-drm.rules \
- ${D}${sysconfdir}/udev/rules.d/71-weston-drm.rules
+ ${D}${systemd_unitdir}/system/weston.service
# Install weston-start script
install -Dm755 ${WORKDIR}/weston-start ${D}${bindir}/weston-start
sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start
@@ -58,11 +55,15 @@ do_install() {
if [ "${@bb.utils.contains('PACKAGECONFIG', 'no-idle-timeout', 'yes', 'no', d)}" = "yes" ]; then
sed -i -e "/^\[core\]/a idle-time=0" ${D}${sysconfdir}/xdg/weston/weston.ini
fi
+
+ install -dm 755 -o weston -g weston ${D}/home/weston
}
INHIBIT_UPDATERCD_BBCLASS = "${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'systemd', '1', '', d)}"
-inherit update-rc.d features_check systemd
+inherit update-rc.d features_check systemd useradd
+
+USERADD_PACKAGES = "${PN}"
# rdepends on weston which depends on virtual/egl
# requires pam enabled if started via systemd
@@ -73,10 +74,18 @@ RDEPENDS_${PN} = "weston kbd"
INITSCRIPT_NAME = "weston"
INITSCRIPT_PARAMS = "start 9 5 2 . stop 20 0 1 6 ."
-FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_system_unitdir}/weston@.service ${systemd_system_unitdir}/weston@.socket ${sysconfdir}/default/weston ${sysconfdir}/pam.d/"
+FILES_${PN} += "\
+ ${sysconfdir}/xdg/weston/weston.ini \
+ ${systemd_system_unitdir}/weston.service \
+ ${systemd_system_unitdir}/weston.socket \
+ ${sysconfdir}/default/weston \
+ ${sysconfdir}/pam.d/ \
+ /home/weston \
+ "
CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${sysconfdir}/default/weston"
-SYSTEMD_SERVICE_${PN} = "weston@%i.service"
-SYSTEMD_AUTO_ENABLE = "disable"
+SYSTEMD_SERVICE_${PN} = "weston.service weston.socket"
+USERADD_PARAM_${PN} = "--home /home/weston --shell /bin/sh --user-group -G video,input weston"
+GROUPADD_PARAM_${PN} = "-r wayland"