Skip to content

Commit fd53bd0

Browse files
committed
check for duplicate records with pdnssec check-all-zones (Issue #607)
1 parent 7eaa83a commit fd53bd0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pdns/pdnssec.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
339339
DNSResourceRecord rr;
340340
uint64_t numrecords=0, numerrors=0, numwarnings=0;
341341

342-
set<string> cnames, noncnames;
342+
set<string> records, cnames, noncnames;
343343

344344
while(sd.db->get(rr)) {
345345
if(!endsOn(rr.qname, zone)) {
@@ -351,6 +351,18 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
351351
if(!rr.qtype.getCode())
352352
continue;
353353

354+
ostringstream content;
355+
content<<rr.qname<<" "<<rr.qtype.getName();
356+
if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
357+
content<<" "<<rr.priority;
358+
content<<" "<<rr.content;
359+
if (records.count(content.str())) {
360+
cout<<"[Error] Duplicate record found '"<<content.str()<<"' This do not belong in the database."<<endl;
361+
numerrors++;
362+
continue;
363+
} else
364+
records.insert(content.str());
365+
354366
if (rr.qtype.getCode() == QType::CNAME) {
355367
if (!cnames.count(rr.qname))
356368
cnames.insert(rr.qname);
@@ -364,6 +376,7 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
364376
if(!dk.isPresigned(zone)) {
365377
cout<<"[Error] RRSIG found at '"<<rr.qname<<"' in non-presigned zone. These do not belong in the database."<<endl;
366378
numerrors++;
379+
continue;
367380
}
368381
} else
369382
noncnames.insert(rr.qname);

0 commit comments

Comments
 (0)