From a7c4e87f7501439a93807c119f611c8be23194eb Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 25 Nov 2013 07:27:50 -0500 Subject: bcfg2-crypt: handle error when encrypting properties with multiple keys --- src/sbin/bcfg2-crypt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/sbin') 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: -- cgit v1.2.3-1-g7c22