Browse Source

[2439] Invalid zone data isn't protocol error

Use separate error message and exception for the case when received zone
data doesn't pass basic validation.
Michal 'vorner' Vaner 12 years ago
parent
commit
97953d08e3
3 changed files with 21 additions and 3 deletions
  1. 1 2
      src/bin/xfrin/tests/xfrin_test.py
  2. 15 1
      src/bin/xfrin/xfrin.py.in
  3. 5 0
      src/bin/xfrin/xfrin_messages.mes

+ 1 - 2
src/bin/xfrin/tests/xfrin_test.py

@@ -1335,8 +1335,7 @@ class TestAXFR(TestXfrinConnection):
             answers=[begin_soa_rrset, a_rr, soa_rrset])
         # Make it fail the validation
         self._check_zone_result = False
-        self.assertRaises(XfrinProtocolError,
-                          self.conn._handle_xfrin_responses)
+        self.assertRaises(XfrinZoneError, self.conn._handle_xfrin_responses)
         self.assertEqual(type(XfrinAXFREnd()), type(self.conn.get_xfrstate()))
         self.assertEqual([], self.conn._datasrc_client.committed_diffs)
         # Check the validation is called with the correct parameters

+ 15 - 1
src/bin/xfrin/xfrin.py.in

@@ -94,6 +94,12 @@ class XfrinProtocolError(Exception):
     '''
     pass
 
+class XfrinZoneError(Exception):
+    '''
+    An exception raised when the received zone contain invalid data.
+    '''
+    pass
+
 class XfrinZoneUptodate(Exception):
     '''TBD
     '''
@@ -817,7 +823,7 @@ class XfrinConnection(asyncore.dispatcher):
         if not check_zone(self._zone_name, self._rrclass,
                           self._diff.get_rrset_collection(),
                           (self.__validate_error, self.__validate_warning)):
-            raise XfrinProtocolError('Validation of the new zone failed')
+            raise XfrinZoneError('Validation of the new zone failed')
         self._diff.commit()
 
     def __parse_soa_response(self, msg, response_data):
@@ -965,7 +971,15 @@ class XfrinConnection(asyncore.dispatcher):
             # of trying another primary server, etc, but for now we treat it
             # as "success".
             pass
+        except XfrinZoneError:
+            # The log message doesn't contain the exception text, since there's
+            # only one place where the exception is thrown now and it'd be the
+            # same generic message every time.
+            logger.error(XFRIN_INVALID_ZONE_DATA, self.zone_str(),
+                         format_addrinfo(self._master_addrinfo))
+            ret = XFRIN_FAIL
         except XfrinProtocolError as e:
+            # FIXME: Why is this .info? Even the messageID contains "ERROR".
             logger.info(XFRIN_XFR_TRANSFER_PROTOCOL_ERROR, req_str,
                         self.zone_str(),
                         format_addrinfo(self._master_addrinfo), str(e))

+ 5 - 0
src/bin/xfrin/xfrin_messages.mes

@@ -77,6 +77,11 @@ is not equal to the requested SOA serial.
 There was an error importing the python DNS module pydnspp. The most
 likely cause is a PYTHONPATH problem.
 
+% XFRIN_INVALID_ZONE_DATA zone %2 received from %3 contains invalid data
+The zone was received, but it failed sanity validation. The previous version
+of zone (if any is available) will be used. Look for previous
+XFRIN_ZONE_INVALID messages to see the exact problem(s).
+
 % XFRIN_IXFR_TRANSFER_SUCCESS incremental IXFR transfer of zone %1 succeeded (messages: %2, changesets: %3, deletions: %4, additions: %5, bytes: %6, run time: %7 seconds, %8 bytes/second)
 The IXFR transfer for the given zone was successful.
 The provided information contains the following values: