]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: always check current tag list before using a device
authorLennart Poettering <lennart@poettering.net>
Thu, 13 Dec 2018 17:36:57 +0000 (18:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Sep 2020 15:40:13 +0000 (17:40 +0200)
src/login/logind-core.c
src/login/logind-dbus.c
src/login/sysfs-show.c

index e0d61f3e7527ee3ae134498c2eec9a21b03d8f6c..048718222517cc58929c15c950275a40f2d35e9b 100644 (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)
index d883288b254e394de66fe4e80e72c4ecdd298fd4..bbec23c850ab01e7d3c871c6c5f4475bbc35ff33 100644 (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)
index a66be28ad96fb46d72c2b19aab45e0ca05b46045..9b7fc203967c297c5cb88f9fea0ffe03e50233e7 100644 (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;
                         }
                 }