From c77d1697a771d23426e9e60e3c7c4fed17ef80be Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 28 Jan 2023 11:08:20 -0500 Subject: [PATCH] Revert "Improve error messages in the management tools when external command-line tools are run" Command line arguments have user secrets in some cases which should not be included in error messages. This reverts commit 26709a3c1dba9cadbd88636b002d95c2f6bd2b14. Reported by AK. --- CHANGELOG.md | 5 +++++ management/utils.py | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d86ce6..2f154d1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +In Development +-------------- + +* Reverted "Improve error messages in the management tools when external command-line tools are run." because of the possibility of user secrets being included in error messages. + Version 61 (January 21, 2023) ----------------------------- diff --git a/management/utils.py b/management/utils.py index f452c16d..b5ca7e59 100644 --- a/management/utils.py +++ b/management/utils.py @@ -122,16 +122,13 @@ def shell(method, cmd_args, env={}, capture_stderr=False, return_bytes=False, tr if method == "check_output" and input is not None: kwargs['input'] = input - try: + if not trap: ret = getattr(subprocess, method)(cmd_args, **kwargs) - code = 0 - except subprocess.CalledProcessError as e: - if not trap: - # Reformat exception. - msg = "Command failed with exit code {}: {}".format(e.returncode, subprocess.list2cmdline(cmd_args)) - if e.output: msg += "\n\nOutput:\n" + e.output - raise Exception(msg) - else: + else: + try: + ret = getattr(subprocess, method)(cmd_args, **kwargs) + code = 0 + except subprocess.CalledProcessError as e: ret = e.output code = e.returncode if not return_bytes and isinstance(ret, bytes): ret = ret.decode("utf8")