Blame SOURCES/0062-sosreport-check-for-valid-CHROOT-values.patch

0cd6dc
From bce8614030c14c1bd39e935877374e083c360a09 Mon Sep 17 00:00:00 2001
0cd6dc
From: "Bryn M. Reeves" <bmr@redhat.com>
0cd6dc
Date: Sun, 25 Jan 2015 21:54:19 +0000
0cd6dc
Subject: [PATCH 62/93] [sosreport] check for valid CHROOT values
0cd6dc
0cd6dc
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
0cd6dc
---
0cd6dc
 sos/sosreport.py | 16 +++++++++++++---
0cd6dc
 1 file changed, 13 insertions(+), 3 deletions(-)
0cd6dc
0cd6dc
diff --git a/sos/sosreport.py b/sos/sosreport.py
0cd6dc
index adfddb2..1dce5f9 100644
0cd6dc
--- a/sos/sosreport.py
0cd6dc
+++ b/sos/sosreport.py
0cd6dc
@@ -220,6 +220,10 @@ class XmlReport(object):
0cd6dc
         outf.close()
0cd6dc
 
0cd6dc
 
0cd6dc
+# valid modes for --chroot
0cd6dc
+chroot_modes = ["auto", "always", "never"]
0cd6dc
+
0cd6dc
+
0cd6dc
 class SoSOptions(object):
0cd6dc
     _list_plugins = False
0cd6dc
     _noplugins = []
0cd6dc
@@ -533,7 +537,7 @@ class SoSOptions(object):
0cd6dc
     @chroot.setter
0cd6dc
     def chroot(self, value):
0cd6dc
         self._check_options_initialized()
0cd6dc
-        if value not in ["auto", "always", "never"]:
0cd6dc
+        if value not in chroot_modes:
0cd6dc
             msg = "SoSOptions.chroot '%s' is not a valid chroot mode: "
0cd6dc
             msg += "('auto', 'always', 'never')"
0cd6dc
             raise ValueError(msg % value)
0cd6dc
@@ -685,6 +689,14 @@ class SoSReport(object):
0cd6dc
         if self.opts.sysroot:
0cd6dc
             self.sysroot = self.opts.sysroot
0cd6dc
 
0cd6dc
+        self._setup_logging()
0cd6dc
+
0cd6dc
+        if self.opts.chroot not in chroot_modes:
0cd6dc
+            self.soslog.error("invalid chroot mode: %s" % self.opts.chroot)
0cd6dc
+            logging.shutdown()
0cd6dc
+            self.tempfile_util.clean()
0cd6dc
+            self._exit(1)
0cd6dc
+
0cd6dc
     def print_header(self):
0cd6dc
         self.ui_log.info("\n%s\n" % _("sosreport (version %s)" %
0cd6dc
                          (__version__,)))
0cd6dc
@@ -1169,7 +1181,6 @@ class SoSReport(object):
0cd6dc
                     self.ui_log.error(" %s while setting up plugins"
0cd6dc
                                       % e.strerror)
0cd6dc
                     self.ui_log.error("")
0cd6dc
-                    self._exit(1)
0cd6dc
                 if self.raise_plugins:
0cd6dc
                     raise
0cd6dc
                 self._log_plugin_exception(plugname, "setup")
0cd6dc
@@ -1419,7 +1430,6 @@ class SoSReport(object):
0cd6dc
 
0cd6dc
     def execute(self):
0cd6dc
         try:
0cd6dc
-            self._setup_logging()
0cd6dc
             self.policy.set_commons(self.get_commons())
0cd6dc
             self.print_header()
0cd6dc
             self.load_plugins()
0cd6dc
-- 
0cd6dc
1.9.3
0cd6dc