Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:Update
salt.22687
support-config-non-root-permission-issues-fixes...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File support-config-non-root-permission-issues-fixes-u-50.patch of Package salt.22687
From 8c7ee66166b9b5a47cdd5150a0db35052e5afbac Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Wed, 17 Oct 2018 14:10:47 +0200 Subject: [PATCH] Support-config non-root permission issues fixes (U#50095) Do not crash if there is no configuration available at all Handle CLI and log errors Catch overwriting exiting archive error by other users Suppress excessive tracebacks on error log level --- salt/cli/support/collector.py | 43 +++++++++++++++++++++++++++++++---- salt/utils/parsers.py | 2 +- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/salt/cli/support/collector.py b/salt/cli/support/collector.py index bfbf491f5b..a08a0b8c6e 100644 --- a/salt/cli/support/collector.py +++ b/salt/cli/support/collector.py @@ -124,6 +124,31 @@ class SupportDataCollector: self.__current_section = [] self.__current_section_name = name + def _printout(self, data, output): + """ + Use salt outputter to printout content. + + :return: + """ + opts = {"extension_modules": "", "color": False} + try: + printout = salt.output.get_printout(output, opts)(data) + if printout is not None: + return printout.rstrip() + except (KeyError, AttributeError, TypeError) as err: + log.debug(err, exc_info=True) + try: + printout = salt.output.get_printout("nested", opts)(data) + if printout is not None: + return printout.rstrip() + except (KeyError, AttributeError, TypeError) as err: + log.debug(err, exc_info=True) + printout = salt.output.get_printout("raw", opts)(data) + if printout is not None: + return printout.rstrip() + + return salt.output.try_printout(data, output, opts) + def write(self, title, data, output=None): """ Add a data to the current opened section. @@ -137,9 +162,7 @@ class SupportDataCollector: try: if isinstance(data, dict) and "return" in data: data = data["return"] - content = salt.output.try_printout( - data, output, {"extension_modules": "", "color": False} - ) + content = self._printout(data, output) except Exception: # Fall-back to just raw YAML content = None else: @@ -436,7 +459,11 @@ class SaltSupport(salt.utils.parsers.SaltSupportOptionParser): and os.path.exists(self.config["support_archive"]) ): self.out.warning("Terminated earlier, cleaning up") - os.unlink(self.config["support_archive"]) + try: + os.unlink(self.config["support_archive"]) + except Exception as err: + log.debug(err) + self.out.error("{} while cleaning up.".format(err)) def _check_existing_archive(self): """ @@ -452,7 +479,13 @@ class SaltSupport(salt.utils.parsers.SaltSupportOptionParser): self.config["support_archive"] ) ) - os.unlink(self.config["support_archive"]) + try: + os.unlink(self.config["support_archive"]) + except Exception as err: + log.debug(err) + self.out.error( + "{} while trying to overwrite existing archive.".format(err) + ) ret = True else: self.out.warning( diff --git a/salt/utils/parsers.py b/salt/utils/parsers.py index c1422a9556..cea59b387e 100644 --- a/salt/utils/parsers.py +++ b/salt/utils/parsers.py @@ -2157,7 +2157,7 @@ class SaltSupportOptionParser( """ _opts, _args = optparse.OptionParser.parse_args(self) configs = self.find_existing_configs(_opts.support_unit) - if cfg not in configs: + if configs and cfg not in configs: cfg = configs[0] return config.master_config(self.get_config_file_path(cfg)) -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor