Skip to content

utmpx: fall back to systemd-logind on Linux when traditional utmp is empty/unavailable - #11579

Open
mattsu2020 wants to merge 1 commit into
uutils:mainfrom
mattsu2020:users
Open

mattsu2020 wants to merge 1 commit into
uutils:mainfrom
mattsu2020:users

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

On Linux systems with a missing or empty default utmp file, login records can be unavailable to users, who, pinky, and uptime. Try systemd-logind in that case, loading libsystemd at runtime and falling back to traditional utmp if it is unavailable. This replaces the opt-in feature.

Read the boot time from /proc/stat instead of the systemd random-seed timestamp.

Related to #3219.

@oech3

This comment was marked as resolved.

@mattsu2020

mattsu2020 commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Is this dynamically linked againsyt libsystemd.so? If so, this should be disabled by default.

Change to fallback only

@mattsu2020 mattsu2020 changed the title feat: enable systemd-logind by default and add utmp fallback users: add utmp fallback Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Note: The gnu test tests/pr/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Congrats! The gnu test tests/tail/pipe-f is now passing!
Skip an intermittent issue tests/cut/bounded-memory (was skipped on 'main', now failing)

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tail/tail-n0f. tests/tail/tail-n0f is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

@github-actions

github-actions Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

@codspeed

codspeed Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.46%

⚠️ 126 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

❌ 2 regressed benchmarks
✅ 399 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation three_39_bit_primes 583.2 ms 617.8 ms -5.6%
❌ Simulation five_38_bit_primes 1.6 s 1.7 s -5.33%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mattsu2020:users (aa176f3) with main (6292c03)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@oech3

oech3 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Is there any way to achieve full feature without runtime strong libsystemd.so dependency?
I think libselinux.so is not serious, but this should be part of binaries published at here.
Just parsing systemd files manually?

@oech3

oech3 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Or can we believe soname compatibility of systemd and publish them?

@mattsu2020
mattsu2020 marked this pull request as draft June 27, 2026 05:04
@mattsu2020 mattsu2020 changed the title users: add utmp fallback users: dynamically load libsystemd with utmp fallback Jun 27, 2026
@mattsu2020

Copy link
Copy Markdown
Contributor Author

Is there any way to achieve full feature without runtime strong libsystemd.so dependency? I think libselinux.so is not serious, but this should be part of binaries published at here. Just parsing systemd files manually?

Since I changed it to dynamic load, I'll test to see if this works.

@oech3

oech3 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

And remove feat_systemd_logind if succeed.

@oech3

oech3 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

It seems pure Rust solution is possible: https://github.com/lucab/zbus_systemd (thought maintainer might not want to add such dep...)

@HackingRepo

Copy link
Copy Markdown
Contributor

nice, ok

@mattsu2020 mattsu2020 changed the title users: dynamically load libsystemd with utmp fallback utmpx: prefer systemd-logind on Linux with utmp fallback Jun 27, 2026
@mattsu2020 mattsu2020 changed the title utmpx: prefer systemd-logind on Linux with utmp fallback utmpx: fall back to systemd-logind on Linux when traditional utmp is empty/unavailable Jun 27, 2026
@mattsu2020
mattsu2020 marked this pull request as ready for review June 27, 2026 07:43
@mattsu2020

Copy link
Copy Markdown
Contributor Author

Code changes are mostly complete

@oech3

oech3 commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

An additional reason that we want to have this PR: #13212

@Ecordonnier

Copy link
Copy Markdown
Collaborator

It seems pure Rust solution is possible: https://github.com/lucab/zbus_systemd (thought maintainer might not want to add such dep...)

See #8376 (comment) where I explained why I did not use zbus in the implementation of systemd-logind. It is a huge crate.

@Ecordonnier

Copy link
Copy Markdown
Collaborator

Will it still be compatible with GNU coreutils behavior? how much is it deviating? the goal of the initial implementation of systemd-logind was to have the same behavior than GNU coreutils.

@oech3

oech3 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@Ecordonnier How about using zbus keeping feat_systemd_logind optional? Then people can keep binary size by removing it.

@mattsu2020

Copy link
Copy Markdown
Contributor Author

Will it still be compatible with GNU coreutils behavior? how much is it deviating? the goal of the initial implementation of systemd-logind was to have the same behavior than GNU coreutils.

Mostly, but not completely.

The systemd-derived records are intended to match GNU coreutils, including boot records and separate seat/TTY entries. However, there are still some known differences, such as session PID handling, remote user formatting, and TTY fallback behavior.

@Ecordonnier

Copy link
Copy Markdown
Collaborator

@Ecordonnier How about using zbus keeping feat_systemd_logind optional? Then people can keep binary size by removing it.

Using zbus would grow the binaries by 800KB. I don't think we want this.

@oech3

oech3 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

I think it is worth to inc multicall-binary 800KiB for simplicity and consistency of binaries published at here.

@oech3

oech3 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

@Ecordonnier Are you fine to merge this?

@xtqqczze

This comment was marked as resolved.

On Linux, try systemd-logind when the default utmp file is missing or
empty. Load libsystemd at runtime so systems without it can still use
traditional utmp, and remove the opt-in feature.

Read the boot time from /proc/stat instead of the random-seed timestamp.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants