# Does FreeBSD have something like Debian's datefudge?



## Bill Evans at Mariposa (Jun 22, 2015)

Command-line program `datefudge`, available on Debian, lets one run some other program using a faked date/time; good for testing whether a program behaves correctly on a leap day, among many other possible examples. Does FreeBSD have something like this?


----------



## sossego (Jun 24, 2015)

Rethought.
Where is the source code? Find it and port it.
This program is similar to driftnet. 
What are you trying to test?


----------



## Bill Evans at Mariposa (Jun 24, 2015)

sossego said:


> This program is similar to driftnet.


It doesn't seem to be similar at all. The brief description of `driftnet` in the list of all FreeBSD packages says, "Tool to grab images out of (your) TCP connections"; `datefudge`, on the other hand, lets you specify on the command line an arbitrary fudge factor and runs some arbitrary program you specify, providing substitute C library functions for things like gettimeofday(3); these functions turn around and calls the usual functions, fudging the results before returning them.


sossego said:


> Where is the source code? Find it and port it.


I've looked at the source code. It depends on lots of Linux idiosyncracies.


sossego said:


> What are you trying to test?


It would be handy to be able to answer questions similar to "How does this program behave on a leap day?" Or even "Does this program deal properly with leap seconds?"  Actually, the more general possibilities are fascinating.

If there is no such program, I'm tempted to hack `truss`/`gdb` to produce a general, script-driven layer between a running program and the outside world, without depending on modifying shared libraries.


----------



## sossego (Jun 26, 2015)

The program should be available. 
https://packages.debian.org/source/sid/datefudge
You will need to edit the files - after extracting, of course - to follow the necessary and equivalent ones in FreeBSD. The Ubuntu manual page for it states - in a certain manner - that nothing can be withheld. 
The possibilities for abuse of the program remain; and, for those uninformed of photorec and other such programs - for comparative analysis of data recovery -  will produce false positives.

You will need to look at the dependency list. FreeBSD uses llvm unless otherwise stated. This means that some of the compiling flags may need to be altered if you do not use the gcc compatibility flag.

Work along with others on this.


----------



## junovitch@ (Jun 26, 2015)

The Porter's Handbook at https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/ will cover most of what you need before "work along with others" as sossego mentioned will be needed.


----------



## drhowarddrfine (Jun 26, 2015)

No help at all but, many moons ago, I read about something like this on a FreeBSD forum. I'm going to bet there's something out there or a known method. Now take that and run with it!


----------



## Bill Evans at Mariposa (Jun 26, 2015)

sossego said:


> The possibilities for abuse of the program remain; and, for those uninformed of photorec and other such programs - for comparative analysis of data recovery -  will produce false positives.


Boy, now I'm really confused. According to wikipedia, `photorec` is used to recover deleted photos from cameras. All `datefudge` does is change the apparent date/time from the viewpoint of the object program. What am I mssing?


----------



## sossego (Jun 26, 2015)

http://www.cgsecurity.org/wiki/PhotoRec#File_systems
http://www.ex-parrot.com/~chris/driftnet/


----------



## Bill Evans at Mariposa (Jun 26, 2015)

Those two links (thanks for which, by the way) highlight my point. The purposes of both `photorec` and `driftnet` have nothing to do with what `datefudge` does.


----------



## NewGuy (Jun 27, 2015)

I have not tried using it on FreeBSD, but the faketime library might work and have fewer Linux-centric code: http://www.code-wizards.com/projects/libfaketime/

Alternatively, could you set up a virtual machine, install FreeBSD with your application and set the clock in the VM to be whatever you want. That would give you the fake time and, so long as NTPD is not enabled in the virtual machine, the programs you're running won't know the difference.


----------



## sossego (Jun 27, 2015)

Bill Evans at Mariposa said:


> Those two links (thanks for which, by the way) highlight my point. The purposes of both `photorec` and `driftnet` have nothing to do with what `datefudge` does.


Yes they do. Photorec is used by security to extract data from the drive. It does more than recover images.
Driftnet extracts images from a local active network. Both programs could be viewed as an invasion of privacy or an exposure of stupidity depending on your standpoint and morals. Datefudge is a program to alter the information of something just to see the results..  
https://www.cs.berkeley.edu/~wkahan/daydate/daydate.txt Surprisingly from the BSD base. 
So you insert the formula into the program.


----------



## sossego (Jun 27, 2015)

Datefudge is a program which one would be able to falsify data based upon the time stamp. Now, when I want to recover overwritten - which you know as formatted - material, I would use photorec and attach an external harddrive.  So, if you were to use datefudge on a document, I would be able to extract other documents of the same file type and determine - through comparative analysis - the real date.  Now, for what reason would you suggest to  have such a program added to FreeBSD? In plain text, it is the same as lying.


----------



## Bill Evans at Mariposa (Jun 27, 2015)

sossego said:


> Now, for what reason would you suggest to  have such a program added to FreeBSD?


I wasn't suggesting that; I was asking whether something like it was available. But you're right in that the two concepts are related.


sossego said:


> it is the same as lying.


"Lying" has moral implications. If I want to test my program to see how it handles leap days, or leap seconds, `datefudge` would be ideal.  The introduction in the README file for `libfaketime`, a different (and probably more portable) product with a similar aim. shows some half dozen other benign uses.

Further, when I run a program on my computer, I don't have any legal or moral obligation to present a "real" reality as that program's running environment.

The more I think about it, the more I'm tempted to hack `truss`/`gdb` to provide a script-driven way of totally specifying what a running program gets from its environment. No "lying" in a moral sense would be involved there.


----------

