1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +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.

(cherry picked from commit 8254755091847105c33e473c62cdc7621ed275bc)
This commit is contained in:
12paper 2024-11-10 03:13:39 +01:00 committed by Luca Boccassi
parent 688eb20fdb
commit c89c5d04f3

View File

@ -1384,10 +1384,20 @@ SessionState session_get_state(Session *s) {
int session_kill(Session *s, KillWho who, int signo) {
assert(s);
if (!s->scope)
return -ESRCH;
switch (who) {
return manager_kill_unit(s->manager, s->scope, who, 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) {