]> granicus.if.org Git - pdns/commitdiff
implement suggestion of ticket 442, export-etc-hosts-suffix
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 1 Apr 2012 15:59:57 +0000 (15:59 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 1 Apr 2012 15:59:57 +0000 (15:59 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2544 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/reczones.cc

index 346da3999741e5ff824309a9476eb3af185280bd..43928239bbdca9c1f9afe6faf296bcc14e2483c0 100644 (file)
@@ -2009,7 +2009,7 @@ int main(int argc, char **argv)
     ::arg().set("forward-zones-recurse", "Zones for which we forward queries with recursion bit, comma separated domain=ip pairs")="";
     ::arg().set("forward-zones-file", "File with (+)domain=ip pairs for forwarding")="";
     ::arg().set("export-etc-hosts", "If we should serve up contents from /etc/hosts")="off";
-    // ::arg().set("export-etc-hosts-search-suffix", "Also serve up the contents of /etc/hosts with this suffix")="";
+    ::arg().set("export-etc-hosts-search-suffix", "Also serve up the contents of /etc/hosts with this suffix")="";
     ::arg().set("etc-hosts-file", "Path to 'hosts' file")="/etc/hosts";
     ::arg().set("serve-rfc1918", "If we should be authoritative for RFC 1918 private IP space")="";
     ::arg().set("auth-can-lower-ttl", "If we follow RFC 2181 to the letter, an authoritative server can lower the TTL of NS records")="off";
index 549bef43d7c8954e7446d5a759cc7b1c0773319e..3ab2312dc692ba08ba1384878536c31f7f2bada7 100644 (file)
@@ -389,6 +389,7 @@ SyncRes::domainmap_t* parseAuthAndForwards()
       L<<Logger::Warning<<"Could not open /etc/hosts for reading"<<endl;
     }
     else {
+      string searchSuffix = ::arg()["export-etc-hosts-search-suffix"];
       string::size_type pos;
       while(getline(ifs,line)) {
        pos=line.find('#');
@@ -402,8 +403,15 @@ SyncRes::domainmap_t* parseAuthAndForwards()
        if(parts[0].find(':')!=string::npos)
          continue;
        
-       for(unsigned int n=1; n < parts.size(); ++n)
+       for(unsigned int n=1; n < parts.size(); ++n) {
          makeNameToIPZone(newMap, parts[n], parts[0]);
+         if(!searchSuffix.empty()) {
+           string canonic=toCanonic(searchSuffix, parts[n]);
+           if(canonic != parts[n]) {
+             makeNameToIPZone(newMap, canonic, parts[0]);
+            }
+          }
+        }
        makeIPToNamesZone(newMap, parts);
       }
     }