mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #118628 from dims/check-before-you-sudo
check before you sudo on AWS EC2 instances
This commit is contained in:
commit
e436472e24
@ -207,6 +207,8 @@ else
|
|||||||
# Refresh sudo credentials if needed
|
# Refresh sudo credentials if needed
|
||||||
if ping -c 1 -q metadata.google.internal &> /dev/null; then
|
if ping -c 1 -q metadata.google.internal &> /dev/null; then
|
||||||
echo 'Running on GCE, not asking for sudo credentials'
|
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
|
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
|
# 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
|
# we can run any command without a password, or that sudo credentials
|
||||||
|
Loading…
Reference in New Issue
Block a user