-
Bug
-
Resolution: Unresolved
-
Normal
-
rhel-8.10, rhel-9.4
-
None
-
util-linux-2.37.4-21.el9
-
No
-
Moderate
-
rhel-sst-cs-plumbers
-
ssg_core_services
-
26
-
2
-
False
-
-
None
-
Red Hat Enterprise Linux
-
None
-
Pass
-
None
-
None
What were you trying to do that didn't work?
When using last -F -s with "%Y%m%d%H%M%S" format, the command returns more entries than planned, because parse_timestamp has a bug, it resets the seconds ("%S") to 00, which causes entries before the timestamp to be returned, as shown in the example below:
# last -F | head root pts/0 192.168.122.1 Wed Aug 28 12:18:02 2024 still logged in root pts/2 192.168.122.1 Wed Aug 28 10:29:57 2024 - Wed Aug 28 11:48:39 2024 (01:18) root pts/1 192.168.122.1 Wed Aug 28 10:29:37 2024 - Wed Aug 28 10:34:56 2024 (00:05) root pts/0 192.168.122.1 Wed Aug 28 09:12:16 2024 - Wed Aug 28 11:32:19 2024 (02:20) reboot system boot 5.14.0-427.28.1. Wed Aug 28 09:11:47 2024 still running [...] # last -F -s "20240828102958" root pts/0 192.168.122.1 Wed Aug 28 12:18:02 2024 still logged in root pts/2 192.168.122.1 Wed Aug 28 10:29:57 2024 - Wed Aug 28 11:48:39 2024 (01:18) ---->> WRONG root pts/1 192.168.122.1 Wed Aug 28 10:29:37 2024 - Wed Aug 28 10:34:56 2024 (00:05) ---->> WRONG # last -F -s "2024-08-28 10:29:58" root pts/0 192.168.122.1 Wed Aug 28 12:18:02 2024 still logged in --> OK
Due to the bug, "20240828102958" is parsed as if it was "20240828102900", with seconds reset, as seen on line 324 of the source code:
150 int parse_timestamp(const char *t, usec_t *usec) 151 { : 322 k = strptime(t, "%Y%m%d%H%M%S", &tm); 323 if (k && *k == 0) { 324 tm.tm_sec = 0; 325 goto finish; 326 }
My guess this code is a bad copy/paste from the previous code dealing with "%H:%M" format:
315 k = strptime(t, "%H:%M", &tm); 316 if (k && *k == 0) { 317 tm.tm_sec = 0; 318 goto finish; 319 }
Please provide the package NVR for which bug is seen:
util-linux-2.37.4-18.el9.x86_64
util-linux-2.32.1-46.el8.x86_64
How reproducible:
Always
Steps to reproduce
See above
Expected results
root pts/0 192.168.122.1 Wed Aug 28 12:18:02 2024 still logged in
Actual results
root pts/0 192.168.122.1 Wed Aug 28 12:18:02 2024 still logged in root pts/2 192.168.122.1 Wed Aug 28 10:29:57 2024 - Wed Aug 28 11:48:39 2024 (01:18) root pts/1 192.168.122.1 Wed Aug 28 10:29:37 2024 - Wed Aug 28 10:34:56 2024 (00:05)