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 <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
changes/08/4175408/4
Aravind Vasudevan 2 years ago committed by LUCI CQ
parent 86cfa62b07
commit 7b1f98e9c6

@ -222,6 +222,11 @@ def _run_subprocess(cmd, interactive=False, env=None):
return subprocess.run(cmd, **kwargs) 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): def run_gsutil(target, args, clean=False):
# Redirect gsutil config calls to luci-auth. # Redirect gsutil config calls to luci-auth.
if os.getenv(GSUTIL_ENABLE_LUCI_AUTH) == '1' and 'config' in args: 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. # 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() 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('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 _run_subprocess(cmd, interactive=True).returncode
return luci_context(cmd).returncode return luci_context(cmd).returncode

Loading…
Cancel
Save