WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7dc2b58

Browse files
committed
PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone
Thanks gjherbiet
1 parent 2119ebe commit 7dc2b58

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
Thanks jschauma
3939
* PR #200: Allow compiled tests to link to ldns statically via
4040
environment variable. Thanks FGasper and pemensik
41+
* PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone
42+
Thanks gjherbiet
4143

4244
1.8.4 2024-07-19
4345
* Fix building documentation in build directory.

examples/ldns-compare-zones.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ldns-compare-zones \- read and compare two zonefiles and print differences
88
.IR [-u]
99
.IR [-i]
1010
.IR [-d]
11+
.IR [-Z]
1112
.IR [-z]
1213
.IR [-s]
1314
.IR ZONEFILE1
@@ -44,6 +45,9 @@ Print resource records whose owner names are present only in ZONEFILE1 (a.k.a. d
4445
Print all changes (except unchanged). Specifying this option is the same as specifying \-c \-i
4546
and \-d.
4647
.TP
48+
\fB-Z\fR
49+
exclude ZONEMD records from comparison
50+
.TP
4751
\fB-z\fR
4852
Suppress zone sorting; this option is not recommended; it can cause records
4953
to be incorrectly marked as changed, depending of the nature of the changes.

examples/ldns-compare-zones.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
static void
2727
usage(char *prog)
2828
{
29-
printf("Usage: %s [-v] [-i] [-d] [-c] [-u] [-s] [-e] "
29+
printf("Usage: %s [-v] [-i] [-d] [-c] [-u] [-s] [-Z] [-e] "
3030
"<zonefile1> <zonefile2>\n", prog);
3131
printf(" -i - print inserted\n");
3232
printf(" -d - print deleted\n");
@@ -35,6 +35,7 @@ usage(char *prog)
3535
printf(" -U - print unchanged records in changed names\n");
3636
printf(" -a - print all differences (-i -d -c)\n");
3737
printf(" -s - do not exclude SOA record from comparison\n");
38+
printf(" -Z - exclude ZONEMD records from comparison\n");
3839
printf(" -z - do not sort zones\n");
3940
printf(" -e - exit with status 2 on changed zones\n");
4041
printf(" -h - show usage and exit\n");
@@ -60,11 +61,11 @@ main(int argc, char **argv)
6061
int c;
6162
bool opt_deleted = false, opt_inserted = false;
6263
bool opt_changed = false, opt_unchanged = false, opt_Unchanged = false;
63-
bool sort = true, inc_soa = false;
64+
bool sort = true, inc_soa = false, exc_zonemd = false;
6465
bool opt_exit_status = false;
6566
char op = 0;
6667

67-
while ((c = getopt(argc, argv, "ahvdicuUesz")) != -1) {
68+
while ((c = getopt(argc, argv, "ahvdicuUesZz")) != -1) {
6869
switch (c) {
6970
case 'h':
7071
usage(argv[0]);
@@ -83,6 +84,9 @@ main(int argc, char **argv)
8384
case 's':
8485
inc_soa = true;
8586
break;
87+
case 'Z':
88+
exc_zonemd = true;
89+
break;
8690
case 'z':
8791
sort = false;
8892
break;
@@ -208,6 +212,18 @@ main(int argc, char **argv)
208212
* set the operator again.
209213
*/
210214
for (i = 0, j = 0; i < rrc1 || j < rrc2;) {
215+
if (exc_zonemd) {
216+
if (ldns_rr_get_type(ldns_rr_list_rr(rrl1, i))
217+
== LDNS_RR_TYPE_ZONEMD) {
218+
i += 1;
219+
continue;
220+
}
221+
if (ldns_rr_get_type(ldns_rr_list_rr(rrl2, j))
222+
== LDNS_RR_TYPE_ZONEMD) {
223+
j += 1;
224+
continue;
225+
}
226+
}
211227
rr_cmp = 0;
212228
if (i < rrc1 && j < rrc2) {
213229
rr1 = ldns_rr_list_rr(rrl1, i);

0 commit comments

Comments
 (0)