Skip to content

Commit 34479a6

Browse files
mind04Peter van Dijk
authored andcommitted
fix getAuth for DS queries at apex
1 parent d080e91 commit 34479a6

File tree

7 files changed

+37
-5
lines changed

7 files changed

+37
-5
lines changed

pdns/packethandler.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,23 @@ int PacketHandler::doVersionRequest(DNSPacket *p, DNSPacket *r, string &target)
286286
/** Determines if we are authoritative for a zone, and at what level */
287287
bool PacketHandler::getAuth(DNSPacket *p, SOAData *sd, const string &target, int *zoneId)
288288
{
289+
bool found=false;
289290
string subdomain(target);
290291
do {
291292
if( B.getSOA( subdomain, *sd, p ) ) {
292-
if(p->qtype.getCode() == QType::DS && pdns_iequals(subdomain, target))
293-
continue; // A DS question is never answered from the apex, go one zone upwards
294-
295293
sd->qname = subdomain;
296294
if(zoneId)
297295
*zoneId = sd->domain_id;
298-
return true;
296+
297+
if(p->qtype.getCode() == QType::DS && pdns_iequals(subdomain, target)) {
298+
// Found authoritative zone but look for parent zone with 'DS' record.
299+
found=true;
300+
} else
301+
return true;
299302
}
300303
}
301304
while( chopOff( subdomain ) ); // 'www.powerdns.org' -> 'powerdns.org' -> 'org' -> ''
302-
return false;
305+
return found;
303306
}
304307

305308
vector<DNSResourceRecord> PacketHandler::getBestReferralNS(DNSPacket *p, SOAData& sd, const string &target)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cleandig example.com DS dnssec
3+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This test tries to resolve a non-existent DS at apex
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
2+
2 . IN OPT 32768
3+
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
4+
Reply to question for qname='example.com.', qtype=DS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
1 example.com. IN NSEC 86400 double.example.com. NS SOA MX RRSIG NSEC DNSKEY
2+
1 example.com. IN RRSIG 86400 NSEC 8 2 86400 [expiry] [inception] [keytag] example.com. ...
3+
1 example.com. IN RRSIG 86400 SOA 8 2 100000 [expiry] [inception] [keytag] example.com. ...
4+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
5+
2 . IN OPT 32768
6+
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
7+
Reply to question for qname='example.com.', qtype=DS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
1 example.com. IN RRSIG 86400 SOA 8 2 100000 [expiry] [inception] [keytag] example.com. ...
2+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
3+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN NSEC3 86400 1 [flags] 1 abcd VTNQ6OCN2VKUIV3NJU14OQTAEN2MT5SL NS SOA MX RRSIG DNSKEY NSEC3PARAM
4+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
5+
2 . IN OPT 32768
6+
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
7+
Reply to question for qname='example.com.', qtype=DS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
1 example.com. IN RRSIG 86400 SOA 8 2 100000 [expiry] [inception] [keytag] example.com. ...
2+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
3+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN NSEC3 86400 1 [flags] 1 abcd VTP9NUQBEH436S7J0K8TI2A32MMKCUUL NS SOA MX RRSIG DNSKEY NSEC3PARAM
4+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
5+
2 . IN OPT 32768
6+
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
7+
Reply to question for qname='example.com.', qtype=DS

0 commit comments

Comments
 (0)