Skip to contentSkip to conversation

weston-init: Run drm udev rule after systemd multi-seat setup

PATCH In review Khem Raj 2 participants 3 messages Sep 9, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 weston-init: Run drm udev rule after systemd multi-seat setup

Currently, weston when autolauched with systemd ends up with seat0 related errors because its launched before seat0 is assigned. The udev rule to install the seat is called 72-seat-drm-pci-0000_00_02_0.rules which sorts after 71-weston-drm.rules, renaming it to 73-weston-drm.rules ensures the right sequence

Fixes
[05:16:09.357] logind: failed to get session seat
[05:16:09.358] logind: cannot setup systemd-logind helper (-61), using legacy fallback

Also fixes weston ptests
RESULTS - weston.WestonTest.test_weston_can_initialize_new_wayland_compositor: PASSED (8.58s)

---
 meta/recipes-graphics/wayland/weston-init.bb  |  8 ++-
 .../wayland/weston-init/weston-autologin      | 11 +++
 .../wayland/weston-init/[email protected]       | 69 ++++++++++++++++---
 .../wayland/weston-init/[email protected]        | 10 +++
 4 files changed, 87 insertions(+), 11 deletions(-)
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston-autologin
 create mode 100644 meta/recipes-graphics/wayland/weston-init/[email protected]
meta/recipes-graphics/wayland/weston-init.bb +7 -1
index 40aa76295f..95d75556dc 100644
@@ -8,7 +8,9 @@ SRC_URI = "file://init \
            file://weston.env \
            file://weston.ini \
            file://[email protected] \
+           file://[email protected] \
            file://71-weston-drm.rules \
+           file://weston-autologin \
            file://weston-start"
 
 S = "${WORKDIR}"
@@ -20,6 +22,10 @@ do_install() {
 
 	# Install Weston systemd service and accompanying udev rule
 	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+        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 \
@@ -50,7 +56,7 @@ 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}/[email protected] ${sysconfdir}/default/weston"
+FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_system_unitdir}/[email protected] ${systemd_system_unitdir}/[email protected] ${sysconfdir}/default/weston ${sysconfdir}/pam.d/"
 
 CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${sysconfdir}/default/weston"
 
meta/recipes-graphics/wayland/weston-init/weston-autologin new file +11 -0
new file mode 100644
index 0000000000..f6e6d106de
@@ -0,0 +1,11 @@
+auth      required  pam_nologin.so
+auth      required  pam_unix.so     try_first_pass nullok
+
+account   required  pam_nologin.so
+account   required  pam_unix.so
+
+session   required  pam_env.so
+session   required  pam_unix.so
+-session  optional  pam_systemd.so type=wayland class=user desktop=weston
+-session  optional  pam_loginuid.so
+
meta/recipes-graphics/wayland/weston-init/[email protected] +59 -10

74 lines not on this page · raw message

meta/recipes-graphics/wayland/weston-init/[email protected] new file +10 -0
new file mode 100644
index 0000000000..f1790d74a8
@@ -0,0 +1,10 @@
+[Unit]
+Description=Weston Wayland socket
[email protected]
+
+[Socket]
+ListenStream=/run/user/1000/wayland-%I
+
+[Install]
+WantedBy=sockets.target
+
Signature · 1 line
2.28.0
#1 lore raw
Quoted 5 lines · Khem Raj

Currently, weston when autolauched with systemd ends up with seat0 related errors because its launched before seat0 is assigned. The udev rule to install the seat is called 72-seat-drm-pci-0000_00_02_0.rules which sorts after 71-weston-drm.rules, renaming it to 73-weston-drm.rules ensures the right sequence

Hi,

I can not see any renaming of 71-weston-drm.rules to 73-weston-drm.rules in this patch.

Bye Henning

Quoted 170 lines

Fixes
[05:16:09.357] logind: failed to get session seat
[05:16:09.358] logind: cannot setup systemd-logind helper (-61), using legacy fallback

Also fixes weston ptests
RESULTS - weston.WestonTest.test_weston_can_initialize_new_wayland_compositor: PASSED (8.58s)

