From: Bob Halley Date: Thu, 12 Nov 2009 18:39:14 +0000 (+0900) Subject: present() did not add a zero TTL if its argument was a single rdata X-Git-Tag: v1.8.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff64ce87300903a843ab13a2b4ff1ab6633371ba;p=thirdparty%2Fdnspython.git present() did not add a zero TTL if its argument was a single rdata --- diff --git a/ChangeLog b/ChangeLog index a28042fc..6b9cc500 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-13 Bob Halley + + * dns/update.py (Update::present): A zero TTL was not added if + present() was called with a single rdata, causing _add() to be + unhappy. Thanks to Eugene Kim for reporting the problem and + submitting a patch. + 2009-11-13 Bob Halley * dns/entropy.py: Use os.urandom() if present. Don't seed until diff --git a/dns/update.py b/dns/update.py index f54a51be..5bd289f7 100644 --- a/dns/update.py +++ b/dns/update.py @@ -26,7 +26,7 @@ class Update(dns.message.Message): def __init__(self, zone, rdclass=dns.rdataclass.IN, keyring=None, keyname=None): """Initialize a new DNS Update object. - + @param zone: The zone which is being updated. @type zone: A dns.name.Name or string @param rdclass: The class of the zone; defaults to dns.rdataclass.IN. @@ -72,7 +72,7 @@ class Update(dns.message.Message): argument is the section to add to. The third argument is always a name. The other arguments can be: - - rdataset... + - rdataset... - ttl, rdata... @@ -109,7 +109,7 @@ class Update(dns.message.Message): """Add records. The first argument is always a name. The other arguments can be: - - rdataset... + - rdataset... - ttl, rdata... @@ -120,9 +120,9 @@ class Update(dns.message.Message): """Delete records. The first argument is always a name. The other arguments can be: - - I{nothing} - - - rdataset... + - I{nothing} + + - rdataset... - rdata... @@ -162,8 +162,8 @@ class Update(dns.message.Message): def replace(self, name, *args): """Replace records. The first argument is always a name. The other arguments can be: - - - rdataset... + + - rdataset... - ttl, rdata... @@ -171,7 +171,7 @@ class Update(dns.message.Message): Note that if you want to replace the entire node, you should do a delete of the name followed by one or more calls to add.""" - + self._add(True, self.authority, name, *args) def present(self, name, *args): @@ -179,13 +179,13 @@ class Update(dns.message.Message): or specific rdataset) exists as a prerequisite to the execution of the update. The first argument is always a name. The other arguments can be: - - - rdataset... + + - rdataset... - rdata... - rdtype, string...""" - + if isinstance(name, (str, unicode)): name = dns.name.from_text(name, None) if len(args) == 0: @@ -196,7 +196,7 @@ class Update(dns.message.Message): elif isinstance(args[0], dns.rdataset.Rdataset) or \ isinstance(args[0], dns.rdata.Rdata) or \ len(args) > 1: - if len(args) > 1: + if not isinstance(args[0], dns.rdata.Rdataset): # Add a 0 TTL args = list(args) args.insert(0, 0) @@ -218,7 +218,7 @@ class Update(dns.message.Message): name = dns.name.from_text(name, None) if rdtype is None: rrset = self.find_rrset(self.answer, name, - dns.rdataclass.NONE, dns.rdatatype.ANY, + dns.rdataclass.NONE, dns.rdatatype.ANY, dns.rdatatype.NONE, None, True, True) else: