From 4df4897146d4f2a0589a8b32532f912f1ea2ed8c Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 22 May 2017 16:30:35 +0100
Subject: [PATCH] [policies/redhat] make missing 'filesystem' package non-fatal
On Red Hat systems, we use the version of the installed filesystem'
package to enable handling of UsrMove[1] in the PATH used when
running commands from sos.
If the package is not present (e.g. because of a broken system
configuration, rpm timeout, corrupt database or other cause),
previous versions would fail immediately. In this situation
there was no way for the user to attempt a complete run (short
of fixing the problem related to the 'filesystem' package).
Now that the timeout has been lengthened for this command, make
the UsrMove determination a bit more robust to prevent users from
being unable to run sos at all:
- If RPM fails entirely, exit (plugin enablement tests will fail)
- If RPM succeeds but 'filesystem' is missing assume UsrMove
(this is true for all supported Red Hat distros today)
- Otherwise apply the normal PATH logic.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
sos/policies/redhat.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index b801b5e..ec1d974 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -58,13 +58,21 @@ class RedHatPolicy(LinuxPolicy):
pkgs = self.package_manager.all_pkgs()
- # If rpm query timed out after timeout duration exit
+ # If rpm query failed, exit
if not pkgs:
print("Could not obtain installed package list", file=sys.stderr)
sys.exit(1)
# handle PATH for UsrMove
- if pkgs['filesystem']['version'][0] == '3':
+ if 'filesystem' not in pkgs:
+ print("Could not find 'filesystem' package: "
+ "assuming PATH settings")
+ usrmove = True
+ else:
+ filesys_version = pkgs['filesystem']['version']
+ usrmove = True if filesys_version[0] == '3' else False
+
+ if usrmove:
self.PATH = "/usr/sbin:/usr/bin:/root/bin"
else:
self.PATH = "/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
--
2.7.4