1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

login: fix session_kill(..., KILL_LEADER,...) (#35105)

`loginctl kill-session --kill-whom=leader <N>` (or the D-Bus equivalent)
doesn't work because logind ends up calling `KillUnit(..., "main", ...)`
on a scope unit and these don't have a `MainPID` property. Here, I just
make it send a signal to the `Leader` directly.
This commit is contained in:
12paper 2024-11-10 03:13:39 +01:00 committed by GitHub
parent 053452e22b
commit 8254755091
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1390,10 +1390,20 @@ SessionState session_get_state(Session *s) {
int session_kill(Session *s, KillWhom whom, int signo) {
assert(s);
if (!s->scope)
return -ESRCH;
switch (whom) {
return manager_kill_unit(s->manager, s->scope, whom, signo, NULL);
case KILL_ALL:
if (!s->scope)
return -ESRCH;
return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL);
case KILL_LEADER:
return pidref_kill(&s->leader, signo);
default:
assert_not_reached();
}
}
static int session_open_vt(Session *s, bool reopen) {