From: Willem Toorop Date: Tue, 18 Nov 2025 14:40:57 +0000 (+0100) Subject: PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone X-Git-Tag: 1.9.0-rc.1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc2b587dac55d33e4f1c51a6bb004a796ce9525;p=thirdparty%2Fldns.git PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone Thanks gjherbiet --- diff --git a/Changelog b/Changelog index 0c311955..a0b5aee6 100644 --- 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. diff --git a/examples/ldns-compare-zones.1 b/examples/ldns-compare-zones.1 index 5a4a579f..76901349 100644 --- a/examples/ldns-compare-zones.1 +++ b/examples/ldns-compare-zones.1 @@ -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. diff --git a/examples/ldns-compare-zones.c b/examples/ldns-compare-zones.c index 750a8455..1ee3602e 100644 --- a/examples/ldns-compare-zones.c +++ b/examples/ldns-compare-zones.c @@ -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] " " \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);