---
 meta/recipes-graphics/wayland/weston-init.bb  |  8 ++-
 .../wayland/weston-init/weston-autologin      | 11 +++
 .../wayland/weston-init/[email protected]       | 69 ++++++++++++++++---
 .../wayland/weston-init/[email protected]        | 10 +++
 4 files changed, 87 insertions(+), 11 deletions(-)
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston-autologin
 create mode 100644 meta/recipes-graphics/wayland/weston-init/[email protected]
meta/recipes-graphics/wayland/weston-init.bb +7 -1
index 40aa76295f..95d75556dc 100644
@@ -8,7 +8,9 @@ SRC_URI = "file://init \
            file://weston.env \
            file://weston.ini \
            file://[email protected] \
+           file://[email protected] \
            file://71-weston-drm.rules \
+           file://weston-autologin \
            file://weston-start"
 
 S = "${WORKDIR}"
@@ -20,6 +22,10 @@ do_install() {
 
 	# Install Weston systemd service and accompanying udev rule
 	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+	install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+        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 \
@@ -50,7 +56,7 @@ 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}/[email protected] ${sysconfdir}/default/weston"
+FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_system_unitdir}/[email protected] ${systemd_system_unitdir}/[email protected] ${sysconfdir}/default/weston ${sysconfdir}/pam.d/"
 
 CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${sysconfdir}/default/weston"
 
meta/recipes-graphics/wayland/weston-init/weston-autologin new file +11 -0
new file mode 100644
index 0000000000..f6e6d106de
@@ -0,0 +1,11 @@
+auth      required  pam_nologin.so
+auth      required  pam_unix.so     try_first_pass nullok
+
+account   required  pam_nologin.so
+account   required  pam_unix.so
+
+session   required  pam_env.so
+session   required  pam_unix.so
+-session  optional  pam_systemd.so type=wayland class=user desktop=weston
+-session  optional  pam_loginuid.so
+
meta/recipes-graphics/wayland/weston-init/[email protected] +59 -10
index 39e193014a..0a1df15bdf 100644
@@ -1,15 +1,64 @@
+# 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 Wayland Compositor
-RequiresMountsFor=/run
-Conflicts=plymouth-quit.service
-After=systemd-user-sessions.service plymouth-quit-wait.service
+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.
+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
+
+# 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]
-User=%i
-PAMName=login
-EnvironmentFile=-/etc/default/weston
+# Requires systemd-notify.so Weston plugin.
+Type=notify
+ExecStart=/usr/bin/weston --modules=systemd-notify.so
+
+# Optional watchdog setup
+TimeoutStartSec=60
+WatchdogSec=20
+
+# The user to run Weston as.
+User=%I
+
+# Make sure working directory is users home directory
+WorkingDirectory=/home/%i
+
+# 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
-PermissionsStartOnly=true
-IgnoreSIGPIPE=no
 
-ExecStart=/usr/bin/weston-start -v -e -- $OPTARGS
+# Log this user with utmp, letting it show up with commands 'w' and 'who'.
+UtmpIdentifier=tty7
+UtmpMode=user
+
+[Install]
+WantedBy=graphical.target
+DefaultInstance=tty7
meta/recipes-graphics/wayland/weston-init/[email protected] new file +10 -0
new file mode 100644
index 0000000000..f1790d74a8
@@ -0,0 +1,10 @@
+[Unit]
+Description=Weston Wayland socket
[email protected]
+
+[Socket]
+ListenStream=/run/user/1000/wayland-%I
+
+[Install]
+WantedBy=sockets.target
+
Signature · 1 line
2.28.0
author
#2 lore raw
Quoted 8 lines · Henning Heinold
Quoted 5 lines · Khem Raj

Currently, weston when autolauched with systemd ends up with seat0 related errors because its launched before seat0 is assigned. The udev rule to install the seat is called 72-seat-drm-pci-0000_00_02_0.rules which sorts after 71-weston-drm.rules, renaming it to 73-weston-drm.rules ensures the right sequence

Quoted 4 lines

Hi,

I can not see any renaming of 71-weston-drm.rules to 73-weston-drm.rules in this patch.

That was tried in between so perhaps should have updated commit msg.

Quoted 174 lines

Bye Henning

Quoted 170 lines

