diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-01-25 21:54:19 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-07-08 17:05:20 +0100 |
commit | b16fbf3911c6256674e072cff6fa706050861993 (patch) | |
tree | 8b0b892ab4a03cc145907f85ea795679fc616c4c | |
parent | f6f7934c7d3e7f6cb41879fc0625b06d0468af4e (diff) | |
download | sos-b16fbf3911c6256674e072cff6fa706050861993.tar.gz |
[sosreport] check for valid CHROOT values
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/sosreport.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py index d9abcb8d..a0b89e78 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -225,6 +225,10 @@ class XmlReport(object): outf.close() +# valid modes for --chroot +chroot_modes = ["auto", "always", "never"] + + class SoSOptions(object): _list_plugins = False _noplugins = [] @@ -548,7 +552,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) @@ -705,6 +709,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__,))) @@ -1205,7 +1217,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") @@ -1455,7 +1466,6 @@ class SoSReport(object): def execute(self): try: - self._setup_logging() self.policy.set_commons(self.get_commons()) self.print_header() self.load_plugins() |