wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.71k stars 324 forks source link

Faketime issue with date timezone conversion #461

Open kotsis opened 7 months ago

kotsis commented 7 months ago

Hello everyone, I got a weird case of Faketime affecting/interfering with a simple date conversion, which I wouldn't expect, since it is a simple date conversion of a specific timestamp. It also seems to only happen in RockyLinux8 distro.

e.g. in Centos7:

[root@vagrant vagrant]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@vagrant vagrant]# date -d @1396627200
Sat Apr  5 00:00:00 +08 2014

#utc date -08:00
[root@vagrant vagrant]# date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

#utf date -08:00 with faketime matches, all good
[root@vagrant vagrant]# LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

But in RockyLinux8 distro:

[root@vagrant vagrant]# cat /etc/centos-release
Rocky Linux release 8.9 (Green Obsidian)

[root@vagrant vagrant]# date -d @1396627200
Sat Apr  5 00:00:00 +08 2014

#utc date -08:00
[root@vagrant vagrant]# date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-04T16:00:00Z

#utf date -08:00 with faketime is wrong now!
[root@vagrant vagrant]# LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 date -u -d @1396627200 +%Y-%m-%dT%H:%M:00Z
2014-04-05T00:00:00Z

Not sure why this happens only in RockyLinux8 , last case.

PS: I use LD_PRELOAD for a bash script, which contains above date conversions, and the bug in RockyLinux8 boils down to above case.