Skip to content

Commit

Permalink
pdnsutil {add-record,delete-rrset}: Don't append ZONE if NAME ends wi…
Browse files Browse the repository at this point in the history
…th .

If a NAME ends with a . it is to be understood as an absolute name and
appending the zone is not intuitive then.

Note this changes behaviour for calls like:

	pdnsutil --config-dir=configs/auth add-record example.net . NS 1.2.3.4

which added the NS record to the zone's apex before and is likely an
error now.

Closes: PowerDNS#8595
  • Loading branch information
ukleinek committed Dec 18, 2024
1 parent 2a1e55f commit ff14c7f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1597,10 +1597,13 @@ static int addOrReplaceRecord(bool addOrReplace, const vector<string>& cmds) {
vector<DNSResourceRecord> newrrs;
DNSName zone(cmds.at(1));
DNSName name;
if (cmds.at(2) == "@")
if (cmds.at(2) == "@") {
name=zone;
else
} else if (isCanonical(cmds.at(2))) {
name = DNSName(cmds.at(2));
} else {
name = DNSName(cmds.at(2)) + zone;
}

rr.qtype = DNSRecordContent::TypeToNumber(cmds.at(3));
rr.ttl = ::arg().asNum("default-ttl");
Expand Down Expand Up @@ -1735,10 +1738,13 @@ static int deleteRRSet(const std::string& zone_, const std::string& name_, const
}

DNSName name;
if(name_=="@")
if (name_=="@") {
name=zone;
else
} else if (isCanonical(name_)) {
name = DNSName(name_);
} else {
name=DNSName(name_)+zone;
}

QType qt(QType::chartocode(type_.c_str()));
di.backend->startTransaction(zone, -1);
Expand Down

0 comments on commit ff14c7f

Please sign in to comment.