From 4b44aab4ed8ef39b15ea4f7a1ebb648ec95642fb Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 28 Dec 2011 12:36:34 -0500 Subject: fixed FileProbes handling of base64-encoded files --- src/lib/Server/Plugins/FileProbes.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/lib/Server/Plugins/FileProbes.py') diff --git a/src/lib/Server/Plugins/FileProbes.py b/src/lib/Server/Plugins/FileProbes.py index d761d23d2..0c1a0d897 100644 --- a/src/lib/Server/Plugins/FileProbes.py +++ b/src/lib/Server/Plugins/FileProbes.py @@ -132,6 +132,12 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin, except Bcfg2.Server.Plugin.PluginExecutionError: create = True + # get current entry data + if entry.get("encoding") == "base64": + entrydata = binascii.a2b_base64(entry.text) + else: + entrydata = entry.text + if create: self.logger.info("Writing new probed file %s" % fileloc) try: @@ -170,14 +176,14 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin, except Bcfg2.Server.Plugin.PluginExecutionError: pass tries += 1 - elif entry.data == contents: + elif entrydata == contents: self.logger.debug("Existing %s contents match probed contents" % filename) return elif (entry.get('update', 'false').lower() == "true"): self.logger.info("Writing updated probed file %s" % fileloc) open(fileloc, 'wb').write(contents) - + # service FAM events tries = 0 updated = False @@ -187,14 +193,18 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin, raise Bcfg2.Server.Plugin.PluginExecutionError self.core.fam.handle_events_in_interval(1) cfg.entries[filename].bind_entry(entry, metadata) - if entry.text == contents: + # get current entry data + if entry.get("encoding") == "base64": + entrydata = binascii.a2b_base64(entry.text) + else: + entrydata = entry.text + if entrydata == contents: updated = True tries += 1 else: self.logger.info("Skipping updated probed file %s" % fileloc) return - - + def write_infoxml(self, infoxml, entry, data): """ write an info.xml for the file """ self.logger.info("Writing info.xml at %s for %s" % -- cgit v1.2.3-1-g7c22