]> granicus.if.org Git - pdns/commitdiff
tinydnsbackend updates: add ignore-bogus-records setting; update tai offset; remove...
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 5 Oct 2012 11:26:00 +0000 (11:26 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 5 Oct 2012 11:26:00 +0000 (11:26 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2762 d19b8d6e-7fed-0310-83ef-9ca221ded41b

modules/tinydnsbackend/tinydnsbackend.cc
modules/tinydnsbackend/tinydnsbackend.hh
pdns/Makefile.am
pdns/docs/pdns.xml

index 9ac79423a3d0ceadf168beebc449ebff8e3928db..f65afbb6e92ce28204bdd3603d6f70479188cb4a 100644 (file)
@@ -1,7 +1,6 @@
 #include "tinydnsbackend.hh"
 #include "pdns/lock.hh"
 #include <cdb.h>
-#include <pdns/dnslabel.hh>
 #include <pdns/misc.hh>
 #include <pdns/iputils.hh>
 #include <pdns/dnspacket.hh>
@@ -60,6 +59,7 @@ TinyDNSBackend::TinyDNSBackend(const string &suffix)
        setArgPrefix("tinydns"+suffix);
        d_suffix = suffix;
        d_locations = mustDo("locations");
+       d_ignorebogus = mustDo("ignore-bogus-records");
        d_taiepoch = 4611686018427387904ULL + getArgAsNum("tai-adjust");
 }
 
@@ -131,7 +131,7 @@ void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains) {
        d_cdbReader->searchAll();
        DNSResourceRecord rr;
 
-       while (get(rr)) {
+       while (get(rr)) { 
                if (rr.qtype.getCode() == QType::SOA) {
                        SOAData sd;
                        fillSOAData(rr.content, sd);
@@ -151,8 +151,7 @@ void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains) {
 
 bool TinyDNSBackend::list(const string &target, int domain_id) {
        d_isAxfr=true;
-       DNSLabel l(target.c_str());
-       string key = l.binary();
+       string key = simpleCompress(target);
        d_cdbReader=new CDB(getArg("dbfile"));
        return d_cdbReader->searchSuffix(key);
 }
@@ -161,11 +160,10 @@ void TinyDNSBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket
        d_isAxfr = false;
        string queryDomain = toLowerCanonic(qdomain);
 
-       DNSLabel l(queryDomain.c_str());
-       string key=l.binary();
+       string key=simpleCompress(queryDomain);
 
        DLOG(L<<Logger::Debug<<backendname<<"[lookup] query for qtype ["<<qtype.getName()<<"] qdomain ["<<qdomain<<"]"<<endl);
-//     DLOG(L<<Logger::Debug<<"[lookup] key ["<<makeHexDump(key)<<"]"<<endl);
+       DLOG(L<<Logger::Debug<<"[lookup] key ["<<makeHexDump(key)<<"]"<<endl);
 
        d_isWildcardQuery = false;
        if (key[0] == '\001' && key[1] == '\052') {
@@ -216,42 +214,41 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr)
                PacketReader pr(bytes);
                rr.qtype = QType(pr.get16BitInt());
 
-               char locwild = pr.get8BitInt();
-               if(locwild != '\075' && (locwild == '\076' || locwild == '\053')) {
-                       if (d_isAxfr && d_locations) { // We skip records with a location in AXFR, unless we disable locations.
-                               continue;
-                       }
-                       char recloc[2];
-                       recloc[0] = pr.get8BitInt();
-                       recloc[1] = pr.get8BitInt();
-                       
-                       if (d_locations) {
-                               bool foundLocation = false;
-                               vector<string> locations = getLocations();
-                               while(locations.size() > 0) {
-                                       string locId = locations.back();
-                                       locations.pop_back();
-       
-                                       if (recloc[0] == locId[0] && recloc[1] == locId[1]) {
-                                               foundLocation = true;
-                                               break;
+               if(d_isAxfr || d_qtype.getCode() == QType::ANY || rr.qtype == d_qtype) {
+                       char locwild = pr.get8BitInt();
+                       if(locwild != '\075' && (locwild == '\076' || locwild == '\053')) {
+                               if (d_isAxfr && d_locations) { // We skip records with a location in AXFR, unless we disable locations.
+                                       continue;
+                               }
+                               char recloc[2];
+                               recloc[0] = pr.get8BitInt();
+                               recloc[1] = pr.get8BitInt();
+                               
+                               if (d_locations) {
+                                       bool foundLocation = false;
+                                       vector<string> locations = getLocations();
+                                       while(locations.size() > 0) {
+                                               string locId = locations.back();
+                                               locations.pop_back();
+               
+                                               if (recloc[0] == locId[0] && recloc[1] == locId[1]) {
+                                                       foundLocation = true;
+                                                       break;
+                                               }
                                        }
+                                       if (!foundLocation) {
+                                               continue;
+                                       } 
                                }
-                               if (!foundLocation) {
-                                       continue;
-                               } 
                        }
-               }
 
-               if(d_isAxfr || d_qtype.getCode() == QType::ANY || rr.qtype == d_qtype) {
-                       
                        if (d_isAxfr && (val[2] == '\052' || val[2] == '\053' )) { // Keys are not stored with wildcard character, with AXFR we need to add that.
                                key.insert(0, 1, '\052');
                                key.insert(0, 1, '\001');
                        }
-                       DNSLabel dnsKey(key.c_str(), key.size());
-                       rr.qname = dnsKey.human();
-                       rr.qname = rr.qname.erase(rr.qname.size()-1, 1);// strip the last dot, packethandler needs this.
+                       rr.qname.clear(); 
+                       simpleExpandTo(key, 0, rr.qname);
+                       rr.qname = stripDot(rr.qname); // strip the last dot, packethandler needs this.
                        rr.domain_id=-1;
                        // 11:13.21 <@ahu> IT IS ALWAYS AUTH --- well not really because we are just a backend :-)
                        // We could actually do NSEC3-NARROW DNSSEC according to Habbie, if we do, we need to change something ehre. 
@@ -272,24 +269,33 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr)
                                        continue;
                                }
                        }
-       
-                       DNSRecord dr;
-                       dr.d_class = 1;
-                       dr.d_type = rr.qtype.getCode();
-                       dr.d_clen = val.size()-pr.d_pos;
-                       DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
-
-                       string content = drc->getZoneRepresentation();
-                       delete drc;
-                       if(rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) {
-                               vector<string>parts;
-                               stringtok(parts,content," ");
-                               rr.priority=atoi(parts[0].c_str());
-                               rr.content=content.substr(parts[0].size()+1);
-                       } else {
-                               rr.content = content;
+                       try {
+                               DNSRecord dr;
+                               dr.d_class = 1;
+                               dr.d_type = rr.qtype.getCode();
+                               dr.d_clen = val.size()-pr.d_pos;
+                               DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
+
+                               string content = drc->getZoneRepresentation();
+                               cerr<<"CONTENT: "<<content<<endl;
+                               delete drc;
+                               if(rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV) {
+                                       vector<string>parts;
+                                       stringtok(parts,content," ");
+                                       rr.priority=atoi(parts[0].c_str());
+                                       rr.content=content.substr(parts[0].size()+1);
+                               } else {
+                                       rr.content = content;
+                               }
+                       }
+                       catch (...) {
+                               if (d_ignorebogus) {
+                                       L<<Logger::Error<<backendname<<"Failed to parse record content for "<<rr.qname<<" with type "<<rr.qtype.getName()<<". Ignoring!"<<endl;
+                                       continue;
+                               } else
+                                       throw;
                        }
-                       DLOG(L<<Logger::Debug<<backendname<<"Returning ["<<rr.content<<"] for ["<<rr.qname<<"] of RecordType ["<<rr.qtype.getName()<<"]"<<endl;);
+//                     DLOG(L<<Logger::Debug<<backendname<<"Returning ["<<rr.content<<"] for ["<<rr.qname<<"] of RecordType ["<<rr.qtype.getName()<<"]"<<endl;);
                        return true;
                }
        } // end of while
@@ -308,8 +314,9 @@ public:
        void declareArguments(const string &suffix="") {
                declare(suffix, "notify-on-startup", "Tell the TinyDNSBackend to notify all the slave nameservers on startup. Default is no.", "no");
                declare(suffix, "dbfile", "Location of the cdb data file", "data.cdb");
-               declare(suffix, "tai-adjust", "This adjusts the TAI value if timestamps are used. These seconds will be added to the start point (1970) and will allow you to adjust for leap seconds. The default is 10.", "10");
+               declare(suffix, "tai-adjust", "This adjusts the TAI value if timestamps are used. These seconds will be added to the start point (1970) and will allow you to adjust for leap seconds. The default is 11.", "11");
                declare(suffix, "locations", "Enable or Disable location support in the backend. Changing the value to 'no' will make the backend ignore the locations. This then returns all records!", "yes");
+               declare(suffix, "ignore-bogus-records", "The data.cdb file might have some wront record data, this causes PowerDNS to fail, where tinydns would send out truncated data. This option makes powerdns ignore that data!", "no");
        }
 
 
index 430a8711f11f763e1d52b62e98a1ce9a4dd9d977..390c7f51432c0764a926100e3c4f323ca3a5f0d9 100644 (file)
@@ -80,7 +80,7 @@ private:
        bool d_isWildcardQuery; // Indicate if the query received was a wildcard query.
        bool d_isAxfr; // Indicate if we received a list() and not a lookup().
        bool d_locations;
-       bool d_timestamps;
+       bool d_ignorebogus;
        string d_suffix;
        
 
index 65168ba86f7259fa5e9ed58fb19eff35639ea1b0..c90bedf5033fd4bc9a86b2dbdaec5d646a10d9fc 100644 (file)
@@ -56,7 +56,7 @@ aes/aestab.c aes/aestab.h aes/brg_endian.h aes/brg_types.h aes/dns_random.cc \
 randomhelper.cc namespaces.hh nsecrecords.cc base32.cc dbdnsseckeeper.cc dnssecinfra.cc \
 dnsseckeeper.hh dnssecinfra.hh base32.hh dns.cc dnssecsigner.cc polarrsakeyinfra.cc md5.cc \
 md5.hh signingpipe.cc signingpipe.hh dnslabeltext.cc lua-pdns.cc lua-auth.cc lua-auth.hh serialtweaker.cc \
-ednssubnet.cc ednssubnet.hh cachecleaner.hh dnslabel.hh dnslabel.cc
+ednssubnet.cc ednssubnet.hh cachecleaner.hh
 
 #
 pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@  $(BOOST_SERIALIZATION_LDFLAGS)  -rdynamic
@@ -94,7 +94,7 @@ pdnssec_SOURCES=pdnssec.cc dbdnsseckeeper.cc sstuff.hh dnsparser.cc dnsparser.hh
        backends/gsql/gsqlbackend.cc \
        backends/gsql/gsqlbackend.hh backends/gsql/ssql.hh zoneparser-tng.cc \
        dynlistener.cc dns.cc randombackend.cc dnssecsigner.cc polarrsakeyinfra.cc md5.cc \
-       signingpipe.cc dnslabeltext.cc ednssubnet.cc cachecleaner.hh dnslabel.hh dnslabel.cc
+       signingpipe.cc dnslabeltext.cc ednssubnet.cc cachecleaner.hh
 
 
 pdnssec_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@  $(BOOST_PROGRAM_OPTIONS_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
@@ -135,7 +135,7 @@ nsec3dig_LDADD= -lpolarssl
 
 toysdig_SOURCES=toysdig.cc sstuff.hh dnsparser.cc dnsparser.hh dnsrecords.cc dnswriter.cc dnslabeltext.cc dnswriter.hh \
        misc.cc misc.hh rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh unix_utility.cc \
-       logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc dnslabel.cc dnslabel.hh \
+       logger.cc statbag.cc qtype.cc sillyrecords.cc nsecrecords.cc base32.cc \
        ednssubnet.cc ednssubnet.hh
 
 
index 99e1a8293414319138974a494eb495d8f374b643..c5bb4dc7929980835ed75e4bb0df10714327ead4 100644 (file)
@@ -17275,10 +17275,10 @@ VALUES (:zoneid, :ip)
           <tbody>
             <row><entry>Native</entry><entry>Yes</entry></row>
             <row><entry>Master</entry><entry>Yes</entry></row>
-             <row><entry>Slave</entry><entry>No</entry></row>
-             <row><entry>Superslave</entry><entry>No</entry></row>
-             <row><entry>Autoserial</entry><entry>No</entry></row>
-             <row><entry>DNSSEC</entry><entry>No</entry></row>
+           <row><entry>Slave</entry><entry>No</entry></row>
+           <row><entry>Superslave</entry><entry>No</entry></row>
+           <row><entry>Autoserial</entry><entry>No</entry></row>
+           <row><entry>DNSSEC</entry><entry>No</entry></row>
             <row><entry>Multiple instances</entry><entry>Yes</entry></row>
           </tbody>
          </tgroup>
@@ -17304,8 +17304,8 @@ the data.cdb files without any changes.
               <listitem>
                 <para>
 This adjusts the <ulink url="http://www.tai64.com/">TAI</ulink> value if timestamps are used.
-These seconds will be added to the start point (1970) and will allow you to adjust for leap seconds. The current default is 10, 
-<ulink url="http://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat">but as of june 30th 2012</ulink> should be 11.
+These seconds will be added to the start point (1970) and will allow you to adjust for leap seconds. The current default is 11.
+The last update was on <ulink url="http://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat">june 30th 2012</ulink>.
                 </para>
               </listitem>
             </varlistentry>
@@ -17315,7 +17315,19 @@ These seconds will be added to the start point (1970) and will allow you to adju
                 <para>Tell the TinyDNSBackend to notify all the slave nameservers on startup. This might cause broadcast storms. Default is no.</para>
               </listitem>
             </varlistentry>
-             <varlistentry>
+            <varlistentry>
+              <term>tinydns-ignore-bogus-records</term>
+              <listitem>
+                <para>
+                  The <command>tinydns-data</command> program can create data.cdb files that have bad/corrupt RDATA. 
+                  PowerDNS will crash when it tries to read that bad/corrupt data. This option (change to yes), allows you to ignore that bad RDATA 
+                  to make PowerDNS operate when bad data is in your CDB file. Be aware that the records are then ignored, where tinydns would
+                  still send out the bogus data.
+                  The option is primarily useful in master mode, as that reads all the packets in the zone to find all the SOA records.
+                </para>
+               </listitem>
+            </varlistentry>
+            <varlistentry>
               <term>tinydns-locations</term>
               <listitem>
                 <para>Enable or Disable location support in the backend. Changing the value to 'no' will make the backend ignore the locations. This then returns all records. When the setting is changed to 'no' an AXFR will also return all the records. With the setting on 'yes' an AXFR will only return records without a location.</para>