weston: allow weston to be started from a systemd user session 68/26968/2
authorArnaud Ferraris <arnaud.ferraris@collabora.com>
Mon, 6 Dec 2021 18:15:55 +0000 (19:15 +0100)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Wed, 8 Dec 2021 13:04:08 +0000 (13:04 +0000)
As part of the App FW rework, we want weston to be started from a
systemd user session, which is allowed by this patch (backported from
upstream).

Bug-AGL: SPEC-4161
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Change-Id: I23961eaebb65bdbdcfd8c3d01ff1941f978385ec
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/26968
Tested-by: Jenkins Job builder account
ci-image-build: Jenkins Job builder account
ci-image-boot-test: Jenkins Job builder account
Reviewed-by: Scott Murray <scott.murray@konsulko.com>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
meta-agl-core/recipes-graphics/wayland/weston/0002-Allow-weston-to-start-from-a-systemd-user-session.patch [new file with mode: 0644]
meta-agl-core/recipes-graphics/wayland/weston_8.0_aglcore.inc

diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0002-Allow-weston-to-start-from-a-systemd-user-session.patch b/meta-agl-core/recipes-graphics/wayland/weston/0002-Allow-weston-to-start-from-a-systemd-user-session.patch
new file mode 100644 (file)
index 0000000..d45f93a
--- /dev/null
@@ -0,0 +1,75 @@
+From b6c891774e23762d6289447ab588bf739a55f628 Mon Sep 17 00:00:00 2001
+From: Derek Foreman <derek.foreman@collabora.com>
+Date: Thu, 15 Jul 2021 12:22:49 -0500
+Subject: [PATCH] launcher-logind: Try the user's primary session if not in a
+ session
+
+If we're not in a session we can fall back to sd_uid_get_display() to
+find the user's primary session.
+
+This allows launching weston from an ssh session or as a systemd
+user service if a viable session is available.
+
+It also more closely follows how libseat finds the session. The libseat
+launcher can already do these things, so this change makes these
+features common to both launchers.
+
+Based on a patch by Sjoerd Simons <sjoerd.simons@collabora.com>
+
+Upstream-Status: Accepted (to be released with weston 10.0.0)
+
+Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
+---
+ libweston/launcher-logind.c | 29 +++++++++++++++++++++++++----
+ 1 file changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
+index 993d8e1a2..3fca1dff6 100644
+--- a/libweston/launcher-logind.c
++++ b/libweston/launcher-logind.c
+@@ -734,6 +734,29 @@ launcher_logind_activate(struct launcher_logind *wl)
+       return 0;
+ }
++static int
++launcher_logind_get_session(char **session)
++{
++      int r;
++
++      r = sd_pid_get_session(getpid(), session);
++      if (r < 0) {
++              if (r != -ENODATA) {
++                      weston_log("logind: not running in a systemd session: %d\n", r);
++                      return r;
++              }
++      } else {
++              return r;
++      }
++
++      /* When not inside a systemd session look if there is a suitable one */
++      r = sd_uid_get_display(getuid(), session);
++      if (r < 0)
++              weston_log("logind: cannot find systemd session for uid: %d %d\n", getuid(), r);
++
++      return r;
++}
++
+ static int
+ launcher_logind_connect(struct weston_launcher **out, struct weston_compositor *compositor,
+                       int tty, const char *seat_id, bool sync_drm)
+@@ -759,11 +782,9 @@ launcher_logind_connect(struct weston_launcher **out, struct weston_compositor *
+               goto err_wl;
+       }
+-      r = sd_pid_get_session(getpid(), &wl->sid);
+-      if (r < 0) {
+-              weston_log("logind: not running in a systemd session\n");
++      r = launcher_logind_get_session(&wl->sid);
++      if (r < 0)
+               goto err_seat;
+-      }
+       t = NULL;
+       r = sd_session_get_seat(wl->sid, &t);
+-- 
+GitLab
index 598215e..06a1c83 100644 (file)
@@ -1,6 +1,7 @@
 FILESEXTRAPATHS:append := ":${THISDIR}/weston"
 
 SRC_URI:append = "\
+    file://0002-Allow-weston-to-start-from-a-systemd-user-session.patch \
     file://0005-correctly-tear-down-drm-backend.patch \
     "