Blob Blame History Raw
From 93a18e629c41604ba13709b42a3e3a23c7edd593 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Tue, 27 Jan 2015 11:40:06 +0000
Subject: [PATCH 84/93] [sosoptions] ensure '_sysroot' and '_chroot' are
 initialised

Make sure the sysroot and chroot members of the SoSOptions object
are initialised to prevent exceptions when these are not set on
the command line:

  sosreport
  Traceback (most recent call last):
    File "/usr/sbin/sosreport", line 25, in <module>
      main(sys.argv[1:])
    File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1490, in main
      sos = SoSReport(args)
    File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 673, in __init__
      self.policy = sos.policies.load(sysroot=self.opts.sysroot)
    File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 40, in load
      cache['policy'] = policy(sysroot=sysroot)
    File "/usr/lib/python2.7/site-packages/sos/policies/redhat.py", line 192, in __init__
      super(FedoraPolicy, self).__init__(sysroot=sysroot)
    File "/usr/lib/python2.7/site-packages/sos/policies/redhat.py", line 58, in __init__
      if self.package_manager.all_pkgs()['filesystem']['version'][0] == '3':
    File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 116, in all_pkgs
      self.packages = self.get_pkg_list()
    File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 99, in get_pkg_list
      pkg_list = shell_out(cmd, chroot=self.chroot).splitlines()
    File "/usr/lib/python2.7/site-packages/sos/utilities.py", line 191, in shell_out
      return sos_get_command_output(cmd, chroot=chroot, chdir=runat)['output']
    File "/usr/lib/python2.7/site-packages/sos/utilities.py", line 156, in sos_get_command_output
      raise e
  OSError: [Errno 1] Operation not permitted: '/'

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/sosreport.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sos/sosreport.py b/sos/sosreport.py
index f0542d9..ea8426f 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -246,6 +246,8 @@ class SoSOptions(object):
     _config_file = ""
     _tmp_dir = ""
     _report = True
+    _sysroot = None
+    _chroot = 'auto'
     _compression_type = 'auto'
 
     _options = None
-- 
1.9.3