Replace random string generation method with OpenSSL for better randomness in install.sh

The previous implementation using cat /dev/urandom | tr caused tr to hang and consume 100% CPU on certain environments (e.g., GCP, specific kernels) due to delayed SIGPIPE handling. Using openssl provides a finite, cryptographically secure string that eliminates this CPU spike and is noticeably faster."
This commit is contained in:
Yunheng Liu 2026-03-04 22:13:08 -05:00 committed by GitHub
parent a2097ad062
commit b01a71f32d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,8 +105,10 @@ install_base() {
gen_random_string() { gen_random_string() {
local length="$1" local length="$1"
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1) # openssl output base64no need /dev/urandom + tr
echo "$random_string" openssl rand -base64 $(( length * 2 )) \
| tr -dc 'a-zA-Z0-9' \
| head -c "$length"
} }
install_acme() { install_acme() {