1 From 79e60e145f8a595bca5a784c00b437216d51de68 Mon Sep 17 00:00:00 2001
2 From: Steven Barth <steven@midlink.org>
3 Date: Mon, 13 Apr 2015 09:45:20 +0200
4 Subject: [PATCH] dnssec: improve timestamp heuristic
6 Signed-off-by: Steven Barth <steven@midlink.org>
8 src/dnssec.c | 15 +++++++++++----
9 1 file changed, 11 insertions(+), 4 deletions(-)
13 @@ -432,17 +432,24 @@ static int back_to_the_future;
14 int setup_timestamp(void)
19 + time_t base = 1420070400; /* 1-1-2015 */
21 back_to_the_future = 0;
23 if (!daemon->timestamp_file)
29 + if (!stat("/proc/self/exe", &statbuf) && difftime(statbuf.st_mtime, base) > 0)
30 + base = statbuf.st_mtime;
32 if (stat(daemon->timestamp_file, &statbuf) != -1)
34 timestamp_time = statbuf.st_mtime;
36 - if (difftime(timestamp_time, time(0)) <= 0)
37 + if (difftime(now, base) >= 0 && difftime(timestamp_time, now) <= 0)
39 /* time already OK, update timestamp, and do key checking from the start. */
40 if (utime(daemon->timestamp_file, NULL) == -1)
41 @@ -463,7 +470,7 @@ int setup_timestamp(void)
45 - timestamp_time = timbuf.actime = timbuf.modtime = 1420070400; /* 1-1-2015 */
46 + timestamp_time = timbuf.actime = timbuf.modtime = base;
47 if (utime(daemon->timestamp_file, &timbuf) == 0)