From owner-freebsd-questions@FreeBSD.ORG Wed Apr 25 02:39:55 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 57C9F16A406 for ; Wed, 25 Apr 2007 02:39:55 +0000 (UTC) (envelope-from kelly.terry.jones@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by mx1.freebsd.org (Postfix) with ESMTP id 180CC13C465 for ; Wed, 25 Apr 2007 02:39:54 +0000 (UTC) (envelope-from kelly.terry.jones@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so74838wxc for ; Tue, 24 Apr 2007 19:39:54 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=jHx572lJb7x+zuc7FGA5G8joc0M8ZKI24KH1nUP+OynGFmS+/8+Q4+NPLFUzRPbwi4pMGjiEZLMSlnkqDXyEykfgK2SpDRqJ6iG+7Sad9ho4Zn6l0mT9BEhHeIzrIeO8ATD1ZiySpk1/Z63EFIxityEPBTetdRjsIOMhNDIsMrU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=YlI+uv8qWoGUNNR/yCPhMUvGtpq33W36GkbCy9CjhSqqGfn6OBnV7mHK7MnqsewCjzEIv8csMe4XjxbVKKoWWB/GG6lxKE5tJpKL8CgJoyPIlr7PQ6fORNj97ArhtfT5oxObcssTQB7adsFyGxWhsinZf+gAw6J/JDq23lj2UFk= Received: by 10.70.69.11 with SMTP id r11mr52070wxa.1177468790520; Tue, 24 Apr 2007 19:39:50 -0700 (PDT) Received: by 10.70.41.12 with HTTP; Tue, 24 Apr 2007 19:39:50 -0700 (PDT) Message-ID: <26face530704241939x1acd5d6en56b26fe4bdf69d85@mail.gmail.com> Date: Tue, 24 Apr 2007 19:39:50 -0700 From: "Kelly Jones" To: nmlug@nmlug.org, nmosug-l@mailman.swcp.com, linuxusersgroup@googlegroups.com, techtalk@linuxchix.org, freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Cc: Subject: Using LD_PRELOAD to make date return a specific date X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2007 02:39:55 -0000 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 ). -- 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.