Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just did some evaluating of pyinfra recently, and noticed that the lastlog information when using the server.Users fact was empty on my Ubuntu and RHEL servers.
Going through the logic, it seems that due to a change introduced in #1015, the functionality for non-FreeBSD based systems broke.
I changed the LASTLOG and LASTLOG_RAW to be a oneliner that should preserve the functionality introduced in the aforementioned PR, and also fixes the issue (at least on the systems I have tested).
I have tested this on:
16.04.3 LTS (Xenial Xerus)
18.04.6 LTS (Bionic Beaver)
20.04.6 LTS (Focal Fossa)
22.04.4 LTS (Jammy Jellyfish)
24.04.1 LTS (Noble Numbat)
Red Hat Enterprise Linux 8.9 (Ootpa)
Red Hat Enterprise Linux 9.5 (Plow)
Before the change, all systems returned:
"lastlog": null,
"login_time": null,
And after the change, they return values as expected:
"lastlog": "Tue Dec 3 09:28:02 +0000 2024",
"login_time": "2024-12-03T09:28:02+00:00",
I also did a quick test on FreeBSD 14.1, and everything seemed to work as expected there also after the change.
The issue is related to the header that is shown when using lastlog:
And after the change it shows this: