From d21e3a56803d106752a8c9c8418979a7f8d1c320 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Tue, 29 Apr 2014 18:09:46 +0100 Subject: 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 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 --- sos/policies/__init__.py | 2 ++ 1 file changed, 2 insertions(+) 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, -- cgit