Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdnsutil {add-record,delete-rrset}: Don't append ZONE if NAME ends with . #14984

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guides/basic-database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Now, let's add a zone and some records::
$ sudo -u pdns pdnsutil create-zone example.com ns1.example.com
Creating empty zone 'example.com'
Also adding one NS record
$ sudo -u pdns pdnsutil add-record example.com '' MX '25 mail.example.com'
$ sudo -u pdns pdnsutil add-record example.com @ MX '25 mail.example.com'
New rrset:
example.com. 3005 IN MX 25 mail.example.com
$ sudo -u pdns pdnsutil add-record example.com. www A 192.0.2.1
Expand Down
1 change: 1 addition & 0 deletions docs/manpages/pdnsutil.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ ZONE MANIPULATION COMMANDS
add-record *ZONE* *NAME* *TYPE* [*TTL*] *CONTENT*
Add one or more records of *NAME* and *TYPE* to *ZONE* with *CONTENT*
and optional *TTL*. If *TTL* is not set, default will be used.
Use @ as name to add a record to the apex.
add-autoprimary *IP* *NAMESERVER* [*ACCOUNT*]
Add a autoprimary entry into the backend. This enables receiving zone updates from other servers.
remove-autoprimary *IP* *NAMESERVER*
Expand Down
4 changes: 1 addition & 3 deletions pdns/misc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,7 @@ pair<string, string> splitField(const string& inp, char sepa);

inline bool isCanonical(const string& qname)
{
if(qname.empty())
return false;
return qname[qname.size()-1]=='.';
return boost::ends_with(qname, ".");
}

inline DNSName toCanonic(const DNSName& zone, const string& qname)
Expand Down
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
6 changes: 3 additions & 3 deletions regression-tests.auth-py/test_GSSTSIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def setUpClass(cls):
os.system("$PDNSUTIL --config-dir=configs/auth create-zone noacceptor.net")
os.system("$PDNSUTIL --config-dir=configs/auth create-zone wrongacceptor.net")

os.system("$PDNSUTIL --config-dir=configs/auth add-record example.net . SOA 3600 'ns1.example.net otto.example.net 2022010403 10800 3600 604800 3600'")
os.system("$PDNSUTIL --config-dir=configs/auth add-record noacceptor.net . SOA 3600 'ns1.noacceptor.net otto.example.net 2022010403 10800 3600 604800 3600'")
os.system("$PDNSUTIL --config-dir=configs/auth add-record wrongacceptor.net . SOA 3600 'ns1.wrongacceptor.net otto.example.net 2022010403 10800 3600 604800 3600'")
os.system("$PDNSUTIL --config-dir=configs/auth add-record example.net @ SOA 3600 'ns1.example.net otto.example.net 2022010403 10800 3600 604800 3600'")
os.system("$PDNSUTIL --config-dir=configs/auth add-record noacceptor.net @ SOA 3600 'ns1.noacceptor.net otto.example.net 2022010403 10800 3600 604800 3600'")
os.system("$PDNSUTIL --config-dir=configs/auth add-record wrongacceptor.net @ SOA 3600 'ns1.wrongacceptor.net otto.example.net 2022010403 10800 3600 604800 3600'")

os.system("$PDNSUTIL --config-dir=configs/auth set-meta example.net GSS-ACCEPTOR-PRINCIPAL DNS/[email protected]")
os.system("$PDNSUTIL --config-dir=configs/auth set-meta wrongacceptor.net GSS-ACCEPTOR-PRINCIPAL DNS/[email protected]")
Expand Down
Loading