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); 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; const char *syspath;
r = sd_device_get_syspath(d, &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); 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 */ /* Ignore non-master devices for unknown seats */
if (!master && !seat) if (!master && !seat)
@ -313,7 +314,8 @@ int manager_process_button_device(Manager *m, sd_device *d) {
if (r < 0) if (r < 0)
return r; 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); b = hashmap_get(m->buttons, sysname);
if (!b) if (!b)

View file

@ -1361,7 +1361,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
if (r < 0) if (r < 0)
return r; return r;
if (sd_device_has_tag(d, "seat") <= 0) if (sd_device_has_current_tag(d, "seat") <= 0)
return -ENODEV; return -ENODEV;
if (sd_device_get_property_value(d, "ID_FOR_SEAT", &id_for_seat) < 0) 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 */ /* Explicitly also check for tag 'seat' here */
if (!streq(seat, sn) || 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_subsystem(dev_list[*i_dev], &subsystem) < 0 ||
sd_device_get_sysname(dev_list[*i_dev], &sysname) < 0) { sd_device_get_sysname(dev_list[*i_dev], &sysname) < 0) {
(*i_dev)++; (*i_dev)++;
continue; 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) 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); (void) sd_device_get_sysattr_value(dev_list[*i_dev], "id", &name);
@ -80,7 +80,7 @@ static int show_sysfs_one(
isempty(lookahead_sn)) isempty(lookahead_sn))
lookahead_sn = "seat0"; 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; break;
} }
} }