@@ -411,7 +411,7 @@ static string canonic(string ret)
411
411
/* * THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedence matching
412
412
This function adds a record to a domain with a certain id.
413
413
Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
414
- void Bind2Backend::insert (shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed)
414
+ void Bind2Backend::insert (shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth )
415
415
{
416
416
BB2DomainInfo bb2 = stage->id_zone_map [id];
417
417
Bind2DNSRecord bdr;
@@ -443,7 +443,9 @@ void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu,
443
443
bdr.nsec3hash = hashed;
444
444
// cerr<<"qname '"<<bdr.qname<<"' nsec3hash '"<<hashed<<"' qtype '"<<qtype.getName()<<"'"<<endl;
445
445
446
- if (!qtype.getCode ()) // Set auth on empty non-terminals
446
+ if (auth) // Set auth on empty non-terminals
447
+ bdr.auth =*auth;
448
+ else
447
449
bdr.auth =true ;
448
450
449
451
if (bdr.qtype == QType::MX || bdr.qtype == QType::SRV) {
@@ -597,32 +599,41 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr<State> stage, int id, bool nse
597
599
{
598
600
BB2DomainInfo bb2 = stage->id_zone_map [id];
599
601
600
- bool doent=true ;
601
- set<string> qnames, nonterm;
602
- string qname, shorter, hashed;
602
+ bool auth, doent=true ;
603
+ set<string> qnames;
604
+ map<string, bool > nonterm;
605
+ string shorter, hashed;
603
606
604
607
uint32_t maxent = ::arg ().asNum (" max-ent-entries" );
605
608
606
609
BOOST_FOREACH (const Bind2DNSRecord& bdr, *bb2.d_records )
607
- if (bdr.auth && (bdr.qtype != QType::RRSIG))
608
- qnames.insert (labelReverse (bdr.qname ));
610
+ qnames.insert (labelReverse (bdr.qname ));
609
611
610
- BOOST_FOREACH (const string& qname, qnames)
611
- {
612
- shorter=qname;
612
+ BOOST_FOREACH (const Bind2DNSRecord& bdr, *bb2.d_records ) {
613
+ shorter=labelReverse (bdr.qname );
614
+
615
+ if (!bdr.auth && bdr.qtype == QType::NS)
616
+ auth=(!nsec3zone || !ns3pr.d_flags );
617
+ else
618
+ auth=bdr.auth ;
613
619
614
620
while (chopOff (shorter))
615
621
{
616
622
if (!qnames.count (shorter))
617
623
{
618
624
if (!(maxent))
619
625
{
620
- L<<Logger::Error<<" Zone '" <<bb2.d_name <<" ' has too many empty non terminals." <<endl;
626
+ if (!::arg ().asNum (" max-ent-entries" ))
627
+ L<<Logger::Error<<" Zone '" <<bb2.d_name <<" ' has too many empty non terminals." <<endl;
621
628
doent=false ;
622
629
break ;
623
630
}
624
- nonterm.insert (shorter);
625
- --maxent;
631
+
632
+ if (!nonterm.count (shorter)) {
633
+ nonterm.insert (pair<string, bool >(shorter, auth));
634
+ --maxent;
635
+ } else if (auth)
636
+ nonterm[shorter]=true ;
626
637
}
627
638
}
628
639
if (!doent)
@@ -634,12 +645,13 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr<State> stage, int id, bool nse
634
645
rr.content =" " ;
635
646
rr.ttl =0 ;
636
647
rr.priority =0 ;
637
- BOOST_FOREACH (const string& qname, nonterm)
648
+ pair<string, bool > nt;
649
+ BOOST_FOREACH (nt, nonterm)
638
650
{
639
- rr.qname =qname +" ." +bb2.d_name +" ." ;
651
+ rr.qname =nt. first +" ." +bb2.d_name +" ." ;
640
652
if (nsec3zone)
641
653
hashed=toLower (toBase32Hex (hashQNameWithSalt (ns3pr.d_iterations , ns3pr.d_salt , rr.qname )));
642
- insert (stage, id, rr.qname , rr.qtype , rr.content , rr.ttl , rr.priority , hashed);
654
+ insert (stage, id, rr.qname , rr.qtype , rr.content , rr.ttl , rr.priority , hashed, &nt. second );
643
655
}
644
656
}
645
657
0 commit comments