From 43fe909ec6a36061d8857b259c29053d0ced3809 Mon Sep 17 00:00:00 2001 From: Daniel Roschka Date: Sun, 22 Mar 2015 17:03:50 +0100 Subject: [PATCH] Fixes error handling for broken TSIG keys. The error handling for broken TSIG keys wasn't working for two reasons: * the import of binascii has been missing, producing a NameError once an exception occured * The exception handler was refering to a non-existant variable key_name. This commit fixes both issues. --- binder/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/binder/models.py b/binder/models.py index d41b33c..c19a839 100644 --- a/binder/models.py +++ b/binder/models.py @@ -1,6 +1,7 @@ ### Binder Models # Standard Imports +import binascii import socket import urllib2 @@ -38,11 +39,9 @@ class Key(models.Model): return None try: - keyring = dns.tsigkeyring.from_text({ - self.name : self.data - }) + keyring = dns.tsigkeyring.from_text({self.name: self.data}) except binascii.Error, err: - raise exceptions.KeyringException("Incorrect key data. Verify key: %s. Reason: %s" % (key_name, err)) + raise exceptions.KeyringException("Incorrect key data. Verify key: %s. Reason: %s" % (self.name, err)) return keyring