]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Revert "lib/, src/: Use local time for human-readable dates"
authorAlejandro Colomar <alx@kernel.org>
Fri, 14 Feb 2025 20:25:01 +0000 (21:25 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 25 Feb 2025 09:09:47 +0000 (10:09 +0100)
This reverts commit 3f5b4b56268269fefed55aa106f382037297d663.

The dates are stored as UTC, and are stored as a number of days since
Epoch.  We don't have enough precision to translate it into local time.
Using local time has caused endless issues in users.

This patch is not enough for fixing this issue completely, since
printing a date without time-zone information means that the date is a
local date, but what we're printing is a UTC date.  A future patch
should add time-zone information to the date.

For now, let's revert this change that has caused so many issues.

Fixes: 3f5b4b562682 (2024-08-01; "lib/, src/: Use local time for human-readable dates")
Link: <https://github.com/ansible/ansible/blob/devel/test/integration/targets/user/tasks/test_expires.yml#L2-L20>
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095430>
Link: <https://lists.iana.org/hyperkitty/list/tz@iana.org/message/ENE5IFV3GAH6WK22UJ6YU57D6TQINSP5/>
Link: <https://github.com/shadow-maint/shadow/issues/1202>
Link: <https://github.com/shadow-maint/shadow/issues/1057>
Link: <https://github.com/shadow-maint/shadow/issues/939>
Link: <https://github.com/shadow-maint/shadow/pull/1058>
Link: <https://github.com/shadow-maint/shadow/pull/1059#issuecomment-2309888519>
Link: <https://github.com/shadow-maint/shadow/pull/952>
Link: <https://github.com/shadow-maint/shadow/pull/942>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Gus Kenion <https://github.com/kenion>
Reported-by: Alejandro Colomar <alx@kernel.org>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Reported-by: Lee Garrett <lgarrett@rocketjump.eu>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Tim Parenti <tim@timtimeonline.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/time/day_to_str.h
src/chage.c

index b70e98975db006cb381480de150747edb10bdef3..fe3308d8cc5aad75a1ac93debc95231585cc4538 100644 (file)
@@ -38,7 +38,7 @@ day_to_str(size_t size, char buf[size], long day)
                return;
        }
 
-       if (localtime_r(&date, &tm) == NULL) {
+       if (gmtime_r(&date, &tm) == NULL) {
                strtcpy(buf, "future", size);
                return;
        }
index aed8e5b6fd5835f72c72bb59442acf0338b6952c..e2902a712076dd5aab1a356b143e7e894bcdeaa6 100644 (file)
@@ -238,7 +238,7 @@ print_day_as_date(long day)
                return;
        }
 
-       if (localtime_r(&date, &tm) == NULL) {
+       if (gmtime_r(&date, &tm) == NULL) {
                puts(_("future"));
                return;
        }