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