Fixes
[05:16:09.357] logind: failed to get session seat
[05:16:09.358] logind: cannot setup systemd-logind helper (-61), using legacy fallback

Also fixes weston ptests
RESULTS - weston.WestonTest.test_weston_can_initialize_new_wayland_compositor: PASSED (8.58s)

---
 meta/recipes-graphics/wayland/weston-init.bb  |  8 ++-
 .../wayland/weston-init/weston-autologin      | 11 +++
 .../wayland/weston-init/[email protected]       | 69 ++++++++++++++++---
 .../wayland/weston-init/[email protected]        | 10 +++
 4 files changed, 87 insertions(+), 11 deletions(-)
 create mode 100644 meta/recipes-graphics/wayland/weston-init/weston-autologin
 create mode 100644 meta/recipes-graphics/wayland/weston-init/[email protected]
meta/recipes-graphics/wayland/weston-init.bb +7 -1
index 40aa76295f..95d75556dc 100644
@@ -8,7 +8,9 @@ SRC_URI = "file://init \
            file://weston.env \
            file://weston.ini \
            file://[email protected] \
+           file://[email protected] \
            file://71-weston-drm.rules \
+           file://weston-autologin \
            file://weston-start"
 
 S = "${WORKDIR}"
@@ -20,6 +22,10 @@ do_install() {
 
      # Install Weston systemd service and accompanying udev rule
      install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+     install -D -p -m0644 ${WORKDIR}/[email protected] ${D}${systemd_system_unitdir}/[email protected]
+        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 \
@@ -50,7 +56,7 @@ 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}/[email protected] ${sysconfdir}/default/weston"
+FILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${systemd_system_unitdir}/[email protected] ${systemd_system_unitdir}/[email protected] ${sysconfdir}/default/weston ${sysconfdir}/pam.d/"
 
 CONFFILES_${PN} += "${sysconfdir}/xdg/weston/weston.ini ${sysconfdir}/default/weston"
 
meta/recipes-graphics/wayland/weston-init/weston-autologin new file +11 -0
new file mode 100644
index 0000000000..f6e6d106de
@@ -0,0 +1,11 @@
+auth      required  pam_nologin.so
+auth      required  pam_unix.so     try_first_pass nullok
+
+account   required  pam_nologin.so
+account   required  pam_unix.so
+
+session   required  pam_env.so
+session   required  pam_unix.so
+-session  optional  pam_systemd.so type=wayland class=user desktop=weston
+-session  optional  pam_loginuid.so
+
meta/recipes-graphics/wayland/weston-init/[email protected] +59 -10
index 39e193014a..0a1df15bdf 100644
@@ -1,15 +1,64 @@
+# 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 Wayland Compositor
-RequiresMountsFor=/run
-Conflicts=plymouth-quit.service
-After=systemd-user-sessions.service plymouth-quit-wait.service
+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.
+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
+
+# 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]
-User=%i
-PAMName=login
-EnvironmentFile=-/etc/default/weston
+# Requires systemd-notify.so Weston plugin.
+Type=notify
+ExecStart=/usr/bin/weston --modules=systemd-notify.so
+
+# Optional watchdog setup
+TimeoutStartSec=60
+WatchdogSec=20
+
+# The user to run Weston as.
+User=%I
+
+# Make sure working directory is users home directory
+WorkingDirectory=/home/%i
+
+# 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
-PermissionsStartOnly=true
-IgnoreSIGPIPE=no
 
-ExecStart=/usr/bin/weston-start -v -e -- $OPTARGS
+# Log this user with utmp, letting it show up with commands 'w' and 'who'.
+UtmpIdentifier=tty7
+UtmpMode=user
+
+[Install]
+WantedBy=graphical.target
+DefaultInstance=tty7
meta/recipes-graphics/wayland/weston-init/[email protected] new file +10 -1
new file mode 100644
index 0000000000..f1790d74a8
@@ -0,0 +1,10 @@
+[Unit]
+Description=Weston Wayland socket
[email protected]
+
+[Socket]
+ListenStream=/run/user/1000/wayland-%I
+
+[Install]
+WantedBy=sockets.target
+
--

2.28.0