import sos-4.1-2.el8

This commit is contained in:
CentOS Sources 2021-05-19 04:12:39 +00:00 committed by Andrew Lukoshko
parent 45825dca01
commit e6bbb07882
12 changed files with 1209 additions and 1 deletions

View File

@ -0,0 +1,243 @@
From fc0218638f3e865c4315823e72aef2f46d012d07 Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Wed, 14 Apr 2021 11:55:03 -0400
Subject: [PATCH 1/2] [clean] Load maps from all archives before obfuscation
loop
Previously, maps were being prepped via archives after extraction. This
reduced the amount of file IO being done, but made it so that necessary
obfuscations from later archives in a series would not be obfuscated in
the archives obfuscated before those later archives were extracted.
Fix this by extracting the map prep files into memory for each archive
to prep the maps before we enter the obfuscation loop entirely.
Closes: #2490
Related: RHBZ#1930181
Resolves: #2492
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/cleaner/__init__.py | 69 +++++++++++++++-----------
sos/cleaner/parsers/username_parser.py | 13 +++--
2 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index b9eb61ef..d10cdc55 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -292,6 +292,7 @@ third party.
# we have at least one valid target to obfuscate
self.completed_reports = []
+ self.preload_all_archives_into_maps()
self.obfuscate_report_paths()
if not self.completed_reports:
@@ -473,6 +474,44 @@ third party.
self.ui_log.info("Exiting on user cancel")
os._exit(130)
+ def preload_all_archives_into_maps(self):
+ """Before doing the actual obfuscation, if we have multiple archives
+ to obfuscate then we need to preload each of them into the mappings
+ to ensure that node1 is obfuscated in node2 as well as node2 being
+ obfuscated in node1's archive.
+ """
+ self.log_info("Pre-loading multiple archives into obfuscation maps")
+ for _arc in self.report_paths:
+ is_dir = os.path.isdir(_arc)
+ if is_dir:
+ _arc_name = _arc
+ else:
+ archive = tarfile.open(_arc)
+ _arc_name = _arc.split('/')[-1].split('.tar')[0]
+ # for each parser, load the map_prep_file into memory, and then
+ # send that for obfuscation. We don't actually obfuscate the file
+ # here, do that in the normal archive loop
+ for _parser in self.parsers:
+ if not _parser.prep_map_file:
+ continue
+ _arc_path = os.path.join(_arc_name, _parser.prep_map_file)
+ try:
+ if is_dir:
+ _pfile = open(_arc_path, 'r')
+ content = _pfile.read()
+ else:
+ _pfile = archive.extractfile(_arc_path)
+ content = _pfile.read().decode('utf-8')
+ _pfile.close()
+ if isinstance(_parser, SoSUsernameParser):
+ _parser.load_usernames_into_map(content)
+ for line in content.splitlines():
+ if isinstance(_parser, SoSHostnameParser):
+ _parser.load_hostname_into_map(line)
+ self.obfuscate_line(line, _parser.prep_map_file)
+ except Exception as err:
+ self.log_debug("Could not prep %s: %s" % (_arc_path, err))
+
def obfuscate_report(self, report):
"""Individually handle each archive or directory we've discovered by
running through each file therein.
@@ -493,7 +532,6 @@ third party.
start_time = datetime.now()
arc_md.add_field('start_time', start_time)
archive.extract()
- self.prep_maps_from_archive(archive)
archive.report_msg("Beginning obfuscation...")
file_list = archive.get_file_list()
@@ -542,35 +580,6 @@ third party.
self.ui_log.info("Exception while processing %s: %s"
% (report, err))
- def prep_maps_from_archive(self, archive):
- """Open specific files from an archive and try to load those values
- into our mappings before iterating through the entire archive.
-
- Positional arguments:
-
- :param archive SoSObfuscationArchive: An open archive object
- """
- for parser in self.parsers:
- if not parser.prep_map_file:
- continue
- prep_file = archive.get_file_path(parser.prep_map_file)
- if not prep_file:
- self.log_debug("Could not prepare %s: %s does not exist"
- % (parser.name, parser.prep_map_file),
- caller=archive.archive_name)
- continue
- # this is a bit clunky, but we need to load this particular
- # parser in a different way due to how hostnames are validated for
- # obfuscation
- if isinstance(parser, SoSHostnameParser):
- with open(prep_file, 'r') as host_file:
- hostname = host_file.readline().strip()
- parser.load_hostname_into_map(hostname)
- if isinstance(parser, SoSUsernameParser):
- parser.load_usernames_into_map(prep_file)
- self.obfuscate_file(prep_file, parser.prep_map_file,
- archive.archive_name)
-
def obfuscate_file(self, filename, short_name=None, arc_name=None):
"""Obfuscate and individual file, line by line.
diff --git a/sos/cleaner/parsers/username_parser.py b/sos/cleaner/parsers/username_parser.py
index 5223c018..2bb6c7f3 100644
--- a/sos/cleaner/parsers/username_parser.py
+++ b/sos/cleaner/parsers/username_parser.py
@@ -39,16 +39,15 @@ class SoSUsernameParser(SoSCleanerParser):
super(SoSUsernameParser, self).__init__(conf_file)
self.mapping.load_names_from_options(opt_names)
- def load_usernames_into_map(self, fname):
+ def load_usernames_into_map(self, content):
"""Since we don't get the list of usernames from a straight regex for
this parser, we need to override the initial parser prepping here.
"""
- with open(fname, 'r') as lastfile:
- for line in lastfile.read().splitlines()[1:]:
- user = line.split()[0]
- if user in self.skip_list:
- continue
- self.mapping.get(user)
+ for line in content.splitlines()[1:]:
+ user = line.split()[0]
+ if user in self.skip_list:
+ continue
+ self.mapping.get(user)
def parse_line(self, line):
count = 0
--
2.26.3
From b713f458bfa92427147de754ea36054bfde53d71 Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Wed, 14 Apr 2021 12:22:28 -0400
Subject: [PATCH 2/2] [clean] Remove duplicate file skipping within
obfuscate_line()
A redundant file skipping check was being executed within
`obfuscate_line()` that would cause subsequent archives being obfuscated
to skip line obfuscation within a file, despite iterating through the
entire file.
Remove this redundant check, thus allowing proper obfuscation.
Closes: #2490
Related: RHBZ#1930181
Resolves: #2492
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/cleaner/__init__.py | 11 +++--------
sos/cleaner/obfuscation_archive.py | 2 --
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index d10cdc55..bdd24f95 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -508,7 +508,7 @@ third party.
for line in content.splitlines():
if isinstance(_parser, SoSHostnameParser):
_parser.load_hostname_into_map(line)
- self.obfuscate_line(line, _parser.prep_map_file)
+ self.obfuscate_line(line)
except Exception as err:
self.log_debug("Could not prep %s: %s" % (_arc_path, err))
@@ -606,7 +606,7 @@ third party.
if not line.strip():
continue
try:
- line, count = self.obfuscate_line(line, short_name)
+ line, count = self.obfuscate_line(line)
subs += count
tfile.write(line)
except Exception as err:
@@ -631,7 +631,7 @@ third party.
pass
return string_data
- def obfuscate_line(self, line, filename):
+ def obfuscate_line(self, line):
"""Run a line through each of the obfuscation parsers, keeping a
cumulative total of substitutions done on that particular line.
@@ -639,16 +639,11 @@ third party.
:param line str: The raw line as read from the file being
processed
- :param filename str: Filename the line was read from
Returns the fully obfuscated line and the number of substitutions made
"""
count = 0
for parser in self.parsers:
- if filename and any([
- re.match(_s, filename) for _s in parser.skip_files
- ]):
- continue
try:
line, _count = parser.parse_line(line)
count += _count
diff --git a/sos/cleaner/obfuscation_archive.py b/sos/cleaner/obfuscation_archive.py
index 84ca30cd..c64ab13b 100644
--- a/sos/cleaner/obfuscation_archive.py
+++ b/sos/cleaner/obfuscation_archive.py
@@ -219,8 +219,6 @@ class SoSObfuscationArchive():
:param filename str: Filename relative to the extracted
archive root
"""
- if filename in self.file_sub_list:
- return True
if not os.path.isfile(self.get_file_path(filename)):
return True
--
2.26.3

View File

@ -0,0 +1,99 @@
From 3b439fb64d8d65b0c09aa8452bf0181ec20f8bcf Mon Sep 17 00:00:00 2001
From: Jose Castillo <jcastillo@redhat.com>
Date: Wed, 3 Mar 2021 13:03:16 +0100
Subject: [PATCH] [man] Multiple fixes in man pages
This patch fixes references to sosreport, to the
preferred 'sos report'. Also adds "SEE ALSO" consistently
for all man pages, and fixes a MAINTAINER line.
Resolves: #2432
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
man/en/sos-clean.1 | 5 +++++
man/en/sos-collect.1 | 1 +
man/en/sos-report.1 | 22 ++++++++++++++--------
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/man/en/sos-clean.1 b/man/en/sos-clean.1
index 0c62ed07..d64a0ec7 100644
--- a/man/en/sos-clean.1
+++ b/man/en/sos-clean.1
@@ -77,6 +77,11 @@ Default: 4
.TP
.B \-\-no-update
Do not write the mapping file contents to /etc/sos/cleaner/default_mapping
+.SH SEE ALSO
+.BR sos (1)
+.BR sos-report (1)
+.BR sos-collect (1)
+
.SH MAINTAINER
.nf
Jake Hunsaker <jhunsake@redhat.com>
diff --git a/man/en/sos-collect.1 b/man/en/sos-collect.1
index d4e5e648..da36542d 100644
--- a/man/en/sos-collect.1
+++ b/man/en/sos-collect.1
@@ -330,6 +330,7 @@ Sosreport option. Override the default compression type.
.SH SEE ALSO
.BR sos (1)
.BR sos-report (1)
+.BR sos-clean (1)
.SH MAINTAINER
Jake Hunsaker <jhunsake@redhat.com>
diff --git a/man/en/sos-report.1 b/man/en/sos-report.1
index e7fae97b..81005959 100644
--- a/man/en/sos-report.1
+++ b/man/en/sos-report.1
@@ -38,11 +38,12 @@ sosreport \- Collect and package diagnostic and support data
[-h|--help]\fR
.SH DESCRIPTION
-\fBsosreport\fR generates an archive of configuration and diagnostic
-information from the running system. The archive may be stored locally
-or centrally for recording or tracking purposes or may be sent to
-technical support representatives, developers or system administrators
-to assist with technical fault-finding and debugging.
+\fBreport\fR is an sos subcommand that generates an archive of
+configuration and diagnostic information from the running system.
+The archive may be stored locally or centrally for recording or
+tracking purposes or may be sent to technical support representatives,
+developers or system administrators to assist with technical
+fault-finding and debugging.
.LP
Sos is modular in design and is able to collect data from a wide
range of subsystems and packages that may be installed. An
@@ -110,8 +111,8 @@ User defined presets are saved under /var/lib/sos/presets as JSON-formatted file
.B \--add-preset ADD_PRESET [options]
Add a preset with name ADD_PRESET that enables [options] when called.
-For example, 'sosreport --add-preset mypreset --log-size=50 -n logs' will enable
-a user to run 'sosreport --preset mypreset' that sets the maximum log size to
+For example, 'sos report --add-preset mypreset --log-size=50 -n logs' will enable
+a user to run 'sos report --preset mypreset' that sets the maximum log size to
50 and disables the logs plugin.
Note: to set a description for the preset that is displayed with \fB--list-presets\fR,
@@ -343,9 +344,14 @@ been tested for this port or may still be under active development.
.TP
.B \--help
Display usage message.
+.SH SEE ALSO
+.BR sos (1)
+.BR sos-clean (1)
+.BR sos-collect (1)
+
.SH MAINTAINER
.nf
-Bryn M. Reeves <bmr@redhat.com>
+Jake Hunsaker <jhunsake@redhat.com>
.fi
.SH AUTHORS & CONTRIBUTORS
See \fBAUTHORS\fR file in the package documentation.
--
2.26.3

View File

@ -0,0 +1,50 @@
From 153c0154050a111fd7e5bcf4a685f906a1dea737 Mon Sep 17 00:00:00 2001
From: Jose Castillo <jcastillo@redhat.com>
Date: Wed, 10 Mar 2021 15:33:50 +0100
Subject: [PATCH] [ds] Mask password and encription keys in ldif files
Both /etc/dirsrv/slapd*/dse.ldif{,.startOK} files contain
sensitive information :
- all the nsSymmetricKey entries : symmetric encryption key
- nsslapd-rootpw : the admin password's hash
This patch masks these entries in the files we collect.
Resolves: #2442
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/report/plugins/ds.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sos/report/plugins/ds.py b/sos/report/plugins/ds.py
index f4d68d6e..d467dc89 100644
--- a/sos/report/plugins/ds.py
+++ b/sos/report/plugins/ds.py
@@ -74,4 +74,22 @@ class DirectoryServer(Plugin, RedHatPlugin):
self.add_cmd_output("ls -l /var/lib/dirsrv/slapd-*/db/*")
+ def postproc(self):
+ # Example for scrubbing rootpw hash
+ #
+ # nsslapd-rootpw: AAAAB3NzaC1yc2EAAAADAQABAAABAQDeXYA3juyPqaUuyfWV2HuIM
+ # v3gebb/5cvx9ehEAFF2yIKvsQN2EJGTV+hBM1DEOB4eyy/H11NqcNwm/2QsagDB3PVwYp
+ # 9VKN3BdhQjlhuoYKhLwgtYUMiGL8AX5g1qxjirIkTRJwjbXkSNuQaXig7wVjmvXnB2o7B
+ # zLtu99DiL1AizfVeZTYA+OVowYKYaXYljVmVKS+g3t29Obaom54ZLpfuoGMmyO64AJrWs
+ #
+ # to
+ #
+ # nsslapd-rootpw:********
+
+ regexppass = r"(nsslapd-rootpw(\s)*:(\s)*)(\S+)([\r\n]\s.*)*\n"
+ regexpkey = r"(nsSymmetricKey(\s)*::(\s)*)(\S+)([\r\n]\s.*)*\n"
+ repl = r"\1********\n"
+ self.do_path_regex_sub('/etc/dirsrv/*', regexppass, repl)
+ self.do_path_regex_sub('/etc/dirsrv/*', regexpkey, repl)
+
# vim: set et ts=4 sw=4 :
--
2.26.3

View File

@ -0,0 +1,315 @@
From 90b6b709e9f4002376b656b155d00d85382f1828 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 29 Mar 2021 16:23:01 +0200
Subject: [PATCH] [report] add --cmd-timeout option
Add --cmd-timeout option to configure command timeout. Plugin-specific
option of the same name (i.e. -k logs.cmd-timeout=60) can control the
timeout per plugin.
Option defaults and global/plugin-specific option preference follows the
--plugin-timeout rules.
Resolves: #2466
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
man/en/sos-report.1 | 18 +++++++++-
sos/collector/__init__.py | 3 ++
sos/collector/sosnode.py | 5 +++
sos/options.py | 3 +-
sos/report/__init__.py | 5 ++-
sos/report/plugins/__init__.py | 63 ++++++++++++++++++++++++----------
6 files changed, 76 insertions(+), 21 deletions(-)
diff --git a/man/en/sos-report.1 b/man/en/sos-report.1
index 81005959..51cf3436 100644
--- a/man/en/sos-report.1
+++ b/man/en/sos-report.1
@@ -17,6 +17,7 @@ sosreport \- Collect and package diagnostic and support data
[--label label] [--case-id id]\fR
[--threads threads]\fR
[--plugin-timeout TIMEOUT]\fR
+ [--cmd-timeout TIMEOUT]\fR
[-s|--sysroot SYSROOT]\fR
[-c|--chroot {auto|always|never}\fR
[--tmp-dir directory]\fR
@@ -247,7 +248,7 @@ Specify a timeout in seconds to allow each plugin to run for. A value of 0
means no timeout will be set. A value of -1 is used to indicate the default
timeout of 300 seconds.
-Note that this options sets the timeout for all plugins. If you want to set
+Note that this option sets the timeout for all plugins. If you want to set
a timeout for a specific plugin, use the 'timeout' plugin option available to
all plugins - e.g. '-k logs.timeout=600'.
@@ -255,6 +256,21 @@ The plugin-specific timeout option will override this option. For example, using
\'--plugin-timeout=60 -k logs.timeout=600\' will set a timeout of 600 seconds for
the logs plugin and 60 seconds for all other enabled plugins.
.TP
+.B \--cmd-timeout TIMEOUT
+Specify a timeout limit in seconds for a command execution. Same defaults logic
+from --plugin-timeout applies here.
+
+This option sets the command timeout for all plugins. If you want to set a cmd
+timeout for a specific plugin, use the 'cmd-timeout' plugin option available to
+all plugins - e.g. '-k logs.cmd-timeout=600'.
+
+Again, the same plugin/global precedence logic as for --plugin-timeout applies
+here.
+
+Note that setting --cmd-timeout (or -k logs.cmd-timeout) high should be followed
+by increasing the --plugin-timeout equivalent, otherwise the plugin can easily
+timeout on slow commands execution.
+.TP
.B \--case-id NUMBER
Specify a case identifier to associate with the archive.
Identifiers may include alphanumeric characters, commas and periods ('.').
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 406c8f35..1ae73508 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -82,6 +82,7 @@ class SoSCollector(SoSComponent):
'password_per_node': False,
'plugin_options': [],
'plugin_timeout': None,
+ 'cmd_timeout': None,
'preset': '',
'save_group': '',
'since': '',
@@ -276,6 +277,8 @@ class SoSCollector(SoSComponent):
help='Do not collect env vars in sosreports')
sos_grp.add_argument('--plugin-timeout', type=int, default=None,
help='Set the global plugin timeout value')
+ sos_grp.add_argument('--cmd-timeout', type=int, default=None,
+ help='Set the global command timeout value')
sos_grp.add_argument('--since', default=None,
help=('Escapes archived files older than date. '
'This will also affect --all-logs. '
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index a1679655..dbbee12e 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -664,6 +664,11 @@ class SosNode():
'--skip-files=%s' % (quote(self.opts.skip_files))
)
+ if self.check_sos_version('4.2'):
+ if self.opts.cmd_timeout:
+ sos_opts.append('--cmd-timeout=%s'
+ % quote(str(self.opts.cmd_timeout)))
+
sos_cmd = sos_cmd.replace(
'sosreport',
os.path.join(self.host.sos_bin_path, self.sos_bin)
diff --git a/sos/options.py b/sos/options.py
index b82a7d36..1eda55d6 100644
--- a/sos/options.py
+++ b/sos/options.py
@@ -283,7 +283,8 @@ class SoSOptions():
if name in ("add_preset", "del_preset", "desc", "note"):
return False
# Exception list for options that still need to be reported when 0
- if name in ['log_size', 'plugin_timeout'] and value == 0:
+ if name in ['log_size', 'plugin_timeout', 'cmd_timeout'] \
+ and value == 0:
return True
return has_value(name, value)
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index 25478ba7..945d0fc1 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -107,6 +107,7 @@ class SoSReport(SoSComponent):
'only_plugins': [],
'preset': 'auto',
'plugin_timeout': 300,
+ 'cmd_timeout': 300,
'profiles': [],
'since': None,
'verify': False,
@@ -266,6 +267,8 @@ class SoSReport(SoSComponent):
help="A preset identifier", default="auto")
report_grp.add_argument("--plugin-timeout", default=None,
help="set a timeout for all plugins")
+ report_grp.add_argument("--cmd-timeout", default=None,
+ help="set a command timeout for all plugins")
report_grp.add_argument("-p", "--profile", "--profiles",
action="extend", dest="profiles", type=str,
default=[],
@@ -709,7 +712,7 @@ class SoSReport(SoSComponent):
self.ui_log.info(_("The following plugin options are available:"))
for (plug, plugname, optname, optparm) in self.all_options:
- if optname in ('timeout', 'postproc'):
+ if optname in ('timeout', 'postproc', 'cmd-timeout'):
continue
# format option value based on its type (int or bool)
if type(optparm["enabled"]) == bool:
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
index 02625eb1..779119af 100644
--- a/sos/report/plugins/__init__.py
+++ b/sos/report/plugins/__init__.py
@@ -472,6 +472,9 @@ class Plugin(object):
_default_plug_opts = [
('timeout', 'Timeout in seconds for plugin. The default value (-1) ' +
'defers to the general plugin timeout, 300 seconds', 'fast', -1),
+ ('cmd-timeout', 'Timeout in seconds for a command execution. The ' +
+ 'default value (-1) defers to the general cmd timeout, 300 ' +
+ 'seconds', 'fast', -1),
('postproc', 'Enable post-processing collected plugin data', 'fast',
True)
]
@@ -532,16 +535,15 @@ class Plugin(object):
self.manifest.add_list('commands', [])
self.manifest.add_list('files', [])
- @property
- def timeout(self):
- """Returns either the default plugin timeout value, the value as
- provided on the commandline via -k plugin.timeout=value, or the value
- of the global --plugin-timeout option.
+ def timeout_from_options(self, optname, plugoptname, default_timeout):
+ """Returns either the default [plugin|cmd] timeout value, the value as
+ provided on the commandline via -k plugin.[|cmd-]timeout=value, or the
+ value of the global --[plugin|cmd]-timeout option.
"""
_timeout = None
try:
- opt_timeout = self.get_option('plugin_timeout')
- own_timeout = int(self.get_option('timeout'))
+ opt_timeout = self.get_option(optname)
+ own_timeout = int(self.get_option(plugoptname))
if opt_timeout is None:
_timeout = own_timeout
elif opt_timeout is not None and own_timeout == -1:
@@ -551,10 +553,30 @@ class Plugin(object):
else:
return None
except ValueError:
- return self.plugin_timeout # Default to known safe value
+ return default_timeout # Default to known safe value
if _timeout is not None and _timeout > -1:
return _timeout
- return self.plugin_timeout
+ return default_timeout
+
+ @property
+ def timeout(self):
+ """Returns either the default plugin timeout value, the value as
+ provided on the commandline via -k plugin.timeout=value, or the value
+ of the global --plugin-timeout option.
+ """
+ _timeout = self.timeout_from_options('plugin_timeout', 'timeout',
+ self.plugin_timeout)
+ return _timeout
+
+ @property
+ def cmdtimeout(self):
+ """Returns either the default command timeout value, the value as
+ provided on the commandline via -k plugin.cmd-timeout=value, or the
+ value of the global --cmd-timeout option.
+ """
+ _cmdtimeout = self.timeout_from_options('cmd_timeout', 'cmd-timeout',
+ self.cmd_timeout)
+ return _cmdtimeout
def set_timeout_hit(self):
self._timeout_hit = True
@@ -1235,8 +1257,8 @@ class Plugin(object):
"""
global_options = (
- 'all_logs', 'allow_system_changes', 'log_size', 'plugin_timeout',
- 'since', 'verify'
+ 'all_logs', 'allow_system_changes', 'cmd_timeout', 'log_size',
+ 'plugin_timeout', 'since', 'verify'
)
if optionname in global_options:
@@ -1505,7 +1527,7 @@ class Plugin(object):
'tags': _spec_tags
})
- def add_blockdev_cmd(self, cmds, devices='block', timeout=300,
+ def add_blockdev_cmd(self, cmds, devices='block', timeout=None,
sizelimit=None, chroot=True, runat=None, env=None,
binary=False, prepend_path=None, whitelist=[],
blacklist=[], tags=[]):
@@ -1569,7 +1591,7 @@ class Plugin(object):
whitelist=whitelist, blacklist=blacklist,
tags=_dev_tags)
- def _add_device_cmd(self, cmds, devices, timeout=300, sizelimit=None,
+ def _add_device_cmd(self, cmds, devices, timeout=None, sizelimit=None,
chroot=True, runat=None, env=None, binary=False,
prepend_path=None, whitelist=[], blacklist=[],
tags=[]):
@@ -1627,7 +1649,7 @@ class Plugin(object):
changes=soscmd.changes)
def add_cmd_output(self, cmds, suggest_filename=None,
- root_symlink=None, timeout=cmd_timeout, stderr=True,
+ root_symlink=None, timeout=None, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None, subdir=None,
changes=False, foreground=False, tags=[]):
@@ -1849,7 +1871,7 @@ class Plugin(object):
self._log_debug("added string ...'%s' as '%s'" % (summary, filename))
def _collect_cmd_output(self, cmd, suggest_filename=None,
- root_symlink=False, timeout=cmd_timeout,
+ root_symlink=False, timeout=None,
stderr=True, chroot=True, runat=None, env=None,
binary=False, sizelimit=None, subdir=None,
changes=False, foreground=False, tags=[]):
@@ -1883,6 +1905,8 @@ class Plugin(object):
if self._timeout_hit:
return
+ if timeout is None:
+ timeout = self.cmdtimeout
_tags = []
if isinstance(tags, str):
@@ -1975,7 +1999,7 @@ class Plugin(object):
return result
def collect_cmd_output(self, cmd, suggest_filename=None,
- root_symlink=False, timeout=cmd_timeout,
+ root_symlink=False, timeout=None,
stderr=True, chroot=True, runat=None, env=None,
binary=False, sizelimit=None, pred=None,
subdir=None, tags=[]):
@@ -2044,7 +2068,7 @@ class Plugin(object):
tags=tags
)
- def exec_cmd(self, cmd, timeout=cmd_timeout, stderr=True, chroot=True,
+ def exec_cmd(self, cmd, timeout=None, stderr=True, chroot=True,
runat=None, env=None, binary=False, pred=None,
foreground=False, container=False, quotecmd=False):
"""Execute a command right now and return the output and status, but
@@ -2095,6 +2119,9 @@ class Plugin(object):
if not self.test_predicate(cmd=True, pred=pred):
return _default
+ if timeout is None:
+ timeout = self.cmdtimeout
+
if chroot or self.commons['cmdlineopts'].chroot == 'always':
root = self.sysroot
else:
@@ -2331,7 +2358,7 @@ class Plugin(object):
def add_journal(self, units=None, boot=None, since=None, until=None,
lines=None, allfields=False, output=None,
- timeout=cmd_timeout, identifier=None, catalog=None,
+ timeout=None, identifier=None, catalog=None,
sizelimit=None, pred=None, tags=[]):
"""Collect journald logs from one of more units.
--
2.26.3

View File

@ -0,0 +1,30 @@
From 0d56e43299009ffa91f665d85b5a08ba76da9c1f Mon Sep 17 00:00:00 2001
From: Jose Castillo <jcastillo@redhat.com>
Date: Wed, 17 Mar 2021 13:10:36 +0100
Subject: [PATCH] [cups] Add gathering cups-browsed logs
Gather logs from the service cups-browsed sent
to the journal.
Resolves: #2452
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
Signed-off-by: Bryan Quigley <code@bryanquigley.com>
---
sos/report/plugins/cups.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/sos/report/plugins/cups.py b/sos/report/plugins/cups.py
index 29a903e8..ab7b6b70 100644
--- a/sos/report/plugins/cups.py
+++ b/sos/report/plugins/cups.py
@@ -40,5 +40,6 @@ class Cups(Plugin, IndependentPlugin):
])
self.add_journal(units="cups")
+ self.add_journal(units="cups-browsed")
# vim: set et ts=4 sw=4 :
--
2.26.3

View File

@ -0,0 +1,62 @@
From d03c2fa4439c87783293c922b2825cf86e8818bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Po=C5=82awski?= <ppolawsk@redhat.com>
Date: Fri, 12 Mar 2021 12:42:30 +0100
Subject: [PATCH] [sssd] Enable collecting SSSD memory cache
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
SSSD plugin by default collects only logs and configuration.
This patch enables collecting memory cache maintained
by SSSD daemon. Cache does not contain any client sensible
data so can be safely included in the sos-report.
Resolves: #2444
Signed-off-by: Paweł Poławski <ppolawsk@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/report/plugins/sssd.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sos/report/plugins/sssd.py b/sos/report/plugins/sssd.py
index 9469c41c..aeb68c4f 100644
--- a/sos/report/plugins/sssd.py
+++ b/sos/report/plugins/sssd.py
@@ -10,6 +10,7 @@
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, SoSPredicate)
+from glob import glob
class Sssd(Plugin):
@@ -22,11 +23,22 @@ class Sssd(Plugin):
def setup(self):
self.add_copy_spec([
+ # main config file
"/etc/sssd/sssd.conf",
- "/var/log/sssd/*",
- "/var/lib/sss/pubconf/krb5.include.d/*",
# SSSD 1.14
- "/etc/sssd/conf.d/*.conf"
+ "/etc/sssd/conf.d/*.conf",
+ # dynamic Kerberos configuration
+ "/var/lib/sss/pubconf/krb5.include.d/*"
+ ])
+
+ # add individual log files
+ self.add_copy_spec(glob("/var/log/sssd/*log*"))
+
+ # add memory cache
+ self.add_copy_spec([
+ "/var/lib/sss/mc/passwd",
+ "/var/lib/sss/mc/group",
+ "/var/lib/sss/mc/initgroups"
])
# call sssctl commands only when sssd service is running,
--
2.26.3

View File

@ -0,0 +1,29 @@
From dddabb07a88d398ed7b8a878e95acfd968af6698 Mon Sep 17 00:00:00 2001
From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Date: Tue, 23 Mar 2021 17:58:30 +0530
Subject: [PATCH] This patch is to update kernel plugin to collect
dynamic_debug log files for ibmvNIC
Resolves: #2458
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Signed-off-by: Bryan Quigley <code@bryanquigley.com>
---
sos/report/plugins/kernel.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/sos/report/plugins/kernel.py b/sos/report/plugins/kernel.py
index febe2ad0..dd7b6939 100644
--- a/sos/report/plugins/kernel.py
+++ b/sos/report/plugins/kernel.py
@@ -106,6 +106,7 @@ class Kernel(Plugin, IndependentPlugin):
"/proc/misc",
"/var/log/dmesg",
"/sys/fs/pstore",
+ "/sys/kernel/debug/dynamic_debug/control",
clocksource_path + "available_clocksource",
clocksource_path + "current_clocksource"
])
--
2.26.3

View File

@ -0,0 +1,147 @@
From 808d9f35ac504a58c337ffed14b39119a591808f Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Tue, 27 Apr 2021 22:16:08 +0200
Subject: [PATCH] [pulpcore] add plugin for pulp-3
Pulp-3 / pulpcore as a revolution from pulp-2 needs a separate
plugin, since both plugins have nothing in common and there might
be deployments where is active both pulp-2 and pulp-3.
Resolves: #2278
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/report/plugins/pulpcore.py | 120 +++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100644 sos/report/plugins/pulpcore.py
diff --git a/sos/report/plugins/pulpcore.py b/sos/report/plugins/pulpcore.py
new file mode 100644
index 00000000..20403814
--- /dev/null
+++ b/sos/report/plugins/pulpcore.py
@@ -0,0 +1,120 @@
+# Copyright (C) 2021 Red Hat, Inc., Pavel Moravec <pmoravec@redhat.com>
+
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos.report.plugins import Plugin, IndependentPlugin
+from pipes import quote
+from re import match
+
+
+class PulpCore(Plugin, IndependentPlugin):
+
+ short_desc = 'Pulp-3 aka pulpcore'
+
+ plugin_name = "pulpcore"
+ commands = ("pulpcore-manager",)
+ files = ("/etc/pulp/settings.py",)
+ option_list = [
+ ('task-days', 'days of tasks history', 'fast', 7)
+ ]
+
+ def parse_settings_config(self):
+ databases_scope = False
+ self.dbhost = "localhost"
+ self.dbport = 5432
+ self.dbpasswd = ""
+ # TODO: read also redis config (we dont expect much customisations)
+ # TODO: read also db user (pulp) and database name (pulpcore)
+ self.staticroot = "/var/lib/pulp/assets"
+ self.uploaddir = "/var/lib/pulp/media/upload"
+
+ def separate_value(line, sep=':'):
+ # an auxiliary method to parse values from lines like:
+ # 'HOST': 'localhost',
+ val = line.split(sep)[1].lstrip().rstrip(',')
+ if (val.startswith('"') and val.endswith('"')) or \
+ (val.startswith('\'') and val.endswith('\'')):
+ val = val[1:-1]
+ return val
+
+ try:
+ for line in open("/etc/pulp/settings.py").read().splitlines():
+ # skip empty lines and lines with comments
+ if not line or line[0] == '#':
+ continue
+ if line.startswith("DATABASES"):
+ databases_scope = True
+ continue
+ # example HOST line to parse:
+ # 'HOST': 'localhost',
+ if databases_scope and match(r"\s+'HOST'\s*:\s+\S+", line):
+ self.dbhost = separate_value(line)
+ if databases_scope and match(r"\s+'PORT'\s*:\s+\S+", line):
+ self.dbport = separate_value(line)
+ if databases_scope and match(r"\s+'PASSWORD'\s*:\s+\S+", line):
+ self.dbpasswd = separate_value(line)
+ # if line contains closing '}' database_scope end
+ if databases_scope and '}' in line:
+ databases_scope = False
+ if line.startswith("STATIC_ROOT = "):
+ self.staticroot = separate_value(line, sep='=')
+ if line.startswith("CHUNKED_UPLOAD_DIR = "):
+ self.uploaddir = separate_value(line, sep='=')
+ except IOError:
+ # fallback when the cfg file is not accessible
+ pass
+ # set the password to os.environ when calling psql commands to prevent
+ # printing it in sos logs
+ # we can't set os.environ directly now: other plugins can overwrite it
+ self.env = {"PGPASSWORD": self.dbpasswd}
+
+ def setup(self):
+ self.parse_settings_config()
+
+ self.add_copy_spec("/etc/pulp/settings.py")
+
+ self.add_cmd_output("rq info -u redis://localhost:6379/8",
+ env={"LC_ALL": "en_US.UTF-8"},
+ suggest_filename="rq_info")
+ self.add_cmd_output("curl -ks https://localhost/pulp/api/v3/status/",
+ suggest_filename="pulp_status")
+ dynaconf_env = {"LC_ALL": "en_US.UTF-8",
+ "PULP_SETTINGS": "/etc/pulp/settings.py",
+ "DJANGO_SETTINGS_MODULE": "pulpcore.app.settings"}
+ self.add_cmd_output("dynaconf list", env=dynaconf_env)
+ for _dir in [self.staticroot, self.uploaddir]:
+ self.add_cmd_output("ls -l %s" % _dir)
+
+ task_days = self.get_option('task-days')
+ for table in ['core_task', 'core_taskgroup',
+ 'core_reservedresourcerecord',
+ 'core_taskreservedresourcerecord',
+ 'core_groupprogressreport', 'core_progressreport']:
+ _query = "select * from %s where pulp_last_updated > NOW() - " \
+ "interval '%s days' order by pulp_last_updated" % \
+ (table, task_days)
+ _cmd = "psql -h %s -p %s -U pulp -d pulpcore -c %s" % \
+ (self.dbhost, self.dbport, quote(_query))
+ self.add_cmd_output(_cmd, env=self.env, suggest_filename=table)
+
+ def postproc(self):
+ # TODO obfuscate from /etc/pulp/settings.py :
+ # SECRET_KEY = "eKfeDkTnvss7p5WFqYdGPWxXfHnsbDBx"
+ # 'PASSWORD': 'tGrag2DmtLqKLTWTQ6U68f6MAhbqZVQj',
+ self.do_path_regex_sub(
+ "/etc/pulp/settings.py",
+ r"(SECRET_KEY\s*=\s*)(.*)",
+ r"\1********")
+ self.do_path_regex_sub(
+ "/etc/pulp/settings.py",
+ r"(PASSWORD\S*\s*:\s*)(.*)",
+ r"\1********")
+
+
+# vim: set et ts=4 sw=4 :
--
2.26.3

View File

@ -0,0 +1,30 @@
From c998ea8c1c950586f91fc9728ee66590740968a5 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Tue, 11 May 2021 15:59:40 +0200
Subject: [PATCH] [saphana] remove redundant unused argument of get_inst_info
get_inst_info does not use and isnt called with 'prefix' argument
Resolves: #2535
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/report/plugins/saphana.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sos/report/plugins/saphana.py b/sos/report/plugins/saphana.py
index 82c497b4..00e84b59 100644
--- a/sos/report/plugins/saphana.py
+++ b/sos/report/plugins/saphana.py
@@ -51,7 +51,7 @@ class saphana(Plugin, RedHatPlugin):
inst = inst.strip()[-2:]
self.get_inst_info(sid, sidadm, inst)
- def get_inst_info(self, prefix, sid, sidadm, inst):
+ def get_inst_info(self, sid, sidadm, inst):
proc_cmd = 'su - %s -c "sapcontrol -nr %s -function GetProcessList"'
status_fname = "%s_%s_status" % (sid, inst)
self.add_cmd_output(
--
2.26.3

View File

@ -0,0 +1,121 @@
From 60105e0705f3483b9a3e8e98dafd6f0e1e277ab7 Mon Sep 17 00:00:00 2001
From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Date: Mon, 19 Apr 2021 16:55:52 +0530
Subject: [PATCH 1/3] [block]:Patch to update block pluging to collect disk
info
This patch is to update block plugin to collect
state of sda
Resolves: #2504
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
---
sos/report/plugins/block.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/sos/report/plugins/block.py b/sos/report/plugins/block.py
index f93b3231..c959d667 100644
--- a/sos/report/plugins/block.py
+++ b/sos/report/plugins/block.py
@@ -38,7 +38,8 @@ class Block(Plugin, IndependentPlugin):
"/run/blkid/blkid.tab",
"/proc/partitions",
"/proc/diskstats",
- "/sys/block/*/queue/"
+ "/sys/block/*/queue/",
+ "/sys/block/sd*/device/state",
])
cmds = [
--
2.26.3
From c6e0fe5cebd0d9581950db75fa2d234713b7e15a Mon Sep 17 00:00:00 2001
From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Date: Mon, 26 Apr 2021 23:09:19 +0530
Subject: [PATCH 2/3] [snapper]:Ptach to update snapper plugin to collect
snapper info
This patch is to Introduce snapper plugin to collect
/usr/lib/snapper/ information to check executable
permission for installation-helper command
Resolves: #2504
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
---
sos/report/plugins/snapper.py | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 sos/report/plugins/snapper.py
diff --git a/sos/report/plugins/snapper.py b/sos/report/plugins/snapper.py
new file mode 100644
index 00000000..9ef5fec2
--- /dev/null
+++ b/sos/report/plugins/snapper.py
@@ -0,0 +1,27 @@
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos.report.plugins import Plugin, IndependentPlugin
+
+
+class Snapper(Plugin, IndependentPlugin):
+
+ short_desc = 'System snapper'
+
+ plugin_name = 'snapper'
+ commands = ("snapper",)
+
+ def setup(self):
+
+ self.add_cmd_output([
+ "ls -la /usr/lib/snapper/",
+ "snapper --version",
+ "snapper list"
+ ])
+
+# vim: set et ts=4 sw=4 :
--
2.26.3
From 61ff5ce165e654a02fe80b9de5ec8e49ed808ec9 Mon Sep 17 00:00:00 2001
From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Date: Mon, 19 Apr 2021 17:49:08 +0530
Subject: [PATCH 3/3] [kernel]:Patch to update kernel plugin to collect debug
info
This patch is to update kernel plugin to collect
page allocation failure info
Resolves: #2504
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
---
sos/report/plugins/kernel.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sos/report/plugins/kernel.py b/sos/report/plugins/kernel.py
index dd7b6939..9d53ca03 100644
--- a/sos/report/plugins/kernel.py
+++ b/sos/report/plugins/kernel.py
@@ -107,6 +107,8 @@ class Kernel(Plugin, IndependentPlugin):
"/var/log/dmesg",
"/sys/fs/pstore",
"/sys/kernel/debug/dynamic_debug/control",
+ "/sys/kernel/debug/extfrag/unusable_index",
+ "/sys/kernel/debug/extfrag/extfrag_index",
clocksource_path + "available_clocksource",
clocksource_path + "current_clocksource"
])
--
2.26.3

View File

@ -0,0 +1,36 @@
From 575ddeddf2f6e1d6a639922f9ccc51c7e46fbe12 Mon Sep 17 00:00:00 2001
From: Seiichi Ikarashi <s.ikarashi@jp.fujitsu.com>
Date: Fri, 14 May 2021 09:49:33 +0900
Subject: [PATCH] [networking] Add nstat command support
As netstat command is being deprecated,
we need nstat as an alternative to "netstat -s".
Signed-off-by: Seiichi Ikarashi <s.ikarashi@fujitsu.com>
---
sos/report/plugins/networking.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sos/report/plugins/networking.py b/sos/report/plugins/networking.py
index 8b4614bb..acfa027f 100644
--- a/sos/report/plugins/networking.py
+++ b/sos/report/plugins/networking.py
@@ -87,6 +87,7 @@ class Networking(Plugin):
root_symlink="netstat")
self.add_cmd_output([
+ "nstat -zas",
"netstat -s",
"netstat %s -agn" % self.ns_wide,
"ip route show table all",
@@ -198,6 +199,7 @@ class Networking(Plugin):
ns_cmd_prefix + "netstat %s -neopa" % self.ns_wide,
ns_cmd_prefix + "netstat -s",
ns_cmd_prefix + "netstat %s -agn" % self.ns_wide,
+ ns_cmd_prefix + "nstat -zas",
])
ss_cmd = ns_cmd_prefix + "ss -peaonmi"
--
2.26.3

View File

@ -5,7 +5,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.1
Release: 1%{?dist}
Release: 2%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
Source1: sos-audit-%{auditversion}.tgz
@ -20,6 +20,17 @@ Requires: xz
Conflicts: vdsm < 4.40
Obsoletes: sos-collector
Recommends: python3-pexpect
Patch1: sos-bz1930181-collect-cleaning-consistency.patch
Patch2: sos-bz1935603-manpages-see-also.patch
Patch3: sos-bz1937418-add-cmd-timeout.patch
Patch4: sos-bz1937298-ds-mask-password-in-ldif.patch
Patch5: sos-bz1939963-gather-cups-browsed-logs.patch
Patch6: sos-bz1940502-sssd-memcache-and-logs.patch
Patch7: sos-bz1942276-ibmvNIC-dynamic-debugs.patch
Patch8: sos-bz1956673-pulpcore-plugin.patch
Patch9: sos-bz1959413-saphana-traceback.patch
Patch10: sos-bz1961458-collect-nstat.patch
Patch11: sos-bz1961229-snapper-plugin-and-allocation-failures.patch
%description
@ -31,6 +42,17 @@ support technicians and developers.
%prep
%setup -qn %{name}-%{version}
%setup -T -D -a1 -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%build
%py3_build
@ -94,6 +116,30 @@ of the system. Currently storage and filesystem commands are audited.
%ghost /etc/audit/rules.d/40-sos-storage.rules
%changelog
* Tue May 18 2021 Pavel Moravec <pmoravec@redhat.com> = 4.1-2
- Load maps from all archives before obfuscation
Resolves: bz1930181
- Multiple fixes in man pages
Resolves: bz1935603
- [ds] Mask password and encryption keys in ldif files
Resolves: bz1937298
- [report] add --cmd-timeout option
Resolves: bz1937418
- [cups] Add gathering cups-browsed logs
Resolves: bz1939963
- [sssd] Collect memory cache / individual logfiles
Resolves: bz1940502
- Collect ibmvNIC dynamic_debugs
Resolves: bz1942276
- [pulpcore] add plugin for pulp-3
Resolves: bz1956673
- [saphana] remove redundant unused argument of get_inst_info
Resolves: bz1959413
- [networking] Add nstat command support
Resolves: bz1961458
- [snapper] add a new plugin
Resolves: bz1961229
* Mon Apr 26 2021 Pavel Moravec <pmoravec@redhat.com> = 4.1-1
- Rebase on upstream 4.1
Resolves: bz1928679