From 643bb9240832c238a28cb36efc9d1a6c8d7e6ea0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 13 Dec 2018 18:36:57 +0100 Subject: [PATCH] logind: always check current tag list before using a device --- src/login/logind-core.c | 8 +++++--- src/login/logind-dbus.c | 2 +- src/login/sysfs-show.c | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/login/logind-core.c b/src/login/logind-core.c index e0d61f3e75..0487182225 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -243,7 +243,8 @@ int manager_process_seat_device(Manager *m, sd_device *d) { assert(m); - if (device_for_action(d, DEVICE_ACTION_REMOVE)) { + if (device_for_action(d, DEVICE_ACTION_REMOVE) || + sd_device_has_current_tag(d, "seat") <= 0) { const char *syspath; r = sd_device_get_syspath(d, &syspath); @@ -271,7 +272,7 @@ int manager_process_seat_device(Manager *m, sd_device *d) { } seat = hashmap_get(m->seats, sn); - master = sd_device_has_tag(d, "master-of-seat") > 0; + master = sd_device_has_current_tag(d, "master-of-seat") > 0; /* Ignore non-master devices for unknown seats */ if (!master && !seat) @@ -313,7 +314,8 @@ int manager_process_button_device(Manager *m, sd_device *d) { if (r < 0) return r; - if (device_for_action(d, DEVICE_ACTION_REMOVE)) { + if (device_for_action(d, DEVICE_ACTION_REMOVE) || + sd_device_has_current_tag(d, "power-switch") <= 0) { b = hashmap_get(m->buttons, sysname); if (!b) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index d883288b25..bbec23c850 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1361,7 +1361,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) { if (r < 0) return r; - if (sd_device_has_tag(d, "seat") <= 0) + if (sd_device_has_current_tag(d, "seat") <= 0) return -ENODEV; if (sd_device_get_property_value(d, "ID_FOR_SEAT", &id_for_seat) < 0) diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c index a66be28ad9..9b7fc20396 100644 --- a/src/login/sysfs-show.c +++ b/src/login/sysfs-show.c @@ -53,14 +53,14 @@ static int show_sysfs_one( /* Explicitly also check for tag 'seat' here */ if (!streq(seat, sn) || - sd_device_has_tag(dev_list[*i_dev], "seat") <= 0 || + sd_device_has_current_tag(dev_list[*i_dev], "seat") <= 0 || sd_device_get_subsystem(dev_list[*i_dev], &subsystem) < 0 || sd_device_get_sysname(dev_list[*i_dev], &sysname) < 0) { (*i_dev)++; continue; } - is_master = sd_device_has_tag(dev_list[*i_dev], "master-of-seat") > 0; + is_master = sd_device_has_current_tag(dev_list[*i_dev], "master-of-seat") > 0; if (sd_device_get_sysattr_value(dev_list[*i_dev], "name", &name) < 0) (void) sd_device_get_sysattr_value(dev_list[*i_dev], "id", &name); @@ -80,7 +80,7 @@ static int show_sysfs_one( isempty(lookahead_sn)) lookahead_sn = "seat0"; - if (streq(seat, lookahead_sn) && sd_device_has_tag(dev_list[lookahead], "seat") > 0) + if (streq(seat, lookahead_sn) && sd_device_has_current_tag(dev_list[lookahead], "seat") > 0) break; } }