lib/utmp.c: Align generated "ut_id" with modern software
Modern software (systemd, utemper) usually use full "ut_line" as "ut_id"
if string is up to four chars or last four chars if "ut_line" is longer.
For reference:
* libutemper (used by many graphical terminal emulator applications
(konsole, xterm, others) to deal with utmp file):
https://github.com/altlinux/libutempter/blob/
4caa8ab94ff8b207228fa723a89214bf5e929321/libutempter/utempter.c#L99-L103
* systemd:
uses full name of the device:
https://github.com/systemd/systemd/blob/
8013beb4a2221680b2c741bac6b3a33fe66406e1/units/getty%40.service.in#L41-L44
or **last** four characters:
https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#UtmpIdentifier=
The code in the commit is optimised for visual C code size.
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Reviewed-by: Alejandro Colomar <alx@kernel.org>