Skip to contentSkip to conversation

weston-init: Add possibility to run weston as non-root user

PATCH Superseded Khem Raj 2 participants 2 messages Sep 10, 2019

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 weston-init: Add possibility to run weston as non-root user

These changes are from meta-96boards primarily
Launch the session via a udev rule based on what kind of display device is available

Cc Otavio Salvador <[email protected]>
---
 meta/recipes-graphics/wayland/weston-init.bb  | 25 ++++++-
 .../wayland/weston-init/71-weston-drm.rules   |  2 +
 .../wayland/weston-init/weston.ini            | 74 +++++++++++++++++++
 .../wayland/weston-init/weston.service        | 13 ----
 .../wayland/weston-init/[email protected]       | 37 ++++++++++
 5 files changed, 134 insertions(+), 17 deletions(-)
 create mode 100644 meta/recipes-graphics/wayland/weston-init/71-weston-drm.rules
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston.ini
 delete mode 100644 meta/recipes-graphics/wayland/weston-init/weston.service
 create mode 100644 meta/recipes-graphics/wayland/weston-init/[email protected]
meta/recipes-graphics/wayland/weston-init.bb +21 -4
index 22ba5f3fb3..86f38fadb4 100644
@@ -3,15 +3,26 @@ LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
 SRC_URI = "file://init \
-           file://weston.service \
+           file://weston.ini \
+           file://[email protected] \
+           file://71-weston-drm.rules \
            file://weston-start"
 
 S = "${WORKDIR}"
 
 do_install() {
 	install -Dm755 ${WORKDIR}/init ${D}/${sysconfdir}/init.d/weston
-	install -Dm0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}/weston.service
-
+	install -Dm0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+	install -D -p -m0644 ${WORKDIR}/weston.ini ${D}${sysconfdir}/xdg/weston/weston.ini
+
+	# Install Weston systemd service and accompanying udev rule
+	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_unitdir}/system/[email protected]
+	sed -i -e s:/etc:${sysconfdir}:g \
+		-e s:/usr/bin:${bindir}:g \
+		-e s:/var:${localstatedir}:g \
+		${D}${systemd_unitdir}/system/[email protected]
+	install -D -p -m0644 ${WORKDIR}/71-weston-drm.rules \
+		${D}${sysconfdir}/udev/rules.d/71-weston-drm.rules
 	# Install weston-start script
 	install -Dm755 ${WORKDIR}/weston-start ${D}${bindir}/weston-start
 	sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start
@@ -28,4 +39,10 @@ RDEPENDS_${PN} = "weston kbd"
 INITSCRIPT_NAME = "weston"
 INITSCRIPT_PARAMS = "start 9 5 2 . stop 20 0 1 6 ."
 
-SYSTEMD_SERVICE_${PN} = "weston.service"
+FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_unitdir}/system/[email protected]"
+
+CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini"
+
+SYSTEMD_SERVICE_${PN} = "weston@%i.service"
+SYSTEMD_AUTO_ENABLE = "disable"
+
meta/recipes-graphics/wayland/weston-init/71-weston-drm.rules new file +2 -0
new file mode 100644
index 0000000000..1a1b8bbda4
@@ -0,0 +1,2 @@
+ACTION=="add", SUBSYSTEM=="graphics", KERNEL=="fb0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="[email protected]"
+ACTION=="add", SUBSYSTEM=="drm", KERNEL=="card0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="[email protected]"
meta/recipes-graphics/wayland/weston-init/weston.ini new file +74 -0

74 lines not on this page · raw message

meta/recipes-graphics/wayland/weston-init/weston.service deleted +0 -13
deleted file mode 100644
index 18f72626e0..0000000000
@@ -1,13 +0,0 @@
-[Unit]
-Description=Weston Wayland Compositor
-RequiresMountsFor=/run
-
-[Service]
-User=root
-PAMName=login
-EnvironmentFile=-/etc/default/weston
-ExecStart=/usr/bin/weston-start -v -e -- $OPTARGS
-
-[Install]
-WantedBy=multi-user.target
-
meta/recipes-graphics/wayland/weston-init/[email protected] new file +37 -0
new file mode 100644
index 0000000000..9ecf2ab069
@@ -0,0 +1,37 @@
+[Unit]
+Description=Weston Wayland Compositor (on tty7)
+RequiresMountsFor=/run
[email protected] plymouth-quit.service
+After=systemd-user-sessions.service [email protected] plymouth-quit-wait.service
+
+[Service]
+User=%i
+PermissionsStartOnly=true
+
+# Log us in via PAM so we get our XDG & co. environment and
+# are treated as logged in so we can use the tty:
+PAMName=login
+
+# Grab tty7
+UtmpIdentifier=tty7
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+# stderr to journal so our logging doesn't get thrown into /dev/null
+StandardOutput=tty
+StandardInput=tty
+StandardError=journal
+
+EnvironmentFile=-/etc/default/weston
+
+# Weston does not successfully change VT, nor does systemd place us on
+# the VT it just activated for us. Switch manually:
+ExecStartPre=/usr/bin/chvt 7
+ExecStart=/usr/bin/weston --log=${XDG_RUNTIME_DIR}/weston.log $OPTARGS
+
+IgnoreSIGPIPE=no
+
+#[Install]
+#Alias=multi-user.target.wants/weston.service
Signature · 1 line
2.23.0
#1 lore raw

On Tue, Sep 10, 2019 at 6:38 PM Khem Raj <[email protected]> wrote:
...

meta/recipes-graphics/wayland/weston-init.bb LICENSE = "MIT" · line 15

Quoted 5 lines
 do_install() {
        install -Dm755 ${WORKDIR}/init ${D}/${sysconfdir}/init.d/weston
meta/recipes-graphics/wayland/weston-init.bb +1 -2
-       install -Dm0644 ${WORKDIR}/weston.service ${D}${systemd_system_unitdir}/weston.service
-
+       install -Dm0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]

Not need, as it is done below.

meta/recipes-graphics/wayland/weston-init.bb LICENSE = "MIT" · line 19

Quoted 4 lines
meta/recipes-graphics/wayland/weston-init.bb +4 -0
+       install -D -p -m0644 ${WORKDIR}/weston.ini ${D}${sysconfdir}/xdg/weston/weston.ini
+
+       # Install Weston systemd service and accompanying udev rule
+       install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_unitdir}/system/[email protected]

This is good. Replace ${systemd_unitdir}/system with ${systemd_system_unitdir}

Quoted 9 lines
meta/recipes-graphics/wayland/weston-init.bb +6 -0
+       sed -i -e s:/etc:${sysconfdir}:g \
+               -e s:/usr/bin:${bindir}:g \
+               -e s:/var:${localstatedir}:g \
+               ${D}${systemd_unitdir}/system/[email protected]
+       install -D -p -m0644 ${WORKDIR}/71-weston-drm.rules \
+               ${D}${sysconfdir}/udev/rules.d/71-weston-drm.rules
        # Install weston-start script
        install -Dm755 ${WORKDIR}/weston-start ${D}${bindir}/weston-start
        sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start

...

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750