Merge pull request #118628 from dims/check-before-you-sudo

check before you sudo on AWS EC2 instances
This commit is contained in:
Kubernetes Prow Robot 2023-06-14 14:14:17 -07:00 committed by GitHub
commit e436472e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,6 +207,8 @@ else
# Refresh sudo credentials if needed
if ping -c 1 -q metadata.google.internal &> /dev/null; then
echo 'Running on GCE, not asking for sudo credentials'
elif ping -c 1 -q 169.254.169.254 &> /dev/null; then
echo 'Running on AWS, not asking for sudo credentials'
elif sudo --non-interactive "$(which bash)" -c true 2> /dev/null; then
# if we can run bash without a password, it's a pretty safe bet that either
# we can run any command without a password, or that sudo credentials