@@ -492,6 +492,8 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
492
492
DNSSECKeeper dk;
493
493
dk.clearCaches (target);
494
494
bool securedZone = dk.isSecuredZone (target);
495
+ bool presignedZone = dk.isPresigned (target);
496
+
495
497
if (dk.getNSEC3PARAM (target, &ns3pr, &narrow)) {
496
498
NSEC3Zone=true ;
497
499
if (narrow) {
@@ -642,12 +644,17 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
642
644
/* now write all other records */
643
645
644
646
string keyname;
647
+ set<string> ns3rrs;
645
648
DTime dt;
646
649
dt.set ();
647
650
int records=0 ;
648
651
while (sd.db ->get (rr)) {
649
- if (rr.qtype .getCode () == QType::RRSIG)
652
+ if (rr.qtype .getCode () == QType::RRSIG) {
653
+ RRSIGRecordContent rrc (rr.content );
654
+ if (presignedZone && rrc.d_type == QType::NSEC3)
655
+ ns3rrs.insert (fromBase32Hex (makeRelative (rr.qname , target)));
650
656
continue ;
657
+ }
651
658
652
659
// only skip the DNSKEY if direct-dnskey is enabled, to avoid changing behaviour
653
660
// when it is not enabled.
@@ -660,7 +667,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
660
667
keyname = NSEC3Zone ? hashQNameWithSalt (ns3pr.d_iterations , ns3pr.d_salt , rr.qname ) : labelReverse (rr.qname );
661
668
NSECXEntry& ne = nsecxrepo[keyname];
662
669
ne.d_ttl = sd.default_ttl ;
663
- ne.d_auth = (ne.d_auth || rr.auth || (NSEC3Zone && !ns3pr.d_flags ));
670
+ ne.d_auth = (ne.d_auth || rr.auth || (NSEC3Zone && ( !ns3pr.d_flags || (presignedZone && ns3pr. d_flags )) ));
664
671
if (rr.qtype .getCode ()) {
665
672
ne.d_set .insert (rr.qtype .getCode ());
666
673
}
@@ -697,7 +704,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
697
704
if (securedZone) {
698
705
if (NSEC3Zone) {
699
706
for (nsecxrepo_t ::const_iterator iter = nsecxrepo.begin (); iter != nsecxrepo.end (); ++iter) {
700
- if (iter->second .d_auth ) {
707
+ if (iter->second .d_auth && (!presignedZone || !ns3pr. d_flags || ns3rrs. count (iter-> first )) ) {
701
708
NSEC3RecordContent n3rc;
702
709
n3rc.d_set = iter->second .d_set ;
703
710
if (n3rc.d_set .size () && (n3rc.d_set .size () != 1 || !n3rc.d_set .count (QType::NS)))
@@ -710,7 +717,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
710
717
inext++;
711
718
if (inext == nsecxrepo.end ())
712
719
inext = nsecxrepo.begin ();
713
- while (!( inext->second .d_auth ) && inext != iter)
720
+ while ((! inext->second .d_auth || (presignedZone && ns3pr. d_flags && !ns3rrs. count (inext-> first ))) && inext != iter)
714
721
{
715
722
inext++;
716
723
if (inext == nsecxrepo.end ())
0 commit comments