1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
|