From 9cf9d865f9c51b7d7d82b3a768244bbed763731e Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Wed, 8 Jul 2015 10:45:29 +0200 Subject: [PATCH 3/7] Just report integrity check failure instead of traceback (#1240710) That way users can continue with the installation in some way or exit the installation in a user-friendly way. Signed-off-by: Vratislav Podzimek --- org_fedora_oscap/gui/spokes/oscap.py | 15 +++++++++++++-- org_fedora_oscap/ks/oscap.py | 22 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/org_fedora_oscap/gui/spokes/oscap.py b/org_fedora_oscap/gui/spokes/oscap.py index 46b742b..daa23e9 100644 --- a/org_fedora_oscap/gui/spokes/oscap.py +++ b/org_fedora_oscap/gui/spokes/oscap.py @@ -332,8 +332,11 @@ class OSCAPSpoke(NormalSpoke): self._addon_data.raw_preinst_content_path, hash_obj) if digest != self._addon_data.fingerprint: - msg = _("Integrity check failed") - raise content_handling.ContentCheckError(msg) + self._integrity_check_failed() + # fetching done + with self._fetch_flag_lock: + self._fetching = False + return # RPM is an archive at this phase if self._addon_data.content_type in ("archive", "rpm"): @@ -652,6 +655,14 @@ class OSCAPSpoke(NormalSpoke): self._wrong_content() @gtk_action_wait + def _integrity_check_failed(self): + """Adapts the UI if integrity check fails""" + + msg = _("The integrity check of the content failed. Cannot use the content.") + self._progress_label.set_markup("%s" % msg) + self._wrong_content() + + @gtk_action_wait def _extraction_failed(self, err_msg): """Adapts the UI if extracting data from entered URL failed""" diff --git a/org_fedora_oscap/ks/oscap.py b/org_fedora_oscap/ks/oscap.py index ed0e54d..1a185d5 100644 --- a/org_fedora_oscap/ks/oscap.py +++ b/org_fedora_oscap/ks/oscap.py @@ -443,8 +443,26 @@ class OSCAPdata(AddonData): digest = utils.get_file_fingerprint(self.raw_preinst_content_path, hash_obj) if digest != self.fingerprint: - msg = "Integrity check of the content failed!" - raise ContentCheckError(msg) + log.error("Failed to fetch and initialize SCAP content!") + msg = _("The integrity check of the security content failed.\n" + + "The installation should be aborted. Do you wish to continue anyway?") + + if flags.flags.automatedInstall and not flags.flags.ksprompt: + # cannot have ask in a non-interactive kickstart installation + raise errors.CmdlineError(msg) + + answ = errors.errorHandler.ui.showYesNoQuestion(msg) + if answ == errors.ERROR_CONTINUE: + # prevent any futher actions here by switching to the dry + # run mode and let things go on + self.dry_run = True + return + else: + # Let's sleep forever to prevent any further actions and wait for + # the main thread to quit the process. + progressQ.send_quit(1) + while True: + time.sleep(100000) # evaluate rules, do automatic fixes and stop if something that cannot # be fixed automatically is wrong -- 2.4.3