]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone
authorWillem Toorop <willem@nlnetlabs.nl>
Tue, 18 Nov 2025 14:40:57 +0000 (15:40 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Tue, 18 Nov 2025 14:40:57 +0000 (15:40 +0100)
Thanks gjherbiet

Changelog
examples/ldns-compare-zones.1
examples/ldns-compare-zones.c

index 0c31195516b740c913231ee6fd184f3e63588874..a0b5aee6f11a24733f06125b0f6bbacbceb72bbb 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -38,6 +38,8 @@
          Thanks jschauma
        * PR #200: Allow compiled tests to link to ldns statically via
          environment variable. Thanks FGasper and pemensik
+       * PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone
+         Thanks gjherbiet
 
 1.8.4  2024-07-19
        * Fix building documentation in build directory.
index 5a4a579fb55df2fc684c7e0f092d757c5ad50028..7690134993d67b952629893715109c5586afe3cd 100644 (file)
@@ -8,6 +8,7 @@ ldns-compare-zones \- read and compare two zonefiles and print differences
 .IR [-u]
 .IR [-i]
 .IR [-d]
+.IR [-Z]
 .IR [-z]
 .IR [-s]
 .IR ZONEFILE1
@@ -44,6 +45,9 @@ Print resource records whose owner names are present only in ZONEFILE1 (a.k.a. d
 Print all changes (except unchanged). Specifying this option is the same as specifying \-c \-i
 and \-d.
 .TP
+\fB-Z\fR
+exclude ZONEMD records from comparison
+.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.
index 750a8455aec5486a89275db78270424d3dcacfbf..1ee3602e3fefdc5ada43e5778baf1d2298efe100 100644 (file)
@@ -26,7 +26,7 @@
 static void 
 usage(char *prog)
 {
-       printf("Usage: %s [-v] [-i] [-d] [-c] [-u] [-s] [-e] "
+       printf("Usage: %s [-v] [-i] [-d] [-c] [-u] [-s] [-Z] [-e] "
               "<zonefile1> <zonefile2>\n", prog);
        printf("       -i - print inserted\n");
        printf("       -d - print deleted\n");
@@ -35,6 +35,7 @@ usage(char *prog)
        printf("       -U - print unchanged records in changed names\n");
        printf("       -a - print all differences (-i -d -c)\n");
        printf("       -s - do not exclude SOA record from comparison\n");
+       printf("       -Z - exclude ZONEMD records from comparison\n");
        printf("       -z - do not sort zones\n");
        printf("       -e - exit with status 2 on changed zones\n");
        printf("       -h - show usage and exit\n");
@@ -60,11 +61,11 @@ main(int argc, char **argv)
        int             c;
        bool            opt_deleted = false, opt_inserted  = false;
        bool            opt_changed = false, opt_unchanged = false, opt_Unchanged = false;
-        bool           sort = true, inc_soa = false;
+        bool           sort = true, inc_soa = false, exc_zonemd = false;
        bool            opt_exit_status = false;
        char            op = 0;
 
-       while ((c = getopt(argc, argv, "ahvdicuUesz")) != -1) {
+       while ((c = getopt(argc, argv, "ahvdicuUesZz")) != -1) {
                switch (c) {
                case 'h':
                        usage(argv[0]);
@@ -83,6 +84,9 @@ main(int argc, char **argv)
                case 's':
                        inc_soa = true;
                        break;
+               case 'Z':
+                       exc_zonemd = true;
+                       break;
                case 'z':
                        sort = false;
                         break;
@@ -208,6 +212,18 @@ main(int argc, char **argv)
         * set the operator again.
         */
        for (i = 0, j = 0; i < rrc1 || j < rrc2;) {
+               if (exc_zonemd) {
+                       if (ldns_rr_get_type(ldns_rr_list_rr(rrl1, i))
+                                       == LDNS_RR_TYPE_ZONEMD) {
+                               i += 1;
+                               continue;
+                       }
+                       if (ldns_rr_get_type(ldns_rr_list_rr(rrl2, j))
+                                       == LDNS_RR_TYPE_ZONEMD) {
+                               j += 1;
+                               continue;
+                       }
+               }
                rr_cmp = 0;
                if (i < rrc1 && j < rrc2) {
                        rr1 = ldns_rr_list_rr(rrl1, i);