mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +03:00
logind: when generating session ids with a counter, retry if session is already allocated
This commit is contained in:
parent
1713813de3
commit
0771475394
@ -176,7 +176,7 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
|
||||
Seat *s;
|
||||
DBusMessageIter iter;
|
||||
int r;
|
||||
char *id, *p;
|
||||
char *id = NULL, *p;
|
||||
int vtnr = -1;
|
||||
int pipe_fds[2] = { -1, -1 };
|
||||
DBusMessage *reply = NULL;
|
||||
@ -306,10 +306,8 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
|
||||
|
||||
audit_session_from_pid(leader, &audit_id);
|
||||
|
||||
if (audit_id > 0)
|
||||
if (audit_id > 0) {
|
||||
asprintf(&id, "%lu", (unsigned long) audit_id);
|
||||
else
|
||||
asprintf(&id, "c%lu", ++m->session_counter);
|
||||
|
||||
if (!id) {
|
||||
r = -ENOMEM;
|
||||
@ -321,6 +319,19 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
|
||||
goto fail;
|
||||
}
|
||||
|
||||
} else {
|
||||
do {
|
||||
free(id);
|
||||
asprintf(&id, "c%lu", ++m->session_counter);
|
||||
|
||||
if (!id) {
|
||||
r = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
} while (hashmap_get(m->sessions, id));
|
||||
}
|
||||
|
||||
r = manager_add_session(m, user, id, &session);
|
||||
free(id);
|
||||
if (r < 0)
|
||||
|
@ -40,6 +40,7 @@
|
||||
* subscribe to fd HUP
|
||||
* D-Bus method: AttachDevice(seat, device);
|
||||
* D-Bus method: PermitLinger(user, bool b);
|
||||
* properly handle if two sessions with the same loginuid are attempted to be created
|
||||
*
|
||||
* non-local X11 server
|
||||
* reboot/shutdown halt management
|
||||
|
Loading…
Reference in New Issue
Block a user