]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
-s option.
authorWouter Wijngaards <wouter@NLnetLabs.nl>
Mon, 1 Mar 2010 09:49:11 +0000 (09:49 +0000)
committerWouter Wijngaards <wouter@NLnetLabs.nl>
Mon, 1 Mar 2010 09:49:11 +0000 (09:49 +0000)
Changelog
examples/ldns-compare-zones.1
examples/ldns-compare-zones.c

index 404817ec4d9de019c41d9722146a01020645e787..6235192f7f0d148986a7a75be76057e4a2cb5716 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@
        * Fix parse of \# syntax with space for type LOC.
        * Fix ldns_dname_absolute for escape sequences, fixes some parse errs.
        * bugfix #297: linking ssl, bug due to patch submitted as #296.
+       * ldns-compare-zones -s to not exclude SOA record from comparison.
 
 1.6.4  2010-01-20
        * Imported pyldns contribution by Zdenek Vasicek and Karel Slany.
index ae4d152a1d68b33f1e34ca9b16ba8a213b7e0c7a..facccd874562e180479ce0c7303ff3366cda278a 100644 (file)
@@ -7,55 +7,50 @@ ldns-compare-zones \- read and compare two zonefiles and print differences
 .IR [-i]
 .IR [-d]
 .IR [-z]
+.IR [-s]
 .IR ZONEFILE1
 .IR ZONEFILE2 
-
 .SH DESCRIPTION
-
 \fBldns-compare-zones\fR reads two DNS zone files and prints number of differences.
+.nf
 Output is formated to:
         +NUM_INS        -NUM_DEL        ~NUM_CHG
 
+.fi
 The major comparison is based on the owner name. If an owner name is present in zonefile 1, but not in zonefile 2, the resource records with this owner name are considered deleted, and counted as NUM_DEL. If an owner name is present in zonefile 2, but not in zonefile 1, the resource records with this owner name are considered inserted, and counted as NUM_INS. If an owner name is present in both, but there is a difference in the amount or content of the records, these are considered changed, and counted as NUM_CHG.
-
 .SH OPTIONS
 .TP
 \fB-c\fR
 Print resource records whose owner names are in both zone files, but with different resource records. (a.k.a. changed)
-
 .TP
 \fB-i\fR
 Print resource records whose owner names are present only in ZONEFILE2 (a.k.a. inserted)
-
 .TP
 \fB-d\fR
 Print resource records whose owner names are present only in ZONEFILE1 (a.k.a. deleted)
-
 .TP
 \fB-a\fR
 Print all changes. Specifying this option is the same as specifying -c -i
 amd -d.
-
 .TP
 \fB-z\fR
 Suppress zone sorting; this option is not recommended; it can cause records
 to be incorrectly marked as changed, depending of the nature of the changes.
-
+.TP
+\fB-s\fR
+Do not exclude the SOA record from the comparison.  The SOA record may
+then show up as changed due to a new serial number.  Off by default since
+you may be interested to know if (other zone apex elements) have changed.
 .TP
 \fB-h\fR
 Show usage and exit
-
 .TP
 \fB-v\fR
 Show the version and exit
-
-
 .SH AUTHOR
 Written by Ondřej Surý <ondrej@sury.org> for CZ.NIC, z.s.p.o. (czech domain registry)
-
 .SH REPORTING BUGS
 Report bugs to <ondrej@sury.org>.
-
 .SH COPYRIGHT
 Copyright (C) 2005 CZ.NIC, z.s.p.o.. This is free software. There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
index bb0ffc94a84a8fc34e99485226dfd603aeffd890..56d36a286c169caf61bbd50422d546cae7ee26a9 100644 (file)
 static void 
 usage(int argc, char **argv)
 {
-       printf("Usage: %s [-v] [-i] [-d] [-c] <zonefile1> <zonefile2>\n",
+       printf("Usage: %s [-v] [-i] [-d] [-c] [-s] <zonefile1> <zonefile2>\n",
                  argv[0]);
        printf("       -i - print inserted\n");
        printf("       -d - print deleted\n");
        printf("       -c - print changed\n");
        printf("       -a - print all differences (-i -d -c)\n");
+       printf("       -s - do not exclude SOA record from comparison\n");
        printf("       -z - do not sort zones\n");
 }
 
@@ -50,10 +51,10 @@ main(int argc, char **argv)
        size_t          num_ins = 0, num_del = 0, num_chg = 0;
        int             c;
        bool            opt_deleted = false, opt_inserted = false, opt_changed = false;
-        bool           sort = true;
+        bool           sort = true, inc_soa = false;
        char            op = 0;
 
-       while ((c = getopt(argc, argv, "ahvdicz")) != -1) {
+       while ((c = getopt(argc, argv, "ahvdicsz")) != -1) {
                switch (c) {
                case 'h':
                        usage(argc, argv);
@@ -66,6 +67,9 @@ main(int argc, char **argv)
                                  ldns_version());
                        exit(EXIT_SUCCESS);
                        break;
+               case 's':
+                       inc_soa = true;
+                       break;
                case 'z':
                        sort = false;
                         break;
@@ -157,6 +161,23 @@ main(int argc, char **argv)
                 ldns_zone_sort(z2);
         }
 
+       if(inc_soa) {
+               ldns_rr_list* wsoa = ldns_rr_list_new();
+               ldns_rr_list_push_rr(wsoa, ldns_zone_soa(z1));
+               ldns_rr_list_cat(wsoa, rrl1);
+               rrl1 = wsoa;
+               rrc1 = ldns_rr_list_rr_count(rrl1);
+               wsoa = ldns_rr_list_new();
+               ldns_rr_list_push_rr(wsoa, ldns_zone_soa(z2));
+               ldns_rr_list_cat(wsoa, rrl2);
+               rrl2 = wsoa;
+               rrc2 = ldns_rr_list_rr_count(rrl2);
+               if(sort) {
+                       ldns_rr_list_sort(rrl1);
+                       ldns_rr_list_sort(rrl2);
+               }
+       }
+
        /*
         * Walk through both zones. The previously seen resource record is
         * kept (in the variable rrx) so that we can recognize when we are
@@ -251,6 +272,10 @@ main(int argc, char **argv)
                  (unsigned int) num_chg);
 
        /* Free resources */
+       if(inc_soa) {
+               ldns_rr_list_free(rrl1);
+               ldns_rr_list_free(rrl2);
+       }
        ldns_zone_deep_free(z2);
        ldns_zone_deep_free(z1);