-
Notifications
You must be signed in to change notification settings - Fork 254
lib/utmp.c: align generated "ut_id" with other software #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
If an entry is being written to utmp file, the file is first checked for entries with the same It was designed to work in the following way (simplified, see https://man7.org/linux/man-pages/man5/utmp.5.html):
I skipped extra details, like updates of This mechanism allows However, this description does not provide any requirements for graphical terminal emulators (like For graphical terminals the last four chars from The same is used for However, Modern implementations, like This PR changes nothing if an entry with |
|
To summarise the idea of this PR. This PR does correct behaviour in non-standard situations, for example, when |
|
The PR has been updated based on comments. |
233c65b to
0070316
Compare
|
Updated again |
|
Updated as requested |
|
Rebased, excluded merged commit. |
|
Updated exactly as suggested. |
alejandro-colomar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Please include those two links in the commit message, if you don't mind. |
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>
|
@alejandro-colomar Includes sorted, links added. |
|
Thanks! |
This PR aligns generated "ut_id" with ids produced by other modern software, like systemd and libutemper.
For reference:
Note: libutemper is used by many graphical terminal emulator applications (konsole, xterm, others) to deal with utmp file.
use full name of the device (see https://github.com/systemd/systemd/blob/8013beb4a2221680b2c741bac6b3a33fe66406e1/units/getty%40.service.in#L41-L44) or last four chars if name is longer then four chars (see https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#UtmpIdentifier=)
To summarise the idea of this PR.
This PR does not change functionality for normal workflow (when
utmpentry is created beforeloginis started).This PR does correct behaviour in non-standard situations, for example, when
loginis started asinitprocess, aligning choice ofut_idvalue with modern software (systemd, utemper).