[Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r5420 - in trunk/OpenDNSSEC: . enforcer/utils

Sion Lloyd sion at nominet.org.uk
Tue Aug 16 16:40:41 CEST 2011


Author: sion
Date: 2011-08-16 16:40:41 +0200 (Tue, 16 Aug 2011)
New Revision: 5420

Modified:
   trunk/OpenDNSSEC/NEWS
   trunk/OpenDNSSEC/enforcer/utils/ksmutil.c
Log:
"ods-ksmutil zone list" now handles empty zonelists; trac ticket #260.


Modified: trunk/OpenDNSSEC/NEWS
===================================================================
--- trunk/OpenDNSSEC/NEWS	2011-08-16 14:27:47 UTC (rev 5419)
+++ trunk/OpenDNSSEC/NEWS	2011-08-16 14:40:41 UTC (rev 5420)
@@ -12,6 +12,7 @@
 * Bugfix #246: Less confusing text for XML validation in ods-kaspcheck.
 * ods-ksmutil: "update kasp" now reflects changes in policy descriptions.
 * ods-ksmutil: Policy descriptions now have special characters quoted.
+* Bugfix #260: "ods-ksmutil zone list" now handles empty zonelists.
 
 
 OpenDNSSEC 1.3.0 - 2011-07-12

Modified: trunk/OpenDNSSEC/enforcer/utils/ksmutil.c
===================================================================
--- trunk/OpenDNSSEC/enforcer/utils/ksmutil.c	2011-08-16 14:27:47 UTC (rev 5419)
+++ trunk/OpenDNSSEC/enforcer/utils/ksmutil.c	2011-08-16 14:40:41 UTC (rev 5420)
@@ -1321,16 +1321,20 @@
     /* Read the file and list the zones as we go */
     list_zone_node(zonelist_filename, zone_ids);
 
-    /* Now see if there are any zones in the DB which are not in the file */
-    StrAppend(&sql, "select name from zones where id not in (");
-    for (j = 0; j < file_zone_count; ++j) {
-        if (j != 0) {
-            StrAppend(&sql, ",");
-        }
-        snprintf(buffer, sizeof(buffer), "%d", zone_ids[j]);
-        StrAppend(&sql, buffer);
-    }
-    StrAppend(&sql, ")");
+	/* Now see if there are any zones in the DB which are not in the file */
+	if (file_zone_count != 0) {
+		StrAppend(&sql, "select name from zones where id not in (");
+		for (j = 0; j < file_zone_count; ++j) {
+			if (j != 0) {
+				StrAppend(&sql, ",");
+			}
+			snprintf(buffer, sizeof(buffer), "%d", zone_ids[j]);
+			StrAppend(&sql, buffer);
+		}
+		StrAppend(&sql, ")");
+	} else {
+		StrAppend(&sql, "select name from zones");
+	}
 
     status = DbExecuteSql(DbHandle(), sql, &result);
     if (status == 0) {
@@ -1341,6 +1345,7 @@
 
             printf("Found zone %s in DB but not zonelist.\n", temp_name);
             status = DbFetchRow(result, &row);
+			file_zone_count++;
         }
 
         /* Convert EOF status to success */
@@ -1355,6 +1360,10 @@
     db_disconnect(lock_fd);
     DbDisconnect(dbhandle);
 
+	if (file_zone_count == 0) {
+		printf("No zones in DB or zonelist.\n");
+	}
+
     MemFree(zone_ids);
     StrFree(sql);
     StrFree(zonelist_filename);




More information about the Opendnssec-commits mailing list