From b7294206ffd1248997679eaaf5daa53a0a315054 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 6 Nov 2012 13:34:01 -0500 Subject: Properties: allow lax decryption, where failure to decrypt an element is not fatal and parsing of that file continues --- src/lib/Bcfg2/Server/Plugins/Properties.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/Plugins/Properties.py b/src/lib/Bcfg2/Server/Plugins/Properties.py index a3b9c6aec..2b4196ad6 100644 --- a/src/lib/Bcfg2/Server/Plugins/Properties.py +++ b/src/lib/Bcfg2/Server/Plugins/Properties.py @@ -210,12 +210,20 @@ class XMLPropertyFile(Bcfg2.Server.Plugin.StructFile, PropertyFile): if not HAS_CRYPTO: raise PluginExecutionError("Properties: M2Crypto is not " "available: %s" % self.name) + strict = self.xdata.get( + "decrypt", + SETUP.cfp.get("properties", "decrypt", + default="strict")) == "strict" for el in self.xdata.xpath("//*[@encrypted]"): try: el.text = self._decrypt(el) except EVPError: - raise PluginExecutionError("Failed to decrypt %s element " - "in %s" % (el.tag, self.name)) + msg = "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): -- cgit v1.2.3-1-g7c22