]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth 2136: match autosplit TXT correctly 11738/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 1 Jul 2022 10:24:13 +0000 (12:24 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 1 Jul 2022 11:15:50 +0000 (13:15 +0200)
modules/tinydnsbackend/data
modules/tinydnsbackend/data.cdb
pdns/rfc2136handler.cc
regression-tests/tests/1dyndns-update-add-delete-txt/command
regression-tests/tests/1dyndns-update-add-delete-txt/expected_result
regression-tests/zones/test.dyndns.orig

index f8adb95c3d3b6ed08ee236b9a791cea39d69ec6a..b5120a79c73908416418a5e9e3de373622684b77 100644 (file)
@@ -20219,6 +20219,7 @@ Ztest.com:ns1.test.com.:ahu.example.com.:2005092501:28800:7200:604800:86400:3600
 +ttl.test.dyndns:127.0.0.1:3600
 :delete-add.test.dyndns:16:\034Should\040be\040gone\040after\040a\040while:3600
 :txt.test.dyndns:16:\021This\040is\040some\040text:3600
+:xautosplit.test.dyndns:16:\377They\040fixed\040up\040the\040corner\040store\040like\040it\040was\040a\040nightclub\040-\040It\047s\040permanently\040disco\040-\040Everyone\040is\040dressed\040so\040oddly\040I\040can\047t\040recognize\040them\040-\040I\040can\047t\040tell\040the\040staff\040from\040the\040customers\040-\040Baby\040check\040this\040out\054\040I\047ve\040got\040something\040to\040say\040-\040Man\054\040it\047s\040so\040loud\040in\040here\040S-\040When\040they\040stop\040the\040drum\040machine\040and\040I\040can\040think\040again\040-\040I\047ll\040remember\040what\040it\040was:3600
 @test.dyndns::host-1.test.dyndns.:10:3600
 @test.dyndns::host-2.test.dyndns.:20:3600
 Ccname1.test.dyndns:host-1.test.dyndns.:3600
index 5460277209efc0e6299c0e6564158ef252e271ba..bdaff5fd8d0e22a0a8c16c569963b2673f53991d 100644 (file)
Binary files a/modules/tinydnsbackend/data.cdb and b/modules/tinydnsbackend/data.cdb differ
index ea985b35c05ff8595935ff8fc4bf809f26fcfaea..24763517b429ff31346bb4852be51186c1655e4f 100644 (file)
@@ -1,3 +1,4 @@
+#include "dnswriter.hh"
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -398,7 +399,17 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr,
           recordsToDelete.push_back(rec);
       }
       if (rr->d_class == QClass::NONE) { // 3.4.2.4
-        if (rrType == rec.qtype && rec.getZoneRepresentation() == rr->d_content->getZoneRepresentation())
+        auto repr = rec.getZoneRepresentation();
+        if (rec.qtype == QType::TXT) {
+          DLOG(g_log<<msgPrefix<<"Adjusting TXT content from ["<<repr<<"]"<<endl);
+          auto drc = DNSRecordContent::mastermake(rec.qtype.getCode(), QClass::IN, repr);
+          auto ser = drc->serialize(rec.qname, true, true);
+          auto rc = DNSRecordContent::deserialize(rec.qname, rec.qtype.getCode(), ser);
+          repr = rc->getZoneRepresentation(true);
+          DLOG(g_log<<msgPrefix<<"Adjusted TXT content to ["<<repr<<"]"<<endl);
+        }
+        DLOG(g_log<<msgPrefix<<"Matching RR in RRset - (adjusted) representation from request=["<<repr<<"], rr->d_content->getZoneRepresentation()=["<<rr->d_content->getZoneRepresentation()<<"]"<<endl);
+        if (rrType == rec.qtype && repr == rr->d_content->getZoneRepresentation())
           recordsToDelete.push_back(rec);
         else
           rrset.push_back(rec);
index 05d1f88f2975166430d3c2e35b8d673b6c4d7257..02b50e052dee435996356038c8e302cdd42ee3be 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
 
 ## add + delete with explicit data
 
@@ -130,3 +130,19 @@ answer
 # check if the record was deleted.
 cleandig test.dyndns TXT
 
+## now remove the overly long entry that was autosplit
+
+# check that it exists now
+cleandig xautosplit.test.dyndns TXT
+
+# delete it
+cleannsupdate <<!
+server $nameserver $port
+zone test.dyndns
+update delete xautosplit.test.dyndns. TXT "They fixed up the corner store like it was a nightclub - It's permanently disco - Everyone is dressed so oddly I can't recognize them - I can't tell the staff from the customers - Baby check this out, I've got something to say - Man, it's so loud in here " "- When they stop the drum machine and I can think again - I'll remember what it was"
+send
+answer
+!
+
+# check that it is gone
+cleandig xautosplit.test.dyndns TXT
index 14b69e04ae249524964ca859d5d2374a957fc14f..802d760874cbe8bff79a428b78134e70e73959f4 100644 (file)
@@ -91,3 +91,15 @@ Answer:
 1      test.dyndns.    IN      SOA     3600    ns1.test.dyndns. ahu.example.dyndns. 2022070136 28800 7200 604800 86400
 Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
 Reply to question for qname='test.dyndns.', qtype=TXT
+0      xautosplit.test.dyndns. IN      TXT     3600    "They fixed up the corner store like it was a nightclub - It's permanently disco - Everyone is dressed so oddly I can't recognize them - I can't tell the staff from the customers - Baby check this out, I've got something to say - Man, it's so loud in here " "- When they stop the drum machine and I can think again - I'll remember what it was"
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='xautosplit.test.dyndns.', qtype=TXT
+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
+
+1      test.dyndns.    IN      SOA     3600    ns1.test.dyndns. ahu.example.dyndns. 2022070137 28800 7200 604800 86400
+Rcode: 3 (Non-Existent domain), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='xautosplit.test.dyndns.', qtype=TXT
index 3f843c591601c5b68edd2113bb035e03531efa8a..823bb035008ba74f8cb8cf5f72e81dad43df2b8f 100644 (file)
@@ -32,3 +32,6 @@ e.host                        IN      A       1.1.1.1
 
 sub                            IN NS ns1.test.dyndns.
 sub                            IN NS ns2.test.dyndns.
+
+; unlike other records in this zone, the record below will actually disappear during the 1dyndns-update-add-delete-txt test
+xautosplit       IN TXT "They fixed up the corner store like it was a nightclub - It's permanently disco - Everyone is dressed so oddly I can't recognize them - I can't tell the staff from the customers - Baby check this out, I've got something to say - Man, it's so loud in here - When they stop the drum machine and I can think again - I'll remember what it was"