From 903958306830ea00ac47e3ea353eaa5d8abbacb6 Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Wed, 23 Oct 2019 14:24:59 -0400
Subject: [PATCH] [Predicate] Override __bool__ to allow py3 evaluation
The check in `Plugin.test_predicate()` relies on a 'is not None' test,
which on py2 invokes a call to `SoSPredicate.__nonzero__()` which in
turns runs our evaluation of the predicate. On py3 however, this test is
an explicit check to see if the object is `NoneType`. As such,
`__nonzero__()` never runs and the predicate defaults to always
evaluating ad `True`. This effectively removed any gating for command
execution on py3.
By overriding `SoSPredicate.__bool__()` to wrap `__nonzero__()` we can
ensure that predicate evaluation is performed properly on both py2 and
py3 runtimes.
Closes: #1839
Resolves: #1840
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/plugins/__init__.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index ed55ea382..7ed75a5cc 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -181,6 +181,11 @@ class SoSPredicate(object):
return ((self._eval_kmods() and self._eval_services()) and not
self.dry_run)
+ def __bool__(self):
+ # Py3 evaluation ends in a __bool__() call where py2 ends in a call
+ # to __nonzero__(). Wrap the latter here, to support both versions
+ return self.__nonzero__()
+
def __init__(self, owner, dry_run=False, kmods=[], services=[],
required={}):
"""Initialise a new SoSPredicate object.
From 4c02a77a1c0403c903c835d85739a6213c1a2287 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Tue, 5 Nov 2019 17:29:57 +0100
Subject: [PATCH] [man] describe --allow-system-changes
In #1435, --allow-system-changes option was added that is documented
in sosreport --help but not in manpages.
Resolves: #1850
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
man/en/sosreport.1 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/man/en/sosreport.1 b/man/en/sosreport.1
index 649cba04d..a885d5630 100644
--- a/man/en/sosreport.1
+++ b/man/en/sosreport.1
@@ -25,6 +25,7 @@ sosreport \- Collect and package diagnostic and support data
[--log-size]\fR
[--all-logs]\fR
[--since YYYYMMDD[HHMMSS]]\fR
+ [--allow-system-changes]\fR
[-z|--compression-type method]\fR
[--encrypt-key KEY]\fR
[--encrypt-pass PASS]\fR
@@ -160,6 +161,9 @@ increase the size of reports.
Limits the collection to logs newer than this date.
This also affects \--all-logs. Will pad with 0s if HHMMSS isn't specified.
.TP
+.B \--allow-system-changes
+Run commands even if they can change the system (e.g. load kernel modules).
+.TP
.B \-z, \--compression-type METHOD
Override the default compression type specified by the active policy.
.TP