From 20e41fab140936cb07a732cfd8f066fc8cc94a6b Mon Sep 17 00:00:00 2001 From: James Kasten Date: Thu, 4 Oct 2012 16:20:48 -0400 Subject: [PATCH] Only create a checkpoint if changes are made to files --- trustify/client/client.py | 3 +-- trustify/client/configurator.py | 36 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/trustify/client/client.py b/trustify/client/client.py index 546011c6e..1851ac75c 100644 --- a/trustify/client/client.py +++ b/trustify/client/client.py @@ -467,8 +467,7 @@ def authenticate(): r = decode(do(upstream, k)) logger.debug(r) - # TODO: This needs to be rewritten to handle multiple challenges - handle_verification_response(r, dn, challenges[0], vhost, key_file, config) + handle_verification_response(r, dn, challenges, vhost, key_file, config) # vim: set expandtab tabstop=4 shiftwidth=4 diff --git a/trustify/client/configurator.py b/trustify/client/configurator.py index df621d5ed..38d83db08 100644 --- a/trustify/client/configurator.py +++ b/trustify/client/configurator.py @@ -96,7 +96,7 @@ class Configurator(object): else: self.aug.set(path["cert_chain"][0], cert_chain) - self.save_notes += "Changed vhost at %s with addresses of %s" % (vhost.file, vhost.addrs) + self.save_notes += "Changed vhost at %s with addresses of %s\n" % (vhost.file, vhost.addrs) self.save_notes += "\tSSLCertificateFile %s\n" % cert self.save_notes += "\tSSLCertificateKeyFile %s\n" % key if cert_chain: @@ -856,13 +856,13 @@ LogLevel warn \n\ except: # Check for the root of save problems new_errs = self.aug.match("/augeas//error") + logger.error("During Save - " + mod_conf) # Only print new errors caused by recent save for err in new_errs: if err not in ex_errs: - print "Error Saving - " + mod_conf - print "Unable to save - " + err[13:len(err)-6] - print "Attempted Save Notes\n" - print self.save_notes + logger.error("Unable to save file - %s" % err[13:len(err)-6]) + logger.error("Attempted Save Notes") + logger.error(self.save_notes) # Erase Save Notes self.save_notes = "" return False @@ -871,21 +871,23 @@ LogLevel warn \n\ # Note: Noop saves can cause the file to be listed twice, used set to # remove this possibility save_paths = self.aug.match("/augeas/events/saved") - save_files = set() - for p in save_paths: - save_files.add(self.aug.get(p)[6:]) + if save_paths: + save_files = set() + for p in save_paths: + save_files.add(self.aug.get(p)[6:]) - for f in save_files: - print f - valid, message = self.check_tempfile_saves(save_files, reversible) + valid, message = self.check_tempfile_saves(save_files, reversible) - if not valid: - logger.error(message) - return False + if not valid: + logger.fatal(message) + # What is the protocol in this situation? + # This shouldn't happen... + return False + + # Create Checkpoint + if not reversible: + self.create_checkpoint(save_files, mod_conf) - # Create Checkpoint - if not reversible: - self.create_checkpoint(save_files, mod_conf) self.aug.set("/augeas/save", save_state) self.save_notes = "" del self.new_files[:]