aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-04-29 18:09:46 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-04-29 18:09:46 +0100
commitd21e3a56803d106752a8c9c8418979a7f8d1c320 (patch)
tree1eb0a7b9881372855561a9740d1dce5ddfe08ca1
parent67afdc16b6141d8df124de507acffd33b2a668ad (diff)
downloadsos-d21e3a56803d106752a8c9c8418979a7f8d1c320.tar.gz
Fix exception in Policy::get_pkg_list()
If the current working directory (as reported by getcwd()) does not exist the package manager component of the policy may fail to initialise: shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory Traceback (most recent call last): File "/sbin/sosreport", line 23, in <module> main(sys.argv[1:]) File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1228, in main sos = SoSReport(args) File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 530, in __init__ self.policy = sos.policies.load() File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 39, in load cache['policy'] = policy() File "/usr/lib/python2.7/site-packages/sos/policies/redhat.py", line 165, in __init__ super(FedoraPolicy, self).__init__() File "/usr/lib/python2.7/site-packages/sos/policies/redhat.py", line 49, in __init__ if self.package_manager.all_pkgs()['filesystem']['version'][0] == '3': File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 108, in all_pkgs self.packages = self.get_pkg_list() File "/usr/lib/python2.7/site-packages/sos/policies/__init__.py", line 95, in get_pkg_list name, version = pkg.split("|") ValueError: need more than 1 value to unpack Fix this by ensuring that the string contains at least one pipe character before splitting. There are many reasons that the package manager could spit out unexpected lines with the package list so this improves the general robustness of this code. Fixes RHBZ#1091683. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index b1fccb10..11995ff6 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -92,6 +92,8 @@ class PackageManager(object):
if self.query_command:
pkg_list = shell_out(self.query_command).splitlines()
for pkg in pkg_list:
+ if '|' not in pkg:
+ continue
name, version = pkg.split("|")
self.packages[name] = {
'name': name,