Blob Blame History Raw
From 0e3bfd1eb771802edab0d5f72dc7a9e8538f2fa7 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Tue, 17 May 2016 14:35:39 +0200
Subject: [PATCH 04/13] Just report misconfiguration instead of crashing in
 text mode

User should get to know what happened, but crashing and showing a traceback is
not really a great way to do it. Showing a text "dialog" with all the
information we have is much better.

Resolves: rhbz#1263207
---
 org_fedora_oscap/ks/oscap.py | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/org_fedora_oscap/ks/oscap.py b/org_fedora_oscap/ks/oscap.py
index 5c29d4a..44c442f 100644
--- a/org_fedora_oscap/ks/oscap.py
+++ b/org_fedora_oscap/ks/oscap.py
@@ -466,10 +466,28 @@ class OSCAPdata(AddonData):
 
         # evaluate rules, do automatic fixes and stop if something that cannot
         # be fixed automatically is wrong
-        messages = self.rule_data.eval_rules(ksdata, storage)
-        if any(message.type == common.MESSAGE_TYPE_FATAL
-               for message in messages):
-            raise MisconfigurationError("Wrong configuration detected!")
+        fatal_messages = [message for message in self.rule_data.eval_rules(ksdata, storage)
+                          if message.type == common.MESSAGE_TYPE_FATAL]
+        if any(fatal_messages):
+            msg = "Wrong configuration detected!\n"
+            msg += "\n".join(message.text for message in fatal_messages)
+            msg += "\nThe 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)
 
         # add packages needed on the target system to the list of packages
         # that are requested to be installed
-- 
2.5.5