Merge pull request #20037 from Homebrew/move_sudo_reset_timestamp

brew.sh: move sudo reset timestamp.
This commit is contained in:
Mike McQuaid 2025-06-03 01:27:47 +00:00 committed by GitHub
commit a0c89e4a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 16 deletions

View File

@ -1078,6 +1078,22 @@ else
export HOMEBREW_GITHUB_PACKAGES_AUTH="Bearer QQ==" export HOMEBREW_GITHUB_PACKAGES_AUTH="Bearer QQ=="
fi fi
# Avoid picking up any random `sudo` in `PATH`.
if [[ -x /usr/bin/sudo ]]
then
SUDO=/usr/bin/sudo
else
# Do this after ensuring we're using default Bash builtins.
SUDO="$(command -v sudo 2>/dev/null)"
fi
# Reset sudo timestamp to avoid running unauthorized sudo commands
if [[ -n "${SUDO}" ]]
then
"${SUDO}" --reset-timestamp 2>/dev/null || true
fi
unset SUDO
if [[ -n "${HOMEBREW_BASH_COMMAND}" ]] if [[ -n "${HOMEBREW_BASH_COMMAND}" ]]
then then
# source rather than executing directly to ensure the entire file is read into # source rather than executing directly to ensure the entire file is read into

View File

@ -57,22 +57,6 @@ do
done done
unset cmd unset cmd
# Avoid picking up any random `sudo` in `PATH`.
if [[ -x /usr/bin/sudo ]]
then
SUDO=/usr/bin/sudo
else
# Do this after ensuring we're using default Bash builtins.
SUDO="$(command -v sudo 2>/dev/null)"
fi
# Reset sudo timestamp to avoid running unauthorized sudo commands
if [[ -n "${SUDO}" ]]
then
"${SUDO}" --reset-timestamp 2>/dev/null || true
fi
unset SUDO
# Take the HOMEBREW_PATH if we are running brew within brew, otherwise we would lose the original path. # Take the HOMEBREW_PATH if we are running brew within brew, otherwise we would lose the original path.
if [[ -n "${HOMEBREW_BREW_FILE:-}" && -n "${HOMEBREW_PATH:-}" ]] if [[ -n "${HOMEBREW_BREW_FILE:-}" && -n "${HOMEBREW_PATH:-}" ]]
then then