summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-18 11:04:33 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-18 11:04:33 -0500
commit3d78a3a1c00035c9d8c49b949b63e8f05f31c7a1 (patch)
tree696d3c32dd5329cb4b907d767a7d2a716e65a370 /src
parentb3950b9437cdf4994e445eceec8339402886ded7 (diff)
downloadbcfg2-3d78a3a1c00035c9d8c49b949b63e8f05f31c7a1.tar.gz
bcfg2-3d78a3a1c00035c9d8c49b949b63e8f05f31c7a1.tar.bz2
bcfg2-3d78a3a1c00035c9d8c49b949b63e8f05f31c7a1.zip
Properties: fixed lax/strict decryption setting with no crypto libs installed
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Properties.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Properties.py b/src/lib/Bcfg2/Server/Plugins/Properties.py
index a51dd8adc..3ebad40e3 100644
--- a/src/lib/Bcfg2/Server/Plugins/Properties.py
+++ b/src/lib/Bcfg2/Server/Plugins/Properties.py
@@ -205,27 +205,25 @@ class XMLPropertyFile(Bcfg2.Server.Plugin.StructFile, PropertyFile):
def Index(self):
Bcfg2.Server.Plugin.StructFile.Index(self)
- strict = self.xdata.get(
- "decrypt",
- SETUP.cfp.get(Bcfg2.Encryption.CFG_SECTION, "decrypt",
- default="strict")) == "strict"
- for el in self.xdata.xpath("//*[@encrypted]"):
- if not HAS_CRYPTO:
- raise PluginExecutionError("Properties: M2Crypto is not "
- "available: %s" % self.name)
- try:
- el.text = self._decrypt(el).encode('ascii',
- 'xmlcharrefreplace')
- except UnicodeDecodeError:
- LOGGER.info("Properties: Decrypted %s to gibberish, "
- "skipping" % el.tag)
- except Bcfg2.Encryption.EVPError:
- msg = "Properties: Failed to decrypt %s element in %s" % \
- (el.tag, self.name)
- if strict:
- raise PluginExecutionError(msg)
- else:
- LOGGER.warning(msg)
+ if HAS_CRYPTO:
+ strict = self.xdata.get(
+ "decrypt",
+ SETUP.cfp.get(Bcfg2.Encryption.CFG_SECTION, "decrypt",
+ default="strict")) == "strict"
+ for el in self.xdata.xpath("//*[@encrypted]"):
+ try:
+ el.text = self._decrypt(el).encode('ascii',
+ 'xmlcharrefreplace')
+ except UnicodeDecodeError:
+ LOGGER.info("Properties: Decrypted %s to gibberish, "
+ "skipping" % el.tag)
+ except Bcfg2.Encryption.EVPError:
+ msg = "Properties: Failed to decrypt %s element in %s" % \
+ (el.tag, self.name)
+ if strict:
+ raise PluginExecutionError(msg)
+ else:
+ LOGGER.warning(msg)
Index.__doc__ = Bcfg2.Server.Plugin.StructFile.Index.__doc__
def _decrypt(self, element):