sessreg
More info
- Creator
- Keith Packard, MIT X Consortium
- Type
- utmp/wtmp utility
- License
- MIT
- Source
- gitlab.freedesktop.org
The small program that records an X login in utmp and wtmp so that who and last can see it — because xdm, unlike getty and login, does not do it itself.
Unix keeps track of who is logged in through utmp, which login writes, and the history in wtmp, which last reads. An X session through XDM bypasses login entirely, so without help it does not show up at all. Keith Packard wrote sessreg at the MIT X Consortium to plug the hole: xdm's Xstartup runs sessreg -a -l $DISPLAY $USER when the session begins and Xreset runs sessreg -d when it ends, and the user gets a line where the terminal column is not a tty but :0. That the column is called "line" is a legacy of serial lines, and the original flags give away the age: -x Xservers and -s existed to work out which slot in the utmp file the display should get, back when the file was indexed per terminal. Today's version uses POSIX pututxline and accepts the flags without doing anything with them.
GDM, LightDM and SDDM write their own utmp entries, so sessreg is in practice the tool of xdm and hand-rolled startx setups; some distributions put it in the Xsession scripts so a login from the console gets registered too. It has mattered less as systemd-logind grew its own bookkeeping of sessions, and the utmp format's 32-bit timestamp hits the wall in 2038, so glibc and systemd have begun phasing it out. It will take a while regardless: who is the first thing many people type on an unfamiliar machine, and the answer with :0 where a tty should be is precisely the bookkeeping sessreg was introduced for.