summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-24 11:54:44 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-24 11:58:04 -0400
commit4fb636cd7ff2d3f4352613932d2c02c08aba1636 (patch)
tree957697c6c1332b5f45c0bd5e8a25287561d19708
parentdd0c589a65f8bb668bdec6bffe6f3cf03b793cc5 (diff)
downloadbcfg2-4fb636cd7ff2d3f4352613932d2c02c08aba1636.tar.gz
bcfg2-4fb636cd7ff2d3f4352613932d2c02c08aba1636.tar.bz2
bcfg2-4fb636cd7ff2d3f4352613932d2c02c08aba1636.zip
improved error messages during failed decryption
-rw-r--r--src/lib/Bcfg2/Server/Plugin/helpers.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/CfgEncryptedGenerator.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py7
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Properties.py13
4 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py
index 8e383ba97..bbceb1989 100644
--- a/src/lib/Bcfg2/Server/Plugin/helpers.py
+++ b/src/lib/Bcfg2/Server/Plugin/helpers.py
@@ -198,6 +198,9 @@ class FileBacked(object):
except IOError:
err = sys.exc_info()[1]
LOGGER.error("Failed to read file %s: %s" % (self.name, err))
+ except:
+ err = sys.exc_info()[1]
+ LOGGER.error("Failed to parse file %s: %s" % (self.name, err))
def Index(self):
""" Index() is called by :func:`HandleEvent` every time the
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgEncryptedGenerator.py b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgEncryptedGenerator.py
index 98a807602..26faf6e2c 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgEncryptedGenerator.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgEncryptedGenerator.py
@@ -42,9 +42,7 @@ class CfgEncryptedGenerator(CfgGenerator):
self.data = bruteforce_decrypt(self.data, setup=SETUP,
algorithm=get_algorithm(SETUP))
except EVPError:
- msg = "Failed to decrypt %s" % self.name
- LOGGER.error(msg)
- raise PluginExecutionError(msg)
+ raise PluginExecutionError("Failed to decrypt %s" % self.name)
handle_event.__doc__ = CfgGenerator.handle_event.__doc__
def get_data(self, entry, metadata):
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index fe53ea809..58f6e1e42 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -378,7 +378,12 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
(action, event.filename))
self.debug_log("%s handling %s event on %s" %
(hdlr.__name__, action, event.filename))
- self.entry_init(event, hdlr)
+ try:
+ self.entry_init(event, hdlr)
+ except: # pylint: disable=W0702
+ err = sys.exc_info()[1]
+ LOGGER.error("Cfg: Failed to parse %s: %s" %
+ (event.filename, err))
return
elif hdlr.ignore(event, basename=self.path):
return
diff --git a/src/lib/Bcfg2/Server/Plugins/Properties.py b/src/lib/Bcfg2/Server/Plugins/Properties.py
index aef5238c6..a3b9c6aec 100644
--- a/src/lib/Bcfg2/Server/Plugins/Properties.py
+++ b/src/lib/Bcfg2/Server/Plugins/Properties.py
@@ -208,17 +208,14 @@ class XMLPropertyFile(Bcfg2.Server.Plugin.StructFile, PropertyFile):
Bcfg2.Server.Plugin.StructFile.Index(self)
if self.xdata.get("encryption", "false").lower() != "false":
if not HAS_CRYPTO:
- msg = "Properties: M2Crypto is not available: %s" % self.name
- LOGGER.error(msg)
- raise PluginExecutionError(msg)
+ raise PluginExecutionError("Properties: M2Crypto is not "
+ "available: %s" % self.name)
for el in self.xdata.xpath("//*[@encrypted]"):
try:
el.text = self._decrypt(el)
except EVPError:
- msg = "Failed to decrypt %s element in %s" % (el.tag,
- self.name)
- LOGGER.error(msg)
- raise PluginExecutionError(msg)
+ raise PluginExecutionError("Failed to decrypt %s element "
+ "in %s" % (el.tag, self.name))
Index.__doc__ = Bcfg2.Server.Plugin.StructFile.Index.__doc__
def _decrypt(self, element):
@@ -318,6 +315,7 @@ class Properties(Bcfg2.Server.Plugin.Plugin,
global SETUP # pylint: disable=W0603
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
Bcfg2.Server.Plugin.Connector.__init__(self)
+ SETUP = core.setup
try:
self.store = PropDirectoryBacked(self.data, core.fam)
except OSError:
@@ -326,7 +324,6 @@ class Properties(Bcfg2.Server.Plugin.Plugin,
err)
raise Bcfg2.Server.Plugin.PluginInitError
- SETUP = core.setup
__init__.__doc__ = Bcfg2.Server.Plugin.Plugin.__init__.__doc__
def get_additional_data(self, metadata):