]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
incorporate review feedback
authorBob Halley <halley@dnspython.org>
Thu, 2 Dec 2021 13:33:35 +0000 (05:33 -0800)
committerBob Halley <halley@dnspython.org>
Thu, 2 Dec 2021 13:33:35 +0000 (05:33 -0800)
dns/node.py
dns/rdataset.py

index 4a750eb01d2d5659ae7154fc4c4d3d73e1ef816b..7f172dd4cdb63177f0aafed230fffdb77518831a 100644 (file)
@@ -102,7 +102,13 @@ class Node:
         """
         # Make having just one rdataset at the node fast.
         if len(self.rdatasets) > 0:
-            if rdataset.rdtype == dns.rdatatype.CNAME:
+            # We don't want adding RRSIG(CNAME) to delete CNAMEs,
+            # so we treat it as expressing "CNAME intent" for classifying
+            # the node as a CNAME node, even if we haven't added the CNAME
+            # yet.
+            if rdataset.rdtype == dns.rdatatype.CNAME or \
+               (rdataset.rdtype == dns.rdatatype.RRSIG and
+                rdataset.covers == dns.rdatatype.CNAME):
                 self.rdatasets = [rds for rds in self.rdatasets
                                   if rds.ok_for_cname()]
             else:
index e9d8fc201277959845c0894e4d09442f15dc6d74..868c1fc34a3fa01384b6e90c1f7203f3f982ea13 100644 (file)
@@ -42,12 +42,10 @@ class IncompatibleTypes(dns.exception.DNSException):
 
 
 _ok_for_cname = {
-    (dns.rdatatype.CNAME, dns.rdatatype.NONE),
-    (dns.rdatatype.RRSIG, dns.rdatatype.CNAME),
-    (dns.rdatatype.NSEC, dns.rdatatype.NONE),
-    (dns.rdatatype.RRSIG, dns.rdatatype.NSEC),
-    (dns.rdatatype.NSEC3, dns.rdatatype.NONE),
-    (dns.rdatatype.RRSIG, dns.rdatatype.NSEC3),
+    dns.rdatatype.CNAME,
+    dns.rdatatype.NSEC,   # RFC 4035 section 2.5
+    dns.rdatatype.NSEC3,  # This is not likely to happen, but not impossible!
+    dns.rdatatype.KEY,    # RFC 4035 section 2.5, RFC 3007
 }
 
 _delete_for_other_data = {
@@ -55,6 +53,7 @@ _delete_for_other_data = {
     (dns.rdatatype.RRSIG, dns.rdatatype.CNAME),
 }
 
+
 class Rdataset(dns.set.Set):
 
     """A DNS rdataset."""
@@ -339,7 +338,9 @@ class Rdataset(dns.set.Set):
 
     def ok_for_cname(self):
         """Is this rdataset compatible with a CNAME node?"""
-        return (self.rdtype, self.covers) in _ok_for_cname
+        return self.rdtype in _ok_for_cname or \
+               (self.rdtype == dns.rdatatype.RRSIG and
+                self.covers in _ok_for_cname)
 
     def ok_for_other_data(self):
         """Is this rdataset compatible with an 'other data' (i.e. not CNAME)