summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authormsizanoen1 <msizanoen@qtmlabs.xyz>2022-03-07 11:34:18 +0700
committerRay Strode <halfline@gmail.com>2023-05-08 13:50:11 +0000
commit8b8f8f05025f91fb76d7669630f7387da1d64772 (patch)
treeaf8d918206149e0d16d1837f24c9b4bd4267ca42 /daemon
parentd07f5dcd65a5d9bdd836c259dd760f59fce9a6df (diff)
downloadgdm-8b8f8f05025f91fb76d7669630f7387da1d64772.tar.gz
local-display-factory: Acquire seat name properly
systemd-logind escapes the seat name prior to exposing as a DBus object. As a result, seat names like "seat-name" may be escaped to "seat_x2dname" when exposed as a DBus object. Use DBus to acquire the seat name instead of using the last component of the object path.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gdm-local-display-factory.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 0b7e8928..5b9baebc 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -1037,19 +1037,39 @@ on_seat_properties_changed (GDBusConnection *connection,
const gchar *seat = NULL;
g_autoptr(GVariant) changed_props = NULL;
g_autoptr(GVariant) changed_prop = NULL;
+ g_autoptr(GVariant) reply = NULL;
+ g_autoptr(GVariant) reply_value = NULL;
+ g_autoptr(GError) error = NULL;
g_autofree const gchar **invalidated_props = NULL;
gboolean changed = FALSE;
int ret;
- /* Extract seat id, i.e. the last element of the object path. */
- seat = strrchr (object_path, '/');
- if (seat == NULL)
+ /* Acquire seat name */
+ reply = g_dbus_connection_call_sync (connection,
+ sender_name,
+ object_path,
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)",
+ "org.freedesktop.login1.Seat",
+ "Id"),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+
+ if (reply == NULL) {
+ g_debug ("could not acquire seat name: %s", error->message);
return;
- seat += 1;
+ }
+
+ g_variant_get (reply, "(v)", &reply_value);
- /* Valid seat IDs must start with seat, i.e. ignore "auto" */
- if (!g_str_has_prefix (seat, "seat"))
+ seat = g_variant_get_string (reply_value, NULL);
+
+ if (seat == NULL) {
+ g_debug ("seat name is not string");
return;
+ }
g_variant_get (parameters, "(s@a{sv}^a&s)", NULL, &changed_props, &invalidated_props);