Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Apr 2007 19:39:50 -0700
From:      "Kelly Jones" <kelly.terry.jones@gmail.com>
To:        nmlug@nmlug.org, nmosug-l@mailman.swcp.com, linuxusersgroup@googlegroups.com,  techtalk@linuxchix.org, freebsd-questions@freebsd.org
Subject:   Using LD_PRELOAD to make date return a specific date
Message-ID:  <26face530704241939x1acd5d6en56b26fe4bdf69d85@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I recently discovered LD_PRELOAD, a cool environment variable that
lets a library "intercept" system calls. For example, setting
LD_PRELOAD to /usr/lib/libtsocks.so lets tsocks intercept socket
connections and redirect them to a SOCKS proxy.

My question: how can I write a library that intercepts the
gettimeofday() system call (or time() or whatever the 'date' command
uses) and gets 'date' to return, say, "Thu Jan 1 00:00:00 UTC 1970"?

I realize this involves a couple of steps (writing a C "library" for
one), so any pointers are appreciated. My real intentions are more
complex (and sinister <G>).

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26face530704241939x1acd5d6en56b26fe4bdf69d85>