wolfcw / libfaketime

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

Compiling with INTERCEPT_SYSCALL, can only specify time with FAKETIME, not with FAKETIME_TIMESTAMP_FILE #450

Closed RCoeurjoly closed 6 months ago

RCoeurjoly commented 6 months ago

I have compiled libfaketime with INTERCEPT_SYSCALL.

The following execution works. LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="2020-12-24 20:30:00" .test_faketime

The code is:

`#include

include

int main() { const auto today = std::chrono::system_clock::now(); const time_t tt = std::chrono::system_clock::to_time_t( today ); std::cout << "now: " << ctime(&tt) << std::endl; return 0; }`

The following execution does not work. LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME_TIMESTAMP_FILE=my-faketime.rc FAKETIME_NO_CACHE=1 .test_faketime where my-faketime.rc is: 2020-12-24 20:30:00

The code is the same as in the previous execution.

I find this weird, because getting the time with boost, which does not use a syscall, works in both cases.

wolfcw commented 6 months ago

thank you for spotting and fixing this =)