|
|
fce3c4 |
From 18ae45219c9aa5ed2340a21e9f0aacad62d69242 Mon Sep 17 00:00:00 2001
|
|
|
fce3c4 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
Date: Sat, 8 Sep 2018 17:39:32 +0200
|
|
|
fce3c4 |
Subject: [PATCH 1/3] [plugins] fix exception when collecting empty strings
|
|
|
fce3c4 |
|
|
|
fce3c4 |
get first line of string to log only for nonempty content
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Relevant to: #1422
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
---
|
|
|
fce3c4 |
sos/plugins/__init__.py | 15 +++++++++------
|
|
|
fce3c4 |
1 file changed, 9 insertions(+), 6 deletions(-)
|
|
|
fce3c4 |
|
|
|
fce3c4 |
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
|
|
|
fce3c4 |
index c87ae19b..6c3b153e 100644
|
|
|
fce3c4 |
--- a/sos/plugins/__init__.py
|
|
|
fce3c4 |
+++ b/sos/plugins/__init__.py
|
|
|
fce3c4 |
@@ -746,9 +746,10 @@ class Plugin(object):
|
|
|
fce3c4 |
def add_string_as_file(self, content, filename):
|
|
|
fce3c4 |
"""Add a string to the archive as a file named `filename`"""
|
|
|
fce3c4 |
self.copy_strings.append((content, filename))
|
|
|
fce3c4 |
- content = content.splitlines()[0]
|
|
|
fce3c4 |
- if not isinstance(content, six.string_types):
|
|
|
fce3c4 |
- content = content.decode('utf8', 'ignore')
|
|
|
fce3c4 |
+ if content:
|
|
|
fce3c4 |
+ content = content.splitlines()[0]
|
|
|
fce3c4 |
+ if not isinstance(content, six.string_types):
|
|
|
fce3c4 |
+ content = content.decode('utf8', 'ignore')
|
|
|
fce3c4 |
self._log_debug("added string ...'%s' as '%s'" % (content, filename))
|
|
|
fce3c4 |
|
|
|
fce3c4 |
def get_cmd_output_now(self, exe, suggest_filename=None,
|
|
|
fce3c4 |
@@ -948,9 +949,11 @@ class Plugin(object):
|
|
|
fce3c4 |
|
|
|
fce3c4 |
def _collect_strings(self):
|
|
|
fce3c4 |
for string, file_name in self.copy_strings:
|
|
|
fce3c4 |
- content = string.splitlines()[0]
|
|
|
fce3c4 |
- if not isinstance(content, six.string_types):
|
|
|
fce3c4 |
- content = content.decode('utf8', 'ignore')
|
|
|
fce3c4 |
+ content = ''
|
|
|
fce3c4 |
+ if string:
|
|
|
fce3c4 |
+ content = string.splitlines()[0]
|
|
|
fce3c4 |
+ if not isinstance(content, six.string_types):
|
|
|
fce3c4 |
+ content = content.decode('utf8', 'ignore')
|
|
|
fce3c4 |
self._log_info("collecting string ...'%s' as '%s'"
|
|
|
fce3c4 |
% (content, file_name))
|
|
|
fce3c4 |
try:
|
|
|
fce3c4 |
--
|
|
|
fce3c4 |
2.17.2
|
|
|
fce3c4 |
|
|
|
fce3c4 |
|
|
|
fce3c4 |
From 036bbd0fa4c85f97da536717673ca0b668dd5276 Mon Sep 17 00:00:00 2001
|
|
|
fce3c4 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
Date: Sat, 8 Sep 2018 17:45:09 +0200
|
|
|
fce3c4 |
Subject: [PATCH 2/3] [juju] catch exceptions when "juju status" command fails
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Catch exceptions when "juju status" command:
|
|
|
fce3c4 |
- does not exist (and generates empty output), or
|
|
|
fce3c4 |
- does not generate valid/expected JSON output
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Resolves: #1422
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
---
|
|
|
fce3c4 |
sos/plugins/juju.py | 7 ++++++-
|
|
|
fce3c4 |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
fce3c4 |
|
|
|
fce3c4 |
diff --git a/sos/plugins/juju.py b/sos/plugins/juju.py
|
|
|
fce3c4 |
index cbd4a17b..8d996041 100644
|
|
|
fce3c4 |
--- a/sos/plugins/juju.py
|
|
|
fce3c4 |
+++ b/sos/plugins/juju.py
|
|
|
fce3c4 |
@@ -51,7 +51,12 @@ class Juju(Plugin, UbuntuPlugin):
|
|
|
fce3c4 |
cmd = "juju status --format json"
|
|
|
fce3c4 |
status_json = self.call_ext_prog(cmd)['output']
|
|
|
fce3c4 |
self.add_string_as_file(status_json, "juju_status_json")
|
|
|
fce3c4 |
- return json_loads(status_json)['services'].keys()
|
|
|
fce3c4 |
+ # if status_json isn't in JSON format (i.e. 'juju' command not found),
|
|
|
fce3c4 |
+ # or if it does not contain 'services' key, return empty list
|
|
|
fce3c4 |
+ try:
|
|
|
fce3c4 |
+ return json_loads(status_json)['services'].keys()
|
|
|
fce3c4 |
+ except ValueError:
|
|
|
fce3c4 |
+ return []
|
|
|
fce3c4 |
|
|
|
fce3c4 |
@ensure_service_is_running("juju-db")
|
|
|
fce3c4 |
def export_mongodb(self):
|
|
|
fce3c4 |
--
|
|
|
fce3c4 |
2.17.2
|
|
|
fce3c4 |
|
|
|
fce3c4 |
|
|
|
fce3c4 |
From 549591879a01edcb856f7f353af9d6324d469c39 Mon Sep 17 00:00:00 2001
|
|
|
fce3c4 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
Date: Mon, 24 Sep 2018 20:09:47 +0200
|
|
|
fce3c4 |
Subject: [PATCH 3/3] [unpackaged] compare realpaths of files
|
|
|
fce3c4 |
|
|
|
fce3c4 |
To compare files in $PATH with files installed from a package, we must
|
|
|
fce3c4 |
expand all symlinks to their realpaths. Otherwise we get false positives
|
|
|
fce3c4 |
like /bin/systemctl (as /bin -> /usr/bin).
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Resolves: #1437
|
|
|
fce3c4 |
|
|
|
fce3c4 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
fce3c4 |
---
|
|
|
fce3c4 |
sos/plugins/unpackaged.py | 8 +++++---
|
|
|
fce3c4 |
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
fce3c4 |
|
|
|
fce3c4 |
diff --git a/sos/plugins/unpackaged.py b/sos/plugins/unpackaged.py
|
|
|
fce3c4 |
index 4c065e11..91de9de2 100644
|
|
|
fce3c4 |
--- a/sos/plugins/unpackaged.py
|
|
|
fce3c4 |
+++ b/sos/plugins/unpackaged.py
|
|
|
fce3c4 |
@@ -45,9 +45,10 @@ class Unpackaged(Plugin, RedHatPlugin):
|
|
|
fce3c4 |
path = os.path.abspath(os.readlink(path))
|
|
|
fce3c4 |
except Exception:
|
|
|
fce3c4 |
continue
|
|
|
fce3c4 |
- file_list.append(path)
|
|
|
fce3c4 |
+ file_list.append(os.path.realpath(path))
|
|
|
fce3c4 |
for name in dirs:
|
|
|
fce3c4 |
- file_list.append(os.path.join(root, name))
|
|
|
fce3c4 |
+ file_list.append(os.path.realpath(
|
|
|
fce3c4 |
+ os.path.join(root, name)))
|
|
|
fce3c4 |
|
|
|
fce3c4 |
return file_list
|
|
|
fce3c4 |
|
|
|
fce3c4 |
@@ -63,7 +64,8 @@ class Unpackaged(Plugin, RedHatPlugin):
|
|
|
fce3c4 |
return expanded
|
|
|
fce3c4 |
|
|
|
fce3c4 |
all_fsystem = []
|
|
|
fce3c4 |
- all_frpm = set(self.policy.mangle_package_path(
|
|
|
fce3c4 |
+ all_frpm = set(os.path.realpath(x)
|
|
|
fce3c4 |
+ for x in self.policy.mangle_package_path(
|
|
|
fce3c4 |
self.policy.package_manager.files))
|
|
|
fce3c4 |
|
|
|
fce3c4 |
for d in get_env_path_list():
|
|
|
fce3c4 |
--
|
|
|
fce3c4 |
2.17.2
|
|
|
fce3c4 |
|