]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Make the record representation of ALIAS match CNAME... 15152/head
authorMiod Vallat <miod.vallat@open-xchange.com>
Thu, 13 Feb 2025 16:15:34 +0000 (17:15 +0100)
committerMiod Vallat <miod.vallat@open-xchange.com>
Fri, 14 Feb 2025 07:05:25 +0000 (08:05 +0100)
...but for the name compression. This will correctly remove non-root
trailing dots from ALIAS records.

Fixes #5500, #7827

pdns/dnsrecords.cc
pdns/pdnsutil.cc
pdns/zoneparser-tng.cc
regression-tests.nobackend/lmdb-schema-upgrade/expected_result

index e096be81ef7fed6da40ee39a97fdea52cbd84ec5..85ce9e471ef053d78352e495e5528e622c578eb5 100644 (file)
@@ -36,7 +36,10 @@ void DNSResourceRecord::setContent(const string &cont) {
     case QType::MX:
       if (content.size() >= 2 && *(content.rbegin()+1) == ' ')
         return;
-      /* Falls through. */
+      [[fallthrough]];
+#if !defined(RECURSOR)
+    case QType::ALIAS:
+#endif
     case QType::CNAME:
     case QType::DNAME:
     case QType::NS:
@@ -64,6 +67,9 @@ string DNSResourceRecord::getZoneRepresentation(bool noDot) const {
       if (*(last.rbegin()) != '.' && !noDot)
         ret << ".";
       break;
+#if !defined(RECURSOR)
+    case QType::ALIAS:
+#endif
     case QType::CNAME:
     case QType::DNAME:
     case QType::NS:
index 3a35755fd0518e06114d5719895928121a9b34ab..4ab130292ccfc54ddf039396263e461f72efc5e6 100644 (file)
@@ -1113,8 +1113,17 @@ static int listZone(const DNSName &zone) {
 
   while(di.backend->get(rr)) {
     if(rr.qtype.getCode() != 0) {
-      if ( (rr.qtype.getCode() == QType::NS || rr.qtype.getCode() == QType::SRV || rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::CNAME) && !rr.content.empty() && rr.content[rr.content.size()-1] != '.')
-       rr.content.append(1, '.');
+      switch (rr.qtype.getCode()) {
+      case QType::ALIAS:
+      case QType::CNAME:
+      case QType::MX:
+      case QType::NS:
+      case QType::SRV:
+        if (!rr.content.empty() && rr.content[rr.content.size()-1] != '.') {
+          rr.content.append(1, '.');
+        }
+        break;
+      }
 
       cout<<rr.qname<<"\t"<<rr.ttl<<"\tIN\t"<<rr.qtype.toString()<<"\t"<<rr.content<<"\n";
     }
index 1ab6c7119aaa0b2e21e353f2bf500822d12ab2c6..41bd5e5683c816a830e330c00d660efad72a49a4 100644 (file)
@@ -607,7 +607,9 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
     }
     break;
 
-
+#if !defined(RECURSOR)
+  case QType::ALIAS:
+#endif
   case QType::NS:
   case QType::CNAME:
   case QType::DNAME:
index 43243ccbb6c5202ae239d17f1514d6b765f1ca9a..8f71281b3dd1aa498d50abfd75503eadd99b2704 100644 (file)
@@ -14,7 +14,7 @@ external.example.com  120     IN      CNAME   somewhere.else.net.
 external-mail.example.com      120     IN      MX      25 server1.test.com.
 france.example.com     120     IN      NS      ns1.otherprovider.net.
 france.example.com     120     IN      NS      ns2.otherprovider.net.
-google-alias.example.com       120     IN      ALIAS   google-public-dns-a.google.com
+google-alias.example.com       120     IN      ALIAS   google-public-dns-a.google.com.
 hightype.example.com   120     IN      A       192.168.1.5
 hightype.example.com   120     IN      TYPE65534       \# 5 07ed260001
 host-0.example.com     120     IN      A       192.168.1.0
@@ -20338,7 +20338,7 @@ external.example.com    120     IN      CNAME   somewhere.else.net.
 external-mail.example.com      120     IN      MX      25 server1.test.com.
 france.example.com     120     IN      NS      ns1.otherprovider.net.
 france.example.com     120     IN      NS      ns2.otherprovider.net.
-google-alias.example.com       120     IN      ALIAS   google-public-dns-a.google.com
+google-alias.example.com       120     IN      ALIAS   google-public-dns-a.google.com.
 hightype.example.com   120     IN      A       192.168.1.5
 hightype.example.com   120     IN      TYPE65534       \# 5 07ed260001
 host-0.example.com     120     IN      A       192.168.1.0