Skip to content

Commit bf4d3b2

Browse files
12paperbluca
authored andcommitted
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 8254755) (cherry picked from commit c89c5d0) (cherry picked from commit 80efb1d) (cherry picked from commit 94b234d)
1 parent e0b8d73 commit bf4d3b2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/login/logind-session.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,10 +1268,20 @@ SessionState session_get_state(Session *s) {
12681268
int session_kill(Session *s, KillWho who, int signo) {
12691269
assert(s);
12701270

1271-
if (!s->scope)
1272-
return -ESRCH;
1271+
switch (who) {
1272+
1273+
case KILL_ALL:
1274+
if (!s->scope)
1275+
return -ESRCH;
1276+
1277+
return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL);
12731278

1274-
return manager_kill_unit(s->manager, s->scope, who, signo, NULL);
1279+
case KILL_LEADER:
1280+
return RET_NERRNO(kill(s->leader, signo));
1281+
1282+
default:
1283+
assert_not_reached();
1284+
}
12751285
}
12761286

12771287
static int session_open_vt(Session *s) {

0 commit comments

Comments
 (0)