I already know about faketime and datefudge, but is there a way to set this up transparently for any process that's being run as a certain user (identified by a specific UID)?


Since you have the entire source code to Linux, you can set this up exactly as you want, but you'll have to modify the system kernel and rebuild it to make it so. It isn't easy to set this up based on a UID.

If you only want to arrange that a logged in user has this property for most commands they execute, give them a login shell that uses faketime to set the environment variable and then call their real shell. You can get a taste for how this looks by doing it interactively:

$ date
Mon Oct 14 14:02:05 EDT 2013
$ faketime yesterday bash
$ date
Sun Oct 13 14:02:10 EDT 2013
$ exit
$ date
Mon Oct 14 14:02:15 EDT 2013

A special login shell should also work for cron jobs that use the user's login shell.

Of course this fakery fails for any program that sets or ignores its own $LD_PRELOAD information:

$ faketime yesterday bash
$ date
Sun Oct 13 14:02:20 EDT 2013
$ env -i /bin/date
Mon Oct 14 14:02:25 EDT 2013

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.