aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/policies/__init__.py3
-rw-r--r--sos/policies/redhat.py10
-rw-r--r--sos/utilities.py4
3 files changed, 13 insertions, 4 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 9fcbd552..34a2f6a2 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -56,6 +56,7 @@ class PackageManager(object):
"""
query_command = None
+ timeout = 30
def __init__(self, query_command=None):
self.packages = {}
@@ -92,7 +93,7 @@ class PackageManager(object):
version': 'major.minor.version'}}
"""
if self.query_command:
- pkg_list = shell_out(self.query_command).splitlines()
+ pkg_list = shell_out(self.query_command, self.timeout).splitlines()
for pkg in pkg_list:
if '|' not in pkg:
continue
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index 22192463..38510d93 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -15,6 +15,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# This enables the use of with syntax in python 2.5 (e.g. jython)
+from __future__ import print_function
import os
import sys
@@ -46,8 +47,15 @@ class RedHatPolicy(LinuxPolicy):
'rpm -qa --queryformat "%{NAME}|%{VERSION}\\n"')
self.valid_subclasses = [RedHatPlugin]
+ pkgs = self.package_manager.all_pkgs()
+
+ # If rpm query timed out after timeout duration exit
+ if not pkgs:
+ print("Could not obtain installed package list", file=sys.stderr)
+ sys.exit(1)
+
# handle PATH for UsrMove
- if self.package_manager.all_pkgs()['filesystem']['version'][0] == '3':
+ if pkgs['filesystem']['version'][0] == '3':
self.PATH = "/usr/sbin:/usr/bin:/root/bin"
else:
self.PATH = "/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
diff --git a/sos/utilities.py b/sos/utilities.py
index 51909c64..2638ce4a 100644
--- a/sos/utilities.py
+++ b/sos/utilities.py
@@ -180,11 +180,11 @@ def import_module(module_fqname, superclasses=None):
return modules
-def shell_out(cmd, runat=None):
+def shell_out(cmd, timeout=30, runat=None):
"""Shell out to an external command and return the output or the empty
string in case of error.
"""
- return sos_get_command_output(cmd, runat=runat)['output']
+ return sos_get_command_output(cmd, timeout=timeout, runat=runat)['output']
class ImporterHelper(object):