Skip to content

Commit

Permalink
Make the record representation of ALIAS match CNAME...
Browse files Browse the repository at this point in the history
...but for the name compression. This will correctly remove non-root
trailing dots from ALIAS records.

Fixes #5500, #7827
  • Loading branch information
miodvallat committed Feb 14, 2025
1 parent 88e27d5 commit af0d6ea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion pdns/dnsrecords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
4 changes: 3 additions & 1 deletion pdns/zoneparser-tng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af0d6ea

Please sign in to comment.