2015-04-13 07:49:29 +00:00
|
|
|
From 79e60e145f8a595bca5a784c00b437216d51de68 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Steven Barth <steven@midlink.org>
|
|
|
|
Date: Mon, 13 Apr 2015 09:45:20 +0200
|
|
|
|
Subject: [PATCH] dnssec: improve timestamp heuristic
|
|
|
|
|
|
|
|
Signed-off-by: Steven Barth <steven@midlink.org>
|
|
|
|
---
|
|
|
|
src/dnssec.c | 15 +++++++++++----
|
|
|
|
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
--- a/src/dnssec.c
|
|
|
|
+++ b/src/dnssec.c
|
2016-05-19 10:55:15 +00:00
|
|
|
@@ -462,17 +462,24 @@ static time_t timestamp_time;
|
2015-04-13 07:49:29 +00:00
|
|
|
int setup_timestamp(void)
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
+ time_t now;
|
|
|
|
+ time_t base = 1420070400; /* 1-1-2015 */
|
2015-07-30 08:53:43 +00:00
|
|
|
|
|
|
|
daemon->back_to_the_future = 0;
|
2015-04-13 07:49:29 +00:00
|
|
|
|
|
|
|
if (!daemon->timestamp_file)
|
|
|
|
return 0;
|
|
|
|
+
|
|
|
|
+ now = time(NULL);
|
|
|
|
+
|
|
|
|
+ if (!stat("/proc/self/exe", &statbuf) && difftime(statbuf.st_mtime, base) > 0)
|
|
|
|
+ base = statbuf.st_mtime;
|
2015-07-30 08:53:43 +00:00
|
|
|
|
2015-04-13 07:49:29 +00:00
|
|
|
if (stat(daemon->timestamp_file, &statbuf) != -1)
|
|
|
|
{
|
|
|
|
timestamp_time = statbuf.st_mtime;
|
|
|
|
check_and_exit:
|
|
|
|
- if (difftime(timestamp_time, time(0)) <= 0)
|
2015-07-30 08:53:43 +00:00
|
|
|
+ if (difftime(now, base) >= 0 && difftime(timestamp_time, now) <= 0)
|
2015-04-13 07:49:29 +00:00
|
|
|
{
|
|
|
|
/* time already OK, update timestamp, and do key checking from the start. */
|
2017-06-01 22:12:34 +00:00
|
|
|
if (utimes(daemon->timestamp_file, NULL) == -1)
|
2016-05-19 10:55:15 +00:00
|
|
|
@@ -493,7 +500,7 @@ int setup_timestamp(void)
|
2015-04-13 07:49:29 +00:00
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
2017-06-01 22:12:34 +00:00
|
|
|
- timestamp_time = 1420070400; /* 1-1-2015 */
|
|
|
|
+ timestamp_time = base; /* 1-1-2015 */
|
|
|
|
tv[0].tv_sec = tv[1].tv_sec = timestamp_time;
|
|
|
|
tv[0].tv_usec = tv[1].tv_usec = 0;
|
|
|
|
if (utimes(daemon->timestamp_file, tv) == 0)
|