summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-25 07:27:50 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-25 07:27:50 -0500
commita7c4e87f7501439a93807c119f611c8be23194eb (patch)
tree12421b07eed47f0544a246fe8870396f28c6c14f /src/sbin
parent0f8d403d1a86cfbfe8222662dc445e16e8f7eff9 (diff)
downloadbcfg2-a7c4e87f7501439a93807c119f611c8be23194eb.tar.gz
bcfg2-a7c4e87f7501439a93807c119f611c8be23194eb.tar.bz2
bcfg2-a7c4e87f7501439a93807c119f611c8be23194eb.zip
bcfg2-crypt: handle error when encrypting properties with multiple keys
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-crypt12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sbin/bcfg2-crypt b/src/sbin/bcfg2-crypt
index 3c2d0f2b6..f3b96909e 100755
--- a/src/sbin/bcfg2-crypt
+++ b/src/sbin/bcfg2-crypt
@@ -54,6 +54,10 @@ class DecryptError(Exception):
""" Exception raised when decryption fails. """
+class EncryptError(Exception):
+ """ Exception raised when encryption fails. """
+
+
class CryptoTool(object):
""" Generic decryption/encryption interface base object """
def __init__(self, filename, setup):
@@ -270,8 +274,7 @@ class PropertiesEncryptor(Encryptor, PropertiesCryptoMixin):
try:
pname, passphrase = self._get_element_passphrase(elt)
except PassphraseError:
- self.logger.error(str(sys.exc_info()[1]))
- return False
+ raise EncryptError(str(sys.exc_info()[1]))
self.logger.debug("Encrypting %s" % print_xml(elt))
elt.text = Bcfg2.Encryption.ssl_encrypt(
elt.text, passphrase,
@@ -454,8 +457,9 @@ def main(): # pylint: disable=R0912,R0915
if data is None:
try:
data = getattr(tool, mode)()
- except DecryptError:
- logger.error("Failed to %s %s, skipping" % (mode, fname))
+ except (EncryptError, DecryptError):
+ logger.error("Failed to %s %s, skipping: %s" %
+ (mode, fname, sys.exc_info()[1]))
continue
if setup['crypt_stdout']:
if len(setup['args']) > 1: