Skip to content

tests/utmpx: check logind timestamps and leader PIDs - #16231

Open
mattsu2020 wants to merge 6 commits into
uutils:mainfrom
mattsu2020:users-zbus
Open

mattsu2020 wants to merge 6 commits into
uutils:mainfrom
mattsu2020:users-zbus

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Check the login time in who -u and pinky, and the session leader PID in who -u. Verify that each field displays ? when sd-login cannot supply its value.

Depends on #11579.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.61 MB (+224 KB, +0.14%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@mattsu2020

Copy link
Copy Markdown
Contributor Author

Personally, I prefer the zbus-based approach because I find it allows for cleaner code.

@mattsu2020 mattsu2020 changed the title utmpx: use zbus for Linux logind fallback utmpx: query missing logind session details with zbus Nov 7, 2026
Comment thread docs/src/wasi-test-gaps.md Resolved
# * cargo
cdylib
doctest
libloading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You no nonger dlopen.

@mattsu2020 mattsu2020 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because the spell checker reported an error.

@codspeed

codspeed Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 3 benchmarks

2 warnings, 1 note

⚠️ 118 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

⚠️ 5 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 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

⚡ 2 improved benchmarks
❌ 3 regressed benchmarks
✅ 408 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation socket_addrs_direct[100000] 105.3 µs 132.9 µs -20.78%
❌ Memory cp_recursive_deep_tree[(120, 4)] 670.5 KB 788.5 KB -14.97%
❌ CPU Simulation hostname_ip_lookup[100000] 544 µs 573.6 µs -5.16%
⚡ Memory socket_addrs_direct[100000] 68 KB 8.6 KB ×7.9
⚡ Memory hostname_ip_lookup[100000] 159.7 KB 100.3 KB +59.19%

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-zbus (66dc25c) with main (dded1b5)

Open in CodSpeed

Footnotes

  1. 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. ↩

Comment thread tests/fixtures/who/logind_redirect.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use binaries provided by systemd itself at our test and remove unsafe dlopen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running some basic tests, but it looks like we can remove it.

@mattsu2020
mattsu2020 force-pushed the users-zbus branch 3 times, most recently from e3aedcd to 699d00d Compare November 7, 2026 10:18
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu 22.04 tests the D-Bus fallback used by older systemd versions.
Ubuntu 24.04 tests direct access through newer sd-login APIs.
Both are needed to cover these different code paths.
If testing just one of them is sufficient, I'll consolidate them into one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu-22.04 runner image is deprecated and will be retired in April 2027, how can we test it then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu's LTS support period is relatively short. How about using Debian instead? I think that could work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub does not provide it. Do we really need to care about legacy API?
We should support what user want to do at 1st.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to run CI/CD tests only on the latest version and remove the Ubuntu 22.04 image.

Since we already have unit tests in place, I believe this should be sufficient.

Comment thread deny.toml Resolved
@mattsu2020 mattsu2020 mentioned this pull request Nov 7, 2026
@mattsu2020
mattsu2020 force-pushed the users-zbus branch 3 times, most recently from e0739b0 to fbd195c Compare November 10, 2026 06:35
@mattsu2020
mattsu2020 marked this pull request as ready for review November 17, 2026 06:35
@sylvestre

Copy link
Copy Markdown
Contributor

thanks for the patch!
The zbus part makes who and pinky 58% bigger, just for systemd < 254. See the comment on bus.rs.
Please also wait until #11579 and #16255 land, rebase on them, and squash everything into one commit.

Comment thread tests/by-util/test_split.rs Resolved
@mattsu2020
mattsu2020 marked this pull request as draft November 18, 2026 13:01
@mattsu2020 mattsu2020 changed the title utmpx: query missing logind session details with zbus tests/utmpx: check logind timestamps and leader PIDs Nov 18, 2026
@mattsu2020
mattsu2020 marked this pull request as ready for review November 21, 2026 04:49
Open and validate a nonblocking descriptor, then select it for libc via
/proc/self/fd. Keep getutxent for record reads and locking.

Cover FIFO rejection, path replacement, invalid inputs and cleanup.
Keep the selected file across iterators and share one lock-wait budget across records. Cover path persistence, lock contention, and cleanup.
Cover both standard and daylight saving time in who output.
Keep display suffixes on host names and distinguish them from IPv6 colons.
Prefer traditional records for a populated default utmp and for explicit paths. Query session timestamps and leader PIDs when needed, and display question marks when logind cannot provide them.
Compare who and pinky fields against loginctl on Ubuntu 22.04 and 24.04, including question marks when sd-login cannot supply the metadata.
Comment thread src/uu/uptime/Cargo.toml
systemd_logind = ["uucore/systemd_logind"]
uucore = { workspace = true, features = [
"libc",
"utmpx",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

Comment thread src/uu/pinky/Cargo.toml

[features]
systemd_logind = ["uucore/systemd_logind"]
uucore = { workspace = true, features = ["utmpx", "systemd-logind", "entries"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

Comment thread src/uu/users/Cargo.toml

[target.'cfg(any(target_vendor = "apple", target_os = "cygwin", target_os = "freebsd", target_os = "linux", target_os = "netbsd"))'.dependencies]
uucore = { workspace = true, features = ["utmpx"] }
uucore = { workspace = true, features = ["utmpx", "systemd-logind"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

Comment thread src/uu/who/Cargo.toml

[features]
systemd_logind = ["uucore/systemd_logind"]
uucore = { workspace = true, features = ["utmpx", "systemd-logind"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

Comment thread src/uucore/Cargo.toml
update-control = ["parser"]
utf8 = []
utmpx = ["time", "time/macros", "libc", "dns-lookup"]
systemd-logind = ["utmpx", "dep:libloading"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

Comment thread Cargo.toml
# "test_risky_names" == enable tests that create problematic file names (would make a network share inaccessible to Windows, breaks SVN on Mac OS, etc.)
test_risky_names = []
# Linux logind integration tests.
test_logind = ["who", "pinky", "users", "uptime"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize please

@xtqqczze

Copy link
Copy Markdown
Collaborator

does each commit stand alone, or should they be squashed?

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.

4 participants