[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3742 - trunk/OpenDNSSEC/signer/src/signer

Matthijs Mekking matthijs at nlnetlabs.nl
Thu Aug 12 09:57:59 CEST 2010


Author: matthijs
Date: 2010-08-12 09:57:59 +0200 (Thu, 12 Aug 2010)
New Revision: 3742

Modified:
   trunk/OpenDNSSEC/signer/src/signer/tools.c
   trunk/OpenDNSSEC/signer/src/signer/zone.c
   trunk/OpenDNSSEC/signer/src/signer/zone.h
Log:
initial backup for zone state

Modified: trunk/OpenDNSSEC/signer/src/signer/tools.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-11 14:43:24 UTC (rev 3741)
+++ trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-12 07:57:59 UTC (rev 3742)
@@ -253,5 +253,10 @@
     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-11 14:43:24 UTC (rev 3741)
+++ trunk/OpenDNSSEC/signer/src/signer/zone.c	2010-08-12 07:57:59 UTC (rev 3742)
@@ -50,6 +50,9 @@
 #include <libhsmdns.h> /* hsm_create_context(), hsm_get_key(), hsm_destroy_context() */
 
 
+#define ODS_SE_FILE_MAGIC "ODSSE1"
+
+
 /**
  * Create a new zone.
  *
@@ -306,7 +309,7 @@
 
 
 /**
- * Add the DNSKEYs from the Signer Configuration to the zone data.
+ * Add the NSEC3PARAMSs from the Signer Configuration to the zone data.
  *
  */
 static int
@@ -582,6 +585,45 @@
 
 
 /**
+ * Backup zone data.
+ * \param[in] zone corresponding zone
+ * \return int 0 on success, 1 on error
+ *
+ */
+int zone_backup(zone_type* zone)
+{
+    int error = 0;
+    char* filename = NULL;
+    FILE* fd = NULL;
+
+    se_log_assert(zone);
+    se_log_assert(zone->zonedata);
+    se_log_assert(zone->signconf);
+
+    filename = se_build_path(zone->name, ".state", 0);
+    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, ";%s\n", ODS_SE_FILE_MAGIC);
+
+        se_fclose(fd);
+    } else {
+        se_log_error("cannot backup zone: cannot open file "
+        "%s for writing", filename?filename:"(null)");
+        return 1;
+    }
+    se_free((void*)filename);
+
+    return error;
+}
+
+
+/**
  * Clean up a zone.
  *
  */

Modified: trunk/OpenDNSSEC/signer/src/signer/zone.h
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/zone.h	2010-08-11 14:43:24 UTC (rev 3741)
+++ trunk/OpenDNSSEC/signer/src/signer/zone.h	2010-08-12 07:57:59 UTC (rev 3742)
@@ -156,6 +156,14 @@
 int zone_sign(zone_type* zone);
 
 /**
+ * Backup zone data.
+ * \param[in] zone corresponding zone
+ * \return int 0 on success, 1 on error
+ *
+ */
+int zone_backup(zone_type* zone);
+
+/**
  * Clean up a zone.
  * \param[in] zone zone to cleanup
  *




More information about the Opendnssec-commits mailing list