logind: always use 64bit session IDs
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.
This commit is contained in:
committed by
Luca Boccassi
parent
08b61b40ed
commit
973527648b
@@ -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));
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user