From 7b1f98e9c638a8d581948c1eae666b90e303312e Mon Sep 17 00:00:00 2001 From: Aravind Vasudevan Date: Wed, 18 Jan 2023 17:34:15 +0000 Subject: [PATCH] Skip reauthentication when ~/.boto file is present This fix skips luci-auth ~/.boto file is already present. Bug: 1407306, 1359383 Change-Id: I333b6baf693bfed295a2467c7a543432111be4dd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4175408 Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic Auto-Submit: Aravind Vasudevan --- gsutil.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gsutil.py b/gsutil.py index 9363d64e3..5d93783cf 100755 --- a/gsutil.py +++ b/gsutil.py @@ -222,6 +222,11 @@ def _run_subprocess(cmd, interactive=False, env=None): return subprocess.run(cmd, **kwargs) +def is_boto_present(): + """Returns true if the .boto file is present in the default path.""" + return os.path.isfile(os.path.join(os.path.expanduser('~'), '.boto')) + + def run_gsutil(target, args, clean=False): # Redirect gsutil config calls to luci-auth. if os.getenv(GSUTIL_ENABLE_LUCI_AUTH) == '1' and 'config' in args: @@ -259,7 +264,7 @@ def run_gsutil(target, args, clean=False): # Bypass luci-auth when run within a bot or .boto file is set. if (os.getenv(GSUTIL_ENABLE_LUCI_AUTH) != '1' or _is_luci_context() or os.getenv('SWARMING_HEADLESS') == '1' or os.getenv('BOTO_CONFIG') - or os.getenv('AWS_CREDENTIAL_FILE')): + or os.getenv('AWS_CREDENTIAL_FILE') or is_boto_present()): return _run_subprocess(cmd, interactive=True).returncode return luci_context(cmd).returncode