[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3840 - in trunk/OpenDNSSEC/signer/src: daemon scheduler signer

Matthijs Mekking matthijs at nlnetlabs.nl
Tue Aug 31 14:51:42 CEST 2010


Author: matthijs
Date: 2010-08-31 14:51:41 +0200 (Tue, 31 Aug 2010)
New Revision: 3840

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/engine.c
   trunk/OpenDNSSEC/signer/src/scheduler/task.c
   trunk/OpenDNSSEC/signer/src/scheduler/task.h
   trunk/OpenDNSSEC/signer/src/signer/backup.c
   trunk/OpenDNSSEC/signer/src/signer/zone.c
Log:
comment out for now

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-31 12:06:15 UTC (rev 3839)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-31 12:51:41 UTC (rev 3840)
@@ -871,7 +871,7 @@
         } else {
             se_log_debug("signer engine started");
             /* try to recover from backups */
-            engine_recover_from_backups(engine);
+/*            engine_recover_from_backups(engine); */
         }
 
         if (zl_changed) {

Modified: trunk/OpenDNSSEC/signer/src/scheduler/task.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/scheduler/task.c	2010-08-31 12:06:15 UTC (rev 3839)
+++ trunk/OpenDNSSEC/signer/src/scheduler/task.c	2010-08-31 12:51:41 UTC (rev 3840)
@@ -32,6 +32,7 @@
  */
 
 #include "scheduler/task.h"
+#include "signer/backup.h"
 #include "signer/zone.h"
 #include "util/duration.h"
 #include "util/file.h"
@@ -73,6 +74,55 @@
 
 
 /**
+ * Recover a task from backup.
+ *
+ */
+task_type*
+task_recover_from_backup(const char* filename, struct zone_struct* zone)
+{
+    task_type* task = NULL;
+    FILE* fd = NULL;
+    const char* who = NULL;
+    int what = 0;
+    time_t when = 0;
+    int flush = 0;
+    time_t backoff = 0;
+
+    se_log_assert(zone);
+    fd = se_fopen(filename, NULL, "r");
+    if (fd) {
+        if (!backup_read_check_str(fd, ODS_SE_FILE_MAGIC) ||
+            !backup_read_check_str(fd, ";who:") ||
+            !backup_read_str(fd, &who) ||
+            !backup_read_check_str(fd, ";what:") ||
+            !backup_read_int(fd, &what) ||
+            !backup_read_check_str(fd, ";when:") ||
+            !backup_read_time_t(fd, &when) ||
+            !backup_read_check_str(fd, ";flush:") ||
+            !backup_read_int(fd, &flush) ||
+            !backup_read_check_str(fd, ";backoff:") ||
+            !backup_read_time_t(fd, &backoff) ||
+            !backup_read_check_str(fd, ODS_SE_FILE_MAGIC))
+        {
+            se_log_error("unable to recover task backup file %s: corrupt "
+                "backup file ", filename?filename:"(null)");
+            task = NULL;
+        } else {
+            task = task_create((task_id) what, when, who, zone);
+            task->flush = flush;
+            task->backoff = backoff;
+        }
+        se_fclose(fd);
+        return task;
+    }
+
+    se_log_debug("unable to recover task backup file %s",
+        filename?filename:"(null)");
+    return NULL;
+}
+
+
+/**
  * Backup task.
  *
  */

Modified: trunk/OpenDNSSEC/signer/src/scheduler/task.h
===================================================================
--- trunk/OpenDNSSEC/signer/src/scheduler/task.h	2010-08-31 12:06:15 UTC (rev 3839)
+++ trunk/OpenDNSSEC/signer/src/scheduler/task.h	2010-08-31 12:51:41 UTC (rev 3840)
@@ -100,6 +100,16 @@
     struct zone_struct* zone);
 
 /**
+ * Recover a task from backup.
+ * \param[in] filename where the task backup is stored
+ * \param[in] zone pointer to zone structure
+ * \return task_type* created task
+ *
+ */
+task_type* task_recover_from_backup(const char* filename,
+    struct zone_struct* zone);
+
+/**
  * Backup task.
  * \param[in] task task
  *

Modified: trunk/OpenDNSSEC/signer/src/signer/backup.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/backup.c	2010-08-31 12:06:15 UTC (rev 3839)
+++ trunk/OpenDNSSEC/signer/src/signer/backup.c	2010-08-31 12:51:41 UTC (rev 3840)
@@ -93,7 +93,7 @@
         se_log_debug("backup: cannot read string\n");
         return 0;
     }
-    *str = p;
+    *str = se_strdup(p);
     return 1;
 }
 

Modified: trunk/OpenDNSSEC/signer/src/signer/zone.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/zone.c	2010-08-31 12:06:15 UTC (rev 3839)
+++ trunk/OpenDNSSEC/signer/src/signer/zone.c	2010-08-31 12:51:41 UTC (rev 3840)
@@ -673,7 +673,10 @@
 {
     int klass = 0;
     char* filename = NULL;
+    task_type* task = NULL;
+    time_t now = 0;
     FILE* fd = NULL;
+    int corrupted = 0;
 
     se_log_assert(zone);
     se_log_assert(zone->zonedata);
@@ -717,12 +720,31 @@
         /* no, stop recovering process */
         return;
     }
+    zone->signconf->keys = keylist_create();
 
+    /* zone data */
+    filename = se_build_path(zone->name, ".unsorted", 0);
+    se_free((void*)filename);
+
     /* time for the keys and nsec3params file */
+    filename = se_build_path(zone->name, ".dnskeys", 0);
+    se_free((void*)filename);
 
-    /* zone data */
+    filename = se_build_path(zone->name, ".denial", 0);
+    se_free((void*)filename);
 
+    filename = se_build_path(zone->name, ".rrsigs", 0);
+    se_free((void*)filename);
+
     /* task */
+    filename = se_build_path(zone->name, ".task", 0);
+    zone->task = task_recover_from_backup((const char*) filename, zone);
+    se_free((void*)filename);
+    if (!zone->task) {
+        now = time_now();
+        zone->task = task_create(TASK_READ, now, zone->name, zone);
+    }
+    task = tasklist_schedule_task(tl, zone->task, 0);
 
     return;
 }




More information about the Opendnssec-commits mailing list