Timeshift ========= From time to time it is useful to test an existing binary program with an altered system clock, without changing the clock and messing up the rest of the machine. Timeshift is a small shared object which can be used to accomplish this via the /etc/ld.so.preload or LD_PRELOAD mechanism. Installation ------------ Type make. Type make test. Verify that it's behaving sensibly. Put timeshift.so somewhere. Tested only on Linux -- sorry. Use --- LD_PRELOAD=/path/to/timeshift.so TIMESHIFT=start:end /path/to/program (Note that the linker ignores LD_PRELOAD for setuid programs. Instead, you can use the /etc/ld.so.preload mechanism. If you do this, be careful: the setting applies to the whole system, and if you make a mistake, you could be unable to run any dynamically linked program. Keeping a statically-linked shell running is a wise precaution.) The two colon-separated elements of TIMESHIFT should be epoch time expressed in decimal. You can convert human-readable to epoch time using GNU date(1): date +%s -d 'yyyy-mm-dd hh:mm:ss' The time reported to the program will wrap around inside the window from start to end, advancing by one second per real second. The formula used is reported_time = start + ((real_time - start) % (end - start)) Note that this means the time will sometimes go backwards. You can alter the function shift() in timeshift.c to implement a more sophisticated behaviour. -- Chris Lightfoot http://ex-parrot.com/~chris/ http://ex-parrot.com/~chris/software.html#timeshift Redistribute freely. $Id: README,v 1.4 2003/05/21 11:47:52 chris Exp $