Skip to content

Commit

Permalink
[sosreport] add option --allow-system-changes
Browse files Browse the repository at this point in the history
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: sosreport#1435

Signed-off-by: Pavel Moravec <[email protected]>
  • Loading branch information
pmoravec committed Jun 13, 2019
1 parent fc41da4 commit 2f5f49d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
21 changes: 11 additions & 10 deletions sos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def _default(msg):

#: 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
Expand Down Expand Up @@ -179,6 +179,7 @@ def __init__(self, **kwargs):
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 = []
Expand Down Expand Up @@ -219,9 +220,9 @@ def _opt_to_args(cls, opt, val):
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:
Expand Down
5 changes: 4 additions & 1 deletion sos/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,10 @@ def get_option(self, optionname, default=0):
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)
Expand Down
4 changes: 4 additions & 0 deletions sos/sosreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2f5f49d

Please sign in to comment.