diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2017-05-22 16:30:35 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2017-05-22 16:30:35 +0100 |
commit | 4df4897146d4f2a0589a8b32532f912f1ea2ed8c (patch) | |
tree | c2349b0ef88481745978f14fad139dbeb86d9c30 | |
parent | 7da0d24619928690f4999ffc1693b643b612f130 (diff) | |
download | sos-4df4897146d4f2a0589a8b32532f912f1ea2ed8c.tar.gz |
[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>
-rw-r--r-- | sos/policies/redhat.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py index b801b5ed..ec1d9748 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" |