Blame SOURCES/sos-bz1789018-allow-system-changes.patch

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