]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: always use 64bit session IDs
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Apr 2023 10:02:32 +0000 (12:02 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 25 Apr 2023 14:52:19 +0000 (15:52 +0100)
it's a bit confusing that on 32bit systems we'd risk session IDs
overruns like this. Let's expose the same behaviour everywhere and stick
to 64bit ids.

Since we format the ids as strings anyway this doesn't really change
anything performance-wise, it just pushes out collisions by overrun to
basically never happen.

src/login/logind-dbus.c
src/login/logind.h

index 1c151021c7904f8a0f71e87bdd26241e379d100f..c5e0fda5e5d74ee3785ff2a57a9b4a93a84d9ac7 100644 (file)
@@ -867,7 +867,7 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
                 do {
                         id = mfree(id);
 
-                        if (asprintf(&id, "c%lu", ++m->session_counter) < 0)
+                        if (asprintf(&id, "c%" PRIu64, ++m->session_counter) < 0)
                                 return -ENOMEM;
 
                 } while (hashmap_contains(m->sessions, id));
@@ -3274,7 +3274,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
         do {
                 id = mfree(id);
 
-                if (asprintf(&id, "%lu", ++m->inhibit_counter) < 0)
+                if (asprintf(&id, "%" PRIu64, ++m->inhibit_counter) < 0)
                         return -ENOMEM;
 
         } while (hashmap_get(m->inhibitors, id));
index d0b1f9671e0538071780d041931fc1b7875af415..e6a04e0834150006f9dde5eb0c0aa5e539559928 100644 (file)
@@ -59,8 +59,8 @@ struct Manager {
         char **kill_only_users, **kill_exclude_users;
         bool kill_user_processes;
 
-        unsigned long session_counter;
-        unsigned long inhibit_counter;
+        uint64_t session_counter;
+        uint64_t inhibit_counter;
 
         Hashmap *session_units;
         Hashmap *user_units;