diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2018-05-24 21:39:41 -0400 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-06-07 11:25:38 +0100 |
commit | 5ecf10675784a51c87d002afa279cb0797be2f37 (patch) | |
tree | 82efe30330ae91c808c4ef7e0fb643c67f05ca9b | |
parent | ca3bec9ada0bb0542cb71a8f808aebd101600564 (diff) | |
download | sos-5ecf10675784a51c87d002afa279cb0797be2f37.tar.gz |
[Plugin] Do not run verify on empty package list
In some instances, the regex match in all_pkgs_by_name_regex() was
returning an empty list when no match was made. This in turn caused sos
to run an empty verify command, e.g. 'rpm -V '.
By filtering the list of packages to verify, we can remove these empty
lists and avoid the empty verify command.
Closes: #1304
Resolves: #1314
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/policies/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index f242df4c..b5cfc819 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -160,8 +160,12 @@ class PackageManager(object): if not self.verify_command: return None + # The re.match(pkg) used by all_pkgs_by_name_regex() may return + # an empty list (`[[]]`) when no package matches: avoid building + # an rpm -V command line with the empty string as the package + # list in this case. by_regex = self.all_pkgs_by_name_regex - verify_list = map(by_regex, packages) + verify_list = filter(None, map(by_regex, packages)) # No packages after regex match? if not verify_list: |