]> granicus.if.org Git - pdns/commitdiff
Bind: Added 'ignore' option for non-zone domains.
authorPavel Boldin <boldin.pavel@gmail.com>
Sat, 11 May 2013 15:00:44 +0000 (19:00 +0400)
committerPavel Boldin <boldin.pavel@gmail.com>
Fri, 6 Sep 2013 11:36:23 +0000 (15:36 +0400)
Now having non-zone record in BIND-type zone file will cause
pdns to ignore only this record, not the whole domain.

pdns/backends/bind/bindbackend2.cc
pdns/backends/bind/bindbackend2.hh

index 9d6a4305bd7c111148834e3ccec256717eecb487..a342660bad9fe481b06b254a91ce0d47b91ca681 100644 (file)
@@ -411,7 +411,7 @@ static string canonic(string ret)
 /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedence matching
     This function adds a record to a domain with a certain id. 
     Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
-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)
+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, const bool ignore_non_zone)
 {
   BB2DomainInfo bb2 = stage->id_zone_map[id];
   Bind2DNSRecord bdr;
@@ -425,8 +425,15 @@ void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu,
     bdr.qname.clear();
   else if(bdr.qname.length() > bb2.d_name.length() && dottedEndsOn(bdr.qname, bb2.d_name))
     bdr.qname.resize(bdr.qname.length() - (bb2.d_name.length() + 1));
-  else
-    throw PDNSException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'");
+  else {
+    string msg = "Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'";
+    if(ignore_non_zone) {
+        L<<Logger::Warning<<msg<< " ignored" << endl;
+        return;
+    }
+    else
+      throw PDNSException(msg);
+  }
 
   bdr.qname.swap(bdr.qname);
 
@@ -639,7 +646,7 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr<State> stage, int id, bool nse
     rr.qname=qname+"."+bb2.d_name+".";
     if(nsec3zone)
       hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname));
-    insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
+    insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, false);
   }
 }
 
index 36a2769c847df048d800f7e502520adcd91c8abe..5d30c47005ecf871f99d1ed32feb59c0f1539816 100644 (file)
@@ -173,7 +173,7 @@ public:
     id_zone_map_t id_zone_map;
   };
 
-  static void insert(shared_ptr<State> stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string());  
+  static void insert(shared_ptr<State> stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), const bool ignore_non_zone = true);  
   void rediscover(string *status=0);
 
   bool isMaster(const string &name, const string &ip);