logind: always check current tag list before using a device

This commit is contained in:
Lennart Poettering 2018-12-13 18:36:57 +01:00
parent fccb48b286
commit 643bb92408
3 changed files with 9 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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;
}
}