aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2019-06-11 18:44:46 +0200
committerBryn M. Reeves <bmr@redhat.com>2019-08-15 16:41:43 +0100
commit94b57fea81704151be2b72c7d81141c9e8589b97 (patch)
treeca10818b350feda8d0aa8678b51fc8b93dc77c55
parent47dcdb876dfd01db67c9ff4731f467854505210a (diff)
downloadsos-94b57fea81704151be2b72c7d81141c9e8589b97.tar.gz
[sosreport] add option --allow-system-changes
Running some commands can change the system e.g. by loading a kernel modules. That disqualifies the commands from being called by default. Add an option that overrides this default behaviour. Related to: #1435 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/__init__.py21
-rw-r--r--sos/plugins/__init__.py5
-rw-r--r--sos/sosreport.py4
3 files changed, 19 insertions, 11 deletions
diff --git a/sos/__init__.py b/sos/__init__.py
index 9cd71728..725c003a 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py
@@ -50,13 +50,13 @@ _sos = _default
#: Names of all arguments
_arg_names = [
- 'add_preset', 'alloptions', 'all_logs', 'batch', 'build', 'case_id',
- 'chroot', 'compression_type', 'config_file', 'desc', 'debug', 'del_preset',
- 'dry_run', 'enableplugins', 'encrypt_key', 'encrypt_pass', 'experimental',
- 'label', 'list_plugins', 'list_presets', 'list_profiles', 'log_size',
- 'noplugins', 'noreport', 'no_env_vars', 'note', 'onlyplugins',
- 'plugin_timeout', 'plugopts', 'preset', 'profiles', 'quiet', 'sysroot',
- 'threads', 'tmp_dir', 'verbosity', 'verify'
+ 'add_preset', 'alloptions', 'allow_system_changes', 'all_logs', 'batch',
+ 'build', 'case_id', 'chroot', 'compression_type', 'config_file', 'desc',
+ 'debug', 'del_preset', 'dry_run', 'enableplugins', 'encrypt_key',
+ 'encrypt_pass', 'experimental', 'label', 'list_plugins', 'list_presets',
+ 'list_profiles', 'log_size', 'noplugins', 'noreport', 'no_env_vars',
+ 'note', 'onlyplugins', 'plugin_timeout', 'plugopts', 'preset', 'profiles',
+ 'quiet', 'sysroot', 'threads', 'tmp_dir', 'verbosity', 'verify'
]
#: Arguments with non-zero default values
@@ -179,6 +179,7 @@ class SoSOptions(object):
self.log_size = _arg_defaults["log_size"]
self.noplugins = []
self.noreport = False
+ self.allow_system_changes = False
self.no_env_vars = False
self.note = ""
self.onlyplugins = []
@@ -219,9 +220,9 @@ class SoSOptions(object):
and verbose).
"""
no_value = (
- "alloptions", "all-logs", "batch", "build", "debug",
- "experimental", "list-plugins", "list-presets", "list-profiles",
- "noreport", "no-env-vars", "quiet", "verify"
+ "alloptions", "allow-system-changes", "all-logs", "batch", "build",
+ "debug", "experimental", "list-plugins", "list-presets",
+ "list-profiles", "noreport", "no-env-vars", "quiet", "verify"
)
count = ("verbose",)
if opt in no_value:
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index e51ca6a7..66c26470 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -750,7 +750,10 @@ class Plugin(object):
matches any of the option names is returned.
"""
- global_options = ('verify', 'all_logs', 'log_size', 'plugin_timeout')
+ global_options = (
+ 'all_logs', 'allow_system_changes', 'log_size', 'plugin_timeout',
+ 'verify'
+ )
if optionname in global_options:
return getattr(self.commons['cmdlineopts'], optionname)
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 04cb8615..723e3e58 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -221,6 +221,10 @@ def _get_parser():
parser.add_argument("-t", "--threads", action="store", dest="threads",
help="specify number of concurrent plugins to run"
" (default=4)", default=4, type=int)
+ parser.add_argument("--allow-system-changes", action="store_true",
+ dest="allow_system_changes", default=False,
+ help="Run commands even if they can change the "
+ "system (e.g. load kernel modules)")
# Group to make add/del preset exclusive
preset_grp = parser.add_mutually_exclusive_group()