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

Matthijs Mekking matthijs at nlnetlabs.nl
Mon Aug 30 14:38:29 CEST 2010


Author: matthijs
Date: 2010-08-30 14:38:28 +0200 (Mon, 30 Aug 2010)
New Revision: 3827

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
   trunk/OpenDNSSEC/signer/src/signer/tools.c
   trunk/OpenDNSSEC/signer/src/signer/zone.c
   trunk/OpenDNSSEC/signer/src/signer/zone.h
Log:
.state file revised

Modified: trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-30 12:20:28 UTC (rev 3826)
+++ trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-30 12:38:28 UTC (rev 3827)
@@ -282,6 +282,10 @@
     unlink(tmpname);
     se_free((void*)tmpname);
 
+    tmpname = se_build_path(tbd, ".state", 0);
+    unlink(tmpname);
+    se_free((void*)tmpname);
+
     tmpname = se_build_path(tbd, ".unsorted", 0);
     unlink(tmpname);
     se_free((void*)tmpname);

Modified: trunk/OpenDNSSEC/signer/src/signer/tools.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-30 12:20:28 UTC (rev 3826)
+++ trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-30 12:38:28 UTC (rev 3827)
@@ -90,6 +90,10 @@
     end = time(NULL);
     zone->stats->sort_time = (end-start);
 
+    if (!error) {
+        zone_backup_state(zone);
+    }
+
     return error;
 }
 
@@ -115,10 +119,16 @@
 int
 tools_update(zone_type* zone)
 {
+    int error = 0;
+
     se_log_assert(zone);
     se_log_assert(zone->signconf);
     se_log_verbose("update zone %s", zone->name?zone->name:"(null)");
-    return zone_update_zonedata(zone);
+    error = zone_update_zonedata(zone);
+    if (!error) {
+        zone_backup_state(zone);
+    }
+    return error;
 }
 
 
@@ -171,6 +181,9 @@
     error = zone_sign(zone);
     end = time(NULL);
     zone->stats->sig_time = (end-start);
+    if (!error) {
+        zone_backup_state(zone);
+    }
     return error;
 }
 
@@ -251,15 +264,9 @@
 
     /* log stats */
     zone->stats->end_time = time(NULL);
-
     se_log_debug("log stats for zone %s", zone->name?zone->name:"(null)");
     stats_log(zone->stats, zone->name, zone->signconf->nsec_type);
     stats_clear(zone->stats);
 
-    /* make backup */
-    if (zone_backup(zone) != 0) {
-        se_log_warning("backup zone %s failed", zone->name?zone->name:"(null)");
-    }
-
     return error;
 }

Modified: trunk/OpenDNSSEC/signer/src/signer/zone.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/zone.c	2010-08-30 12:20:28 UTC (rev 3826)
+++ trunk/OpenDNSSEC/signer/src/signer/zone.c	2010-08-30 12:38:28 UTC (rev 3827)
@@ -630,7 +630,7 @@
  * \return int 0 on success, 1 on error
  *
  */
-int zone_backup(zone_type* zone)
+int zone_backup_state(zone_type* zone)
 {
     int error = 0;
     char* filename = NULL;
@@ -644,13 +644,13 @@
     fd = se_fopen(filename, NULL, "w");
     if (fd) {
         fprintf(fd, ";%s\n", ODS_SE_FILE_MAGIC);
-        fprintf(fd, "; Zone state within OpenDNSSEC\n");
-        fprintf(fd, "; DO NOT EDIT MANUALLY!\n");
-        fprintf(fd, "zone_name: %s\n", zone->name?zone->name:"(null)");
-        fprintf(fd, "zd_outbound_serial: %u\n",
-            zone->zonedata->outbound_serial);
+        fprintf(fd, "name: %s\n", zone->name?zone->name:"(null)");
+        fprintf(fd, "class: %i\n", (int) zone->klass);
+        fprintf(fd, "default_ttl: %u\n", zone->zonedata->default_ttl);
+        fprintf(fd, "inbound_serial: %u\n", zone->zonedata->inbound_serial);
+        fprintf(fd, "internal_serial: %u\n", zone->zonedata->internal_serial);
+        fprintf(fd, "outbound_serial: %u\n", zone->zonedata->outbound_serial);
         fprintf(fd, ";%s\n", ODS_SE_FILE_MAGIC);
-
         se_fclose(fd);
     } else {
         se_log_error("cannot backup zone: cannot open file "

Modified: trunk/OpenDNSSEC/signer/src/signer/zone.h
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/zone.h	2010-08-30 12:20:28 UTC (rev 3826)
+++ trunk/OpenDNSSEC/signer/src/signer/zone.h	2010-08-30 12:38:28 UTC (rev 3827)
@@ -156,12 +156,12 @@
 int zone_sign(zone_type* zone);
 
 /**
- * Backup zone data.
+ * Backup zone state.
  * \param[in] zone corresponding zone
  * \return int 0 on success, 1 on error
  *
  */
-int zone_backup(zone_type* zone);
+int zone_backup_state(zone_type* zone);
 
 /**
  * Clean up a zone.




More information about the Opendnssec-commits mailing list