]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Update DNSSEC timestamp file on process TERM.
authorKevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
Mon, 27 Jul 2015 18:34:23 +0000 (19:34 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Mon, 27 Jul 2015 18:34:23 +0000 (19:34 +0100)
src/dnsmasq.c
src/dnsmasq.h
src/dnssec.c

index 514e10bdf206cb966d1dc41fe63e15429794c61e..04d57580f24bfc7af41c15e4a70ec4ac614cebd7 100644 (file)
@@ -1321,6 +1321,15 @@ static void async_event(int pipe, time_t now)
        if (daemon->lease_stream)
          fclose(daemon->lease_stream);
 
+#ifdef HAVE_DNSSEC
+       /* update timestamp file on TERM if time is considered valid */
+       if (daemon->back_to_the_future)
+         {
+            if (utime(daemon->timestamp_file, NULL) == -1)
+               my_syslog(LOG_ERR, _("failed to update mtime on %s: %s"), daemon->timestamp_file, strerror(errno));
+         }
+#endif
+
        if (daemon->runfile)
          unlink(daemon->runfile);
        
index de146c649491c9f44b9c7b39b0d4b89c7ebb5607..e4035db30209d04bec061a02c4322896ff902d28 100644 (file)
@@ -992,6 +992,7 @@ extern struct daemon {
 #endif
 #ifdef HAVE_DNSSEC
   struct ds_config *ds;
+  int back_to_the_future;
   char *timestamp_file;
 #endif
 
index 55cf90bec7b3d4a1bcc5017d04503626220f0a5b..0aa41ce322578876c5bd8a73ba5dc24fa9bed0e3 100644 (file)
@@ -427,13 +427,12 @@ static int serial_compare_32(unsigned long s1, unsigned long s2)
 */
 
 static time_t timestamp_time;
-static int back_to_the_future;
 
 int setup_timestamp(void)
 {
   struct stat statbuf;
   
-  back_to_the_future = 0;
+  daemon->back_to_the_future = 0;
   
   if (!daemon->timestamp_file)
     return 0;
@@ -447,7 +446,7 @@ int setup_timestamp(void)
          /* time already OK, update timestamp, and do key checking from the start. */
          if (utime(daemon->timestamp_file, NULL) == -1)
            my_syslog(LOG_ERR, _("failed to update mtime on %s: %s"), daemon->timestamp_file, strerror(errno));
-         back_to_the_future = 1;
+         daemon->back_to_the_future = 1;
          return 0;
        }
       return 1;
@@ -487,17 +486,17 @@ static int check_date_range(unsigned long date_start, unsigned long date_end)
      and start checking keys */
   if (daemon->timestamp_file)
     {
-      if (back_to_the_future == 0 && difftime(timestamp_time, curtime) <= 0)
+      if (daemon->back_to_the_future == 0 && difftime(timestamp_time, curtime) <= 0)
        {
          if (utime(daemon->timestamp_file, NULL) != 0)
            my_syslog(LOG_ERR, _("failed to update mtime on %s: %s"), daemon->timestamp_file, strerror(errno));
          
-         back_to_the_future = 1;       
+         daemon->back_to_the_future = 1;
          set_option_bool(OPT_DNSSEC_TIME);
          queue_event(EVENT_RELOAD); /* purge cache */
        } 
 
-      if (back_to_the_future == 0)
+      if (daemon->back_to_the_future == 0)
        return 1;
     }
   else if (option_bool(OPT_DNSSEC_TIME))