utmpx: fall back to logind when default utmp is unavailable #11579
Is this dynamically linked againsyt libsystemd.so? If so, this should be disabled by default.
Is this dynamically linked againsyt libsystemd.so? If so, this should be disabled by default.
Change to fallback only
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.
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)
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.
<!-- gnu-comment-bot -->
GNU testsuite comparison:
Congrats! The gnu test tests/tail/follow-name is no longer failing!
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!
<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
Merging this PR will regress 2 benchmarks
<details>
<summary><b>1 warning, 1 note</b></summary>
:warning: 122 benchmarks are dominated by system calls
> System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
> Learn more about system calls
> See affected benchmarks
:information_source: 1 benchmark has no flamegraph
> The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
> See affected benchmarks
</details>
⚡ 1 improved benchmark ❌ 2 regressed benchmarks ✅ 410 untouched benchmarks ⏩ 70 skipped benchmarks[^skipped]
[!WARNING]
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes
| | Mode | Benchmark | BASE | HEAD | Efficiency |
| --- | ---- | --------- | ------ | ------ | ---------- |
| ❌ | CPU Simulation | ` dd_copy_4k_blocks | 2.6 ms | 2.7 ms | -3.08% |
| ❌ | CPU Simulation | dd_copy_with_skip | 4.8 ms | 4.9 ms | -3.03% |
| ⚡ | CPU Simulation | true_consecutive_calls | 350.2 ns | 294.7 ns | +18.85% |
[!TIP]
Investigate this regression by commenting @codspeedbot fix this regression` on this PR, or directly use the CodSpeed MCP with your agent.
---
<sub>Comparing <code>mattsu2020:users</code> (0dc65d8) with <code>main</code> (293a724)[^unexpected-base]</sub>
<a href="https://app.codspeed.io/uutils/coreutils/branches/mattsu2020%3Ausers?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>
[^skipped]: 70 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.
[^unexpected-base]: No successful run was found on <code>main</code> (91f89c4) during the generation of this report, so 293a724 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
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?
Is there any way to achieve full feature without runtime stronglibsystemd.sodependency? I thinklibselinux.sois 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.
And remove feat_systemd_logind if succeed.
It seems pure Rust solution is possible: https://github.com/lucab/zbus_systemd (thought maintainer might not want to add such dep...)
Code changes are mostly complete
An additional reason that we want to have this PR: https://github.com/uutils/coreutils/issues/13212
It seems pure Rust solution is possible: https://github.com/lucab/zbus_systemd (thought maintainer might not want to add such dep...)
See https://github.com/uutils/coreutils/issues/8376#issuecomment-3193829490 where I explained why I did not use zbus in the implementation of systemd-logind. It is a huge crate.
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.
@Ecordonnier How about using zbus keeping feat_systemd_logind optional? Then people can keep binary size by removing it.
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 How about usingzbuskeepingfeat_systemd_logindoptional? Then people can keep binary size by removing it.
Using zbus would grow the binaries by 800KB. I don't think we want this.
I think it is worth to inc multicall-binary 800KiB for simplicity and consistency of binaries published at here.
@Ecordonnier Are you fine to merge this?
@mattsu2020 drop the merge commit and then rebase, rewrite the commit description, remove GitHub issue link from the commit description, rewrite the PR description
Needed to rebase.
hi, this one can't be merged as it is:
src/uucore/src/lib/features/systemd_logind.rs: switching boot time from random-seed to /proc/stat changes who -b output, please split that into another prsrc/uucore/src/lib/features/utmpx.rs: 5 lines of comment to say no caller does it, please make it shorter (or drop it)src/uucore/src/lib/features/utmpx.rs: please make the doc shorter, the second paragraph can gosrc/uucore/src/lib/features/utmpx.rs: why always false on musl? please add a short commentsrc/uucore/src/lib/features/utmpx.rs: this generic exists only for the test, do we really need it?could you please have a look? otherwise, i will close it, thanks
Otherwise these utilities try libsystemd at runtime and return to the
traditional reader if loading or session enumeration fails.
<!-- size-comment-bot -->
Binary size comparison:
Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).
Total size of compared binaries: 155.61 MB (+232 KB, +0.15%)
Significant per-binary changes:
env 1.20 MB -> 1.28 MB (+80 KB, +6.51%)
I'm not sure if we should have many unsafes to avoid zbus adn maintain 1000+ lines. CodSpeed already says +336 KB at here.
Or we could simply statically link libsystemd.
https://github.com/mattsu2020/coreutils/tree/users-zbus
I tried implementing it using zbus, but it ended up increasing the binary size.
I think it is acceptible since libsystemd.so itself is large enough. We increased binary size when we dropped oniguruma. But it is not a real disadvantage.
I think it is acceptible sincelibsystemd.soitself is large enough. We increased binary size when we droppedoniguruma. But it is not a real disadvantage.
I've reworked the PR to use zbus, as I determined that the increase in binary size is not significant enough to be a concern.
why do we reimplement getutxent() with our own fcntl locking on linux?
this is a lot of new code unrelated to the logind fallback, please split it into another pr
this error is thrown away by read_logind(options).ok() in utmpx.rs, so nobody will see it
do we need the translation, the two ftl entries and the test in locale.rs?
do we really need ReadOptions? asking logind for the start time and the leader is cheap, and every caller would get simpler
please avoid the #[allow(...)]
please don't add a test-only field to the iterator
who needs this? nothing in the tree calls getutxent() on linux anymore
could you please move these tests into their own file, like systemd_logind/tests.rs?
thanks for the patch!
The main blocker is the new Linux utmp reader, the one that replaces getutxent(): please split it into another PR (details inline).
Please also rebase so only your commits are left, and squash them into a single commit.
fixed it
fixed it
fixed it
fixed it
Moved the tests into utmpx/tests.rs.
fixed it
Removed ReadOptions.
oech3
mattsu2020
When Linux's default utmp has no complete record, try logind for who, users, pinky and uptime. Keep populated traditional files first.
Related to #3219 and #8376; zbus support follows in #16231.