From: 12paper <104864644+12paper@users.noreply.github.com> Date: Sun, 10 Nov 2024 02:13:39 +0000 (+0100) Subject: login: fix session_kill(..., KILL_LEADER,...) (#35105) X-Git-Tag: v256.8~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c89c5d04f33dbc5c6dfb67b8bc58cbd3d924b434;p=thirdparty%2Fsystemd.git login: fix session_kill(..., KILL_LEADER,...) (#35105) `loginctl kill-session --kill-whom=leader ` (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) --- diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 4758cb9ff1b..5f4c13652f5 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -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) { + + case KILL_ALL: + if (!s->scope) + return -ESRCH; + + return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL); - return manager_kill_unit(s->manager, s->scope, who, signo, NULL); + case KILL_LEADER: + return pidref_kill(&s->leader, signo); + + default: + assert_not_reached(); + } } static int session_open_vt(Session *s, bool reopen) {