Skip to content

a library that adds a filter to time() function calls

License

Notifications You must be signed in to change notification settings

burghardt/libfaketime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libFakeTime

LibFakeTime - a library that adds a filter to time() function calls

Description

Dynamically linked programs that check the time using the time() or gettimeofday() functions would report fake time to make it possible to send an e-mail to a friend with the date of his birthday after this date has already passed if one forgot.

You can also use it to warp time in xclock or to test programs dealing with expiration dates (i.e., shareware programs work forever, SSL certificates never expire, and debugged programs start each time with the same time settings).

For more information about library usage, refer to the manual (libfaketime.8).

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Downloading

Simply clone repository.

git clone https://github.com/burghardt/libfaketime.git

Building from sources

Build sources with make to create binary libfaketime.so.1.

make

Build architecture

CFLAGS and LDFLAGS allow building for foreign architecture on multilib systems (i.e. 32-bit library on 64-bit userland).

env CFLAGS=-m32 LDFLAGS=-m32 make

Build options

LibFakeTime library has two optional build-time configuration options (see Makefile).

  • -DDEBUG (optional) This enables verbose debug code. Not very useful for regular usage, but it might be helpful for troubleshooting.

  • -DKILLER (optional) This enables the killer code. If the library cannot read fake time from the file, it will kill the process. Helpful with programs writing timestamps or invalidating something after the expiration date.

Warning: -DKILLER option can kill your /sbin/init early during boot process rendering system unable to boot if enabled system-wide!

Installing

Run make install (as root) to install binary library and manual page.

sudo make install

The Makefile install target will only copy the library and man page to the appropriate directories. To activate libfaketime, either on a per-process basis or a system-wide basis, see the section "Installing libfaketime" on the manual page.

Usage

Configure fake timestamp, preload library and run target program.

mkdir -p  ~/.libfaketime.d
date -d 20200101 +%s > ~/.libfaketime.d/date.fake
env LD_PRELOAD=libfaketime.so.1 date -R # prints "Wed, 01 Jan 2020  00:00:00 +0100"

Acknowledgments

I used some code from:

Footnote

See http://github.com/burghardt/libfaketime for more information and new releases. Send comments and bug reports to krzysztof@burghardt.pl.

About

a library that adds a filter to time() function calls

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published