]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rfc2136: ignore case when checking PTR/MX/SRV content for duplicates
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 27 Aug 2019 18:39:38 +0000 (20:39 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 27 Aug 2019 18:39:47 +0000 (20:39 +0200)
pdns/rfc2136handler.cc
regression-tests/tests/1dyndns-content-casemix/command [new file with mode: 0755]
regression-tests/tests/1dyndns-content-casemix/description [new file with mode: 0644]
regression-tests/tests/1dyndns-content-casemix/expected_result [new file with mode: 0644]
regression-tests/tests/1dyndns-content-casemix/skip.nodyndns [new file with mode: 0644]

index 1797d3080899509a8fd49ab59a6e858454c526c1..6e914a2c311ee1291ee14afac30ea7e3bb9f0333 100644 (file)
@@ -216,9 +216,18 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr,
       } else {
         int updateTTL=0;
         foundRecord = false;
+        bool lowerCase = false;
+        if (rrType.getCode() == QType::PTR ||
+            rrType.getCode() == QType::MX ||
+            rrType.getCode() == QType::SRV) {
+          lowerCase = true;
+        }
+        string content = rr->d_content->getZoneRepresentation();
+        if (lowerCase) content = toLower(content);
         for (auto& i : rrset) {
-          string content = rr->d_content->getZoneRepresentation();
-          if (rrType == i.qtype.getCode() && i.getZoneRepresentation() == content) {
+          string icontent = i.getZoneRepresentation();
+          if (lowerCase) icontent = toLower(icontent);
+          if (rrType == i.qtype.getCode() && icontent == content) {
             foundRecord=true;
             if (i.ttl != rr->d_ttl)  {
               i.ttl = rr->d_ttl;
diff --git a/regression-tests/tests/1dyndns-content-casemix/command b/regression-tests/tests/1dyndns-content-casemix/command
new file mode 100755 (executable)
index 0000000..0dcba16
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+echo == Verify RRset absence
+cleandig ptr1.test.dyndns PTR
+
+echo
+echo == Add PTR
+cleannsupdate <<!
+server $nameserver $port
+zone test.dyndns
+update add ptr1.test.dyndns. 3600 PTR host-2.test.dyndns.
+send
+answer
+!
+
+echo
+echo == Verify PTR presence
+cleandig ptr1.test.dyndns PTR
+
+echo
+echo == Add the PTR again
+cleannsupdate <<!
+server $nameserver $port
+zone test.dyndns
+update add ptr1.test.dyndns. 3600 PTR HOST-2.test.dyndns.
+send
+answer
+!
+
+echo
+echo == Verify that we have one PTR
+cleandig ptr1.test.dyndns PTR
+
+echo
+echo == Clean up
+cleannsupdate <<!
+server $nameserver $port
+zone test.dyndns
+update delete ptr1.test.dyndns. PTR
+send
+answer
+!
+
+echo
+echo == Verify RRset absence
+cleandig ptr1.test.dyndns PTR
diff --git a/regression-tests/tests/1dyndns-content-casemix/description b/regression-tests/tests/1dyndns-content-casemix/description
new file mode 100644 (file)
index 0000000..50f9b8f
--- /dev/null
@@ -0,0 +1 @@
+Make sure duplicate content is disallowed when case is mixed.
diff --git a/regression-tests/tests/1dyndns-content-casemix/expected_result b/regression-tests/tests/1dyndns-content-casemix/expected_result
new file mode 100644 (file)
index 0000000..6f0405b
--- /dev/null
@@ -0,0 +1,43 @@
+== Verify RRset absence
+1      test.dyndns.    IN      SOA     3600    ns1.test.dyndns. ahu.example.dyndns. 2019082709 28800 7200 604800 86400
+Rcode: 3 (Non-Existent domain), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='ptr1.test.dyndns.', qtype=PTR
+
+== Add PTR
+Answer:
+;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id]
+;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0
+;; ZONE SECTION:
+;test.dyndns.                  IN      SOA
+
+
+== Verify PTR presence
+0      ptr1.test.dyndns.       IN      PTR     3600    host-2.test.dyndns.
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='ptr1.test.dyndns.', qtype=PTR
+
+== Add the PTR again
+Answer:
+;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id]
+;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0
+;; ZONE SECTION:
+;test.dyndns.                  IN      SOA
+
+
+== Verify that we have one PTR
+0      ptr1.test.dyndns.       IN      PTR     3600    host-2.test.dyndns.
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='ptr1.test.dyndns.', qtype=PTR
+
+== Clean up
+Answer:
+;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: [id]
+;; flags: qr aa; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0
+;; ZONE SECTION:
+;test.dyndns.                  IN      SOA
+
+
+== Verify RRset absence
+1      test.dyndns.    IN      SOA     3600    ns1.test.dyndns. ahu.example.dyndns. 2019082711 28800 7200 604800 86400
+Rcode: 3 (Non-Existent domain), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='ptr1.test.dyndns.', qtype=PTR
diff --git a/regression-tests/tests/1dyndns-content-casemix/skip.nodyndns b/regression-tests/tests/1dyndns-content-casemix/skip.nodyndns
new file mode 100644 (file)
index 0000000..81c071b
--- /dev/null
@@ -0,0 +1 @@
+Skip this test if the backend does not support dyndns/rfc2136