]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/utmp.c: Align generated "ut_id" with modern software
authorEvgeny Grin (Karlson2k) <k2k@drgrin.dev>
Wed, 16 Jul 2025 15:50:53 +0000 (17:50 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Fri, 18 Jul 2025 09:52:19 +0000 (11:52 +0200)
commit59c5acb5dee310c3909a348a557224119f7d345f
tree74ec5e211c7c7896cedf9f36f86e15058376d8f4
parent4f476f98d940aa00e803515f1cf8b24ee861a7f5
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>
lib/utmp.c