
timewarp v0.1, (c) Jeremy D. Impson <jdimpson@acm.org>, 1998

This software is covered by the GNU Public Licence.  See the file COPYING
for details. 

Read the file INSTALL to find out how to install timewarp

WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!  

This is alpha software.  It does a lot of kernel memory allocation and
deallocation.  I am confident that there are no memory leaks, but even I
would not run this on anything other than a workstation that can be
rebooted once in a while in the event that there are memory leaks.

Desription: 

timewarp allows you to fool a process into thinking that the current time
is something other than it really is.  This allows you to continue running
binary software that has 'expired' without having to change the time of
the entire system. 

timewarp is a loadable module (timewarp.o) that creates a /proc entry
(called /proc/warp) and that allows a user to specify a "warp" value on a
per-program basis.  The warp value is in seconds.  Whenever a program asks
the kernel for the system time, this module intercepts the system call and
checks to see if the program making the system call has a warp value.  If
it does, timewarp takes the current time and subtracts the warp value from
it, returning the resultant value as the "warped" time. 

Usage: 

To add an entry, do something like this: 
	echo 'date  31536000' > /proc/warp

(the number of spaces is irrelavant as long as it is at least 1.  And tabs
are OK, too.  This particular value turns the time back about 1 year.) 

To view your entries, do this:
	cat /proc/warp

The output should look like this:

date	31536000

Note that each user can see only his or her own entries.  A superuser,
however, can see all entries, and would see this

date    31536000	501

where 501 is the userid of the user that created the entry.  Note that one
user's entry will not effect another's.  That is, if user 501 makes an
entry for 'date', user 502 will still get the correct, unwarped time when
executing date.  User 501 will get the warped system time. 

To change the warp value for an entry, do this: 

	echo 'date    63072000' > /proc/stay

that is, just add the entry as you did earlier, but with a different warp
value. 

To delete an entry, do this:
        echo 'date' > /proc/warp

Superuser can see all entries, but it cannot add or delete entries for
other users.  (At least, not directly.  If you are superuser, use 'su'.) 

Caveats (i.e. bugs :): 

Negative warp values (to set into the future) are currently unsupported. 
(But they would be easy to implement.) 

The warp values are stored in signed integers, so no values should be
larger than 2147483647.  This is my fault.  They should be time_t's (for
portability).  This will be fixed Real Soon Now. 

In order to keep the write() code simple, all entries written to
/proc/warp _MUST_ be done in a single write() system call.  You can
usually rely on 'echo' to do this.  Most printf() statements will work, as
they are line buffered.  If you are getting odd results, it may be that
whatever you are using to write to /proc/warp is breaking your entry into
multiple writes. 

timewarp first determines what uid the requesting process is running as
before doing any process name/entry command comparisons.  Right now, it
only looks at the real uid, not the euid, so suid programs fall under the
entries for the uid that executed them, not the uid that owns the suid
program.  This too is my fault, and will change. 

Performance: 

The data structures are seperated in the following manner.  Each user that
makes at least one entry to /proc/warp has it's own list of program
name/warp value pairs.  This list isn't sorted, so must be searched
linearly.  Also, timewarp must search it's list of uid lists, also
linearly.  I don't forsee using timewarp on a large scale, so I have
little impetus to rewrite the list routines to scale better.  If anyone
cares to send me patches that sorts the lists, feel free! 

Architecture note: 

This code has only been tried on x86 (ia32).  If any other port does not
implement a time() system call (but does it as a userspace library call
based on gettimeofday), then timewarp may just bring your system crashing
when loaded (hopefully, it simply won't compile, saying something to the
effect that time(), do_time(), or __NR_time is undefined).  If this is the
case, remove all references to hacked_time and *original_time from
timewarp.c and see if it fixes things. 

Any reports regarding timewarp on non-Intel platforms are welcome. 

Implementation note: 

sys_time is not implemented in userspace using sys_gettimeofday(), so
timewarp must warp both of them.  Someday in the future (maybe in glibc6? 
I dunno because I haven't installed it yet..) it probably will be. 

