]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Only add PTR records for the canonical hostname
authorFred Morcos <fred.morcos@open-xchange.com>
Fri, 3 Jun 2022 10:48:39 +0000 (12:48 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 13 Jun 2022 12:24:24 +0000 (14:24 +0200)
pdns/recursordist/test-reczones-helpers.cc
pdns/reczones-helpers.cc

index f089c7cb0f341fcc4b112a7934fa94abcd368025..aea3759bfe08ad4863353d8828a1af31aab4400c 100644 (file)
@@ -72,7 +72,6 @@ struct Fixture
         DNSRecord("1.0.168.192.in-addr.arpa", makeLocalhostDRC(), QType::NS),
         DNSRecord("1.0.168.192.in-addr.arpa", makeLocalhostRootDRC(), QType::SOA),
         DNSRecord("1.0.168.192.in-addr.arpa", makePtrDRC("foo."), QType::PTR),
-        DNSRecord("1.0.168.192.in-addr.arpa", makePtrDRC("bar."), QType::PTR),
       });
     addDomainMapFixtureEntry("baz", QType::A, "192.168.0.2");
     addDomainMapFixtureEntry(
@@ -108,7 +107,6 @@ struct Fixture
         DNSRecord("b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makeLocalhostDRC(), QType::NS),
         DNSRecord("b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makeLocalhostRootDRC(), QType::SOA),
         DNSRecord("b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makePtrDRC("foo6."), QType::PTR),
-        DNSRecord("b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makePtrDRC("bar6."), QType::PTR),
       });
 
     addDomainMapFixtureEntry("localhost", QType::AAAA, "::1");
@@ -119,7 +117,6 @@ struct Fixture
         DNSRecord("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", makeLocalhostDRC(), QType::NS),
         DNSRecord("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", makeLocalhostRootDRC(), QType::SOA),
         DNSRecord("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", makePtrDRC("localhost."), QType::PTR),
-        DNSRecord("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", makePtrDRC("self."), QType::PTR),
       });
 
     addDomainMapFixtureEntry("some", QType::AAAA, "2001:db8::567:89ac");
@@ -131,8 +128,6 @@ struct Fixture
         DNSRecord("c.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makeLocalhostDRC(), QType::NS),
         DNSRecord("c.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makeLocalhostRootDRC(), QType::SOA),
         DNSRecord("c.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makePtrDRC("some.address.somewhere."), QType::PTR),
-        DNSRecord("c.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makePtrDRC("some."), QType::PTR),
-        DNSRecord("c.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", makePtrDRC("some.address."), QType::PTR),
       });
   }
 
index c71d2db1ab84ae76bed31976ebde99292a7b2051..8f613ac92fed76c504429897ad8604e04c419a91 100644 (file)
@@ -72,7 +72,7 @@ static void addToDomainMap(SyncRes::domainmap_t& newMap,
 
 static void makeNameToIPZone(SyncRes::domainmap_t& newMap,
                              const DNSName& hostname,
-                             const ComboAddress& addr,
+                             const ComboAddress& address,
                              Logr::log_t log)
 {
   DNSRecord dr;
@@ -80,33 +80,30 @@ static void makeNameToIPZone(SyncRes::domainmap_t& newMap,
 
   SyncRes::AuthDomain ad = makeSOAAndNSNodes(dr, "localhost.");
 
-  auto recType = addr.isIPv6() ? QType::AAAA : QType::A;
+  auto recType = address.isIPv6() ? QType::AAAA : QType::A;
   dr.d_type = recType;
-  dr.d_content = DNSRecordContent::mastermake(recType, 1, addr.toStringNoInterface());
+  dr.d_content = DNSRecordContent::mastermake(recType, 1, address.toStringNoInterface());
   ad.d_records.insert(dr);
 
   addToDomainMap(newMap, ad, dr.d_name, log);
 }
 
 static void makeIPToNamesZone(SyncRes::domainmap_t& newMap,
-                              const ComboAddress& addr,
-                              const std::vector<std::string>& parts,
+                              const ComboAddress& address,
+                              const std::string& canonicalHostname,
                               Logr::log_t log)
 {
   DNSRecord dr;
-  dr.d_name = DNSName(addr.toStringReversed());
-  dr.d_name.appendRawLabel(addr.isIPv4() ? "in-addr" : "ip6");
+  dr.d_name = DNSName(address.toStringReversed());
+  dr.d_name.appendRawLabel(address.isIPv4() ? "in-addr" : "ip6");
   dr.d_name.appendRawLabel("arpa");
 
   SyncRes::AuthDomain ad = makeSOAAndNSNodes(dr, DNSName("localhost."));
 
-  // Go over the hostname and aliases (parts[1], parts[2], etc...) and add PTR entries for
-  // reverse lookups.
+  // Add a PTR entry for the primary name for reverse lookups.
   dr.d_type = QType::PTR;
-  for (auto name = parts.cbegin() + 1; name != parts.cend(); ++name) {
-    dr.d_content = DNSRecordContent::mastermake(QType::PTR, 1, DNSName(*name).toString());
-    ad.d_records.insert(dr);
-  }
+  dr.d_content = DNSRecordContent::mastermake(QType::PTR, 1, DNSName(canonicalHostname).toString());
+  ad.d_records.insert(dr);
 
   addToDomainMap(newMap, ad, dr.d_name, log, false, true);
 }
@@ -148,8 +145,8 @@ void addForwardAndReverseLookupEntries(SyncRes::domainmap_t& newMap,
     }
   }
 
-  // Add entries for reverse lookups.
-  makeIPToNamesZone(newMap, address, parts, log);
+  // Add entries for the primary name for reverse lookups.
+  makeIPToNamesZone(newMap, address, parts[1], log);
 }
 
 bool parseEtcHostsLine(std::vector<std::string>& parts, std::string& line)