Fix input error on generating password and salt in install script (#3051)

* Fix potential input error on password generation

This happens on macOS systems when a different locale is
explicitly set.

* Don't use a masked variable name
This commit is contained in:
Shrikant Sharat Kandula 2021-02-16 12:23:53 +05:30 committed by GitHub
parent 7e84c93282
commit b26706ca90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,8 +248,13 @@ urlencode() {
}
generate_password() {
# Picked up the following method of generation from : https://gist.github.com/earthgecko/3089509
LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 13 | head -n 1
local gen_string="$(/usr/bin/python -c 'import random, string; print("".join(random.choice(string.ascii_letters + string.digits) for _ in range(13)))' 2>/dev/null)"
if [[ -n $gen_string ]]; then
echo "$gen_string"
else
# Picked up the following method of generation from : https://gist.github.com/earthgecko/3089509
LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 13 | head -n 1
fi
}
confirm() {