From 2d941a894f4dbaeb6151fc3f74f932d48bec43e1 Mon Sep 17 00:00:00 2001 From: Ian Norton Date: Fri, 18 Mar 2022 12:03:24 +0000 Subject: fixes #374 fix compiling without FAKE_STAT --- src/libfaketime.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libfaketime.c b/src/libfaketime.c index e632395..0c28e5f 100644 --- a/src/libfaketime.c +++ b/src/libfaketime.c @@ -830,6 +830,10 @@ static bool load_time(struct timespec *tp) * Faked system functions: file related === FAKE(FILE) * ======================================================================= */ +#ifdef FAKE_UTIME +static int fake_utime_disabled = 0; +#endif + #ifdef FAKE_STAT @@ -843,7 +847,6 @@ static bool load_time(struct timespec *tp) #include static int fake_stat_disabled = 0; -static int fake_utime_disabled = 1; static bool user_per_tick_inc_set_backup = false; void lock_for_stat() @@ -2699,9 +2702,8 @@ static void ftpl_init(void) } #endif #if defined FAKE_FILE_TIMESTAMPS -#ifndef FAKE_UTIME - fake_utime_disabled = 0; // Defaults to enabled w/o FAKE_UTIME define -#endif +#ifdef FAKE_UTIME + // fake_utime_disabled is 0 by default if ((tmp_env = getenv("FAKE_UTIME")) != NULL) //Note that this is NOT re-checked { if (!*tmp_env || *tmp_env == 'y' || *tmp_env == 'Y' || *tmp_env == 't' || *tmp_env == 'T') @@ -2713,6 +2715,10 @@ static void ftpl_init(void) fake_utime_disabled = !atoi(tmp_env); } } +#else + // compiled without FAKE_UTIME support, so don't allow it to be controlled by the env var + fake_utime_disabled = 1; +#endif #endif if ((tmp_env = getenv("FAKETIME_CACHE_DURATION")) != NULL) -- cgit v1.2.1