s6-linux-init
Software
skarnet.org

The s6-linux-init-logouthookd program

s6-linux-init-logouthookd cleans up its client's utmp record when it dies.

Interface

     s6-ipcserver socket s6-linux-init-logouthookd

s6-linux-init-logouthookd implements a local service for getty programs that add a utmp record when a user logs in.

In the sysvinit model, getty/login and similar programs add a utmp record for every user that logs in, then exec into the user's shell. At logout time, the shell dies; sysvinit is supervising the getty program, so it's watching the pid, and respawns the getty when the shell dies. But before respawning the getty, it cleans up the utmp record, to correctly report that the user isn't logged in on this terminal anymore.

utmp is an old, clunky, insecure system (unless you're using utmps) and it is definitely not pid 1's job to have any knowledge of utmp and play janitor after getty. s6-svscan will definitely not do it.

Some distributions use versions of login that fork the user's shell instead of execing it. When the user logs out, the login program cleans up after itself. This is a better model, but it's not always easy to patch login to go from an "exec the shell" model to a "fork the shell as a child" model.

s6-linux-init comes with a small library which makes it easy for a distribution to fully support utmp cleanup with an s6 init system if they so choose. Before execing into the user's shell, the login program should just make a call to s6_linux_init_logouthook(), and that's it. That function will call the s6-linux-init-logouthookd local service, which will do nothing but wait until the user's shell dies; and when it happens, the user's utmp record will automatically be cleaned up.

Exit codes

s6-linux-init-logouthookd's exit code does not matter, because no program uses it. However, here's the list for completeness:

Notes