Skip to content

Commit

Permalink
Custom timestamp filename added: ~/.faketimerc alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-joker committed Nov 17, 2014
1 parent 527478d commit 6c207c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,15 @@ will be loaded, but just report the real system time. There are three
ways to specify the faked time:

a) By setting the environment variable FAKETIME.
b) By using the file .faketimerc in your home directory.
c) By using the file /etc/faketimerc for a system-wide default.
b) By using the file given in the environment variable FAKETIME_TIMESTAMP_FILE
c) By using the file .faketimerc in your home directory.
d) By using the file /etc/faketimerc for a system-wide default.

If you want to use b) or c), $HOME/.faketimerc or /etc/faketimerc consist of
If you want to use b) c) or d), $HOME/.faketimerc or /etc/faketimerc consist of
only one line of text with exactly the same content as the FAKETIME environment
variable, which is described below. Note that /etc/faketimerc will only be used
if there is no $HOME/.faketimerc, and the FAKETIME environment variable always
has priority over the files.
if there is no $HOME/.faketimerc nor FAKETIME_TIMESTAMP_FILE file exists, and
the FAKETIME environment variable always has priority over the files.


4b) Using absolute dates
Expand Down
5 changes: 4 additions & 1 deletion src/libfaketime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
if (parse_config_file)
{
static char user_faked_time[BUFFERLEN]; /* changed to static for caching in v0.6 */
char custom_filename[BUFSIZ];
char filename[BUFSIZ];
FILE *faketimerc;
/* initialize with default or env. variable */
Expand All @@ -1794,8 +1795,10 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
* a system-wide /etc/faketimerc present.
* The /etc/faketimerc handling has been contributed by David Burley,
* Jacob Moorman, and Wayne Davison of SourceForge, Inc. in version 0.6 */
(void) snprintf(custom_filename, BUFSIZ, "%s", getenv("FAKETIME_TIMESTAMP_FILE"));
(void) snprintf(filename, BUFSIZ, "%s/.faketimerc", getenv("HOME"));
if ((faketimerc = fopen(filename, "rt")) != NULL ||
if ((faketimerc = fopen(custom_filename, "rt")) != NULL ||
(faketimerc = fopen(filename, "rt")) != NULL ||
(faketimerc = fopen("/etc/faketimerc", "rt")) != NULL)
{
char line[BUFFERLEN];
Expand Down

0 comments on commit 6c207c9

Please sign in to comment.