login: log session state "closing" (as well as New/Removed)
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Fri, 1 Jun 2018 18:03:21 +0000 (19:03 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 4 Jun 2018 09:31:11 +0000 (11:31 +0200)
commit8150acb16090e5213eea68679eb5aaba868cb570
tree31c22f1850e947ccd12a8343c16f2dd5596d13e0
parent2a13fafd894013e14d0e1febbcb8c56f519e0db7
login: log session state "closing" (as well as New/Removed)

Let's show a message at the time of logout i.e. entering the "closing"
state, not just e.g. once the user closes `tmux` and the session can be
removed completely.  (At least when KillUserProcesses=no applies.  My
thinking was we can spare the log noise if we're killing the processes
anyway).

These are two independent events.  I think the logout event is quite
significant in the session lifecycle.  It will be easier for a user who
does not know logind details to understand why "Removed session" doesn't
appear at logout time, if we have a specific message we can show at this
time :).

Tested using tmux and KillUserProcesses=no.  I can also confirm the extra
message doesn't show when using KillUserProcesses=yes.  Maybe it looks a
bit mysterious when you use KillOnlyUsers= / KillExcludeUsers=, but
hopefully not alarmingly so.

I was looking at systemd-logind messages on my system, because I can
reproduce two separate problems with Gnome on Fedora 28 where
sessions are unexpectedly in state "closing".  (One where a GUI session
limps along in a degraded state[1], and another where spice-vdagent is left
alive after logout, keeping the session around[2]).  It logged when
sessions were created and removed, but it didn't log when the session
entered the "closing" state.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1583240#c1
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1583261

Closes #9096
src/login/logind-session.c