Skip to content

Commit 5322439

Browse files
author
fack
committed
added support for curl --retry
1 parent a9e1989 commit 5322439

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

rustup-init.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ downloader() {
473473
local _ciphersuites
474474
local _err
475475
local _status
476+
local _retry
476477
if check_cmd curl; then
477478
_dld=curl
478479
elif check_cmd wget; then
@@ -484,10 +485,12 @@ downloader() {
484485
if [ "$1" = --check ]; then
485486
need_cmd "$_dld"
486487
elif [ "$_dld" = curl ]; then
488+
check_curl_for_retry_support
489+
_retry="$RETVAL"
487490
get_ciphersuites_for_curl
488491
_ciphersuites="$RETVAL"
489492
if [ -n "$_ciphersuites" ]; then
490-
_err=$(curl --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)
493+
_err=$(curl $_retry --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)
491494
_status=$?
492495
else
493496
echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
@@ -589,8 +592,19 @@ check_help_for() {
589592
true # not strictly needed
590593
}
591594

595+
# Check if curl supports the --retry flag, then pass it to the curl invocation.
596+
check_curl_for_retry_support() {
597+
# "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
598+
if check_help_for "notspecified" "curl" "--retry"; then
599+
local _retry_supported="--retry 3"
600+
fi
601+
602+
RETVAL="$_retry_supported"
603+
604+
}
605+
592606
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
593-
# if support by local tools is detected. Detection currently supports these curl backends:
607+
# if support by local tools is detected. Detection currently supports these curl backends:
594608
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
595609
get_ciphersuites_for_curl() {
596610
if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then
@@ -635,7 +649,7 @@ get_ciphersuites_for_curl() {
635649
}
636650

637651
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
638-
# if support by local tools is detected. Detection currently supports these wget backends:
652+
# if support by local tools is detected. Detection currently supports these wget backends:
639653
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.
640654
get_ciphersuites_for_wget() {
641655
if [ -n "${RUSTUP_TLS_CIPHERSUITES-}" ]; then
@@ -660,10 +674,10 @@ get_ciphersuites_for_wget() {
660674
RETVAL="$_cs"
661675
}
662676

663-
# Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2
664-
# excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad
677+
# Return strong TLS 1.2-1.3 cipher suites in OpenSSL or GnuTLS syntax. TLS 1.2
678+
# excludes non-ECDHE and non-AEAD cipher suites. DHE is excluded due to bad
665679
# DH params often found on servers (see RFC 7919). Sequence matches or is
666-
# similar to Firefox 68 ESR with weak cipher suites disabled via about:config.
680+
# similar to Firefox 68 ESR with weak cipher suites disabled via about:config.
667681
# $1 must be openssl or gnutls.
668682
get_strong_ciphersuites_for() {
669683
if [ "$1" = "openssl" ]; then
@@ -673,7 +687,7 @@ get_strong_ciphersuites_for() {
673687
# GnuTLS isn't forgiving of unknown values, so this may require a GnuTLS version that supports TLS 1.3 even if wget doesn't.
674688
# Begin with SECURE128 (and higher) then remove/add to build cipher suites. Produces same 9 cipher suites as OpenSSL but in slightly different order.
675689
echo "SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-VERS-DTLS-ALL:-CIPHER-ALL:-MAC-ALL:-KX-ALL:+AEAD:+ECDHE-ECDSA:+ECDHE-RSA:+AES-128-GCM:+CHACHA20-POLY1305:+AES-256-GCM"
676-
fi
690+
fi
677691
}
678692

679693
main "$@" || exit 1

0 commit comments

Comments
 (0)