mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #20037 from Homebrew/move_sudo_reset_timestamp
brew.sh: move sudo reset timestamp.
This commit is contained in:
commit
a0c89e4a7f
@ -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
|
||||||
|
16
bin/brew
16
bin/brew
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user