From b26706ca90d33a52dbf9106eb46172bb7f4b52b9 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Tue, 16 Feb 2021 12:23:53 +0530 Subject: [PATCH] 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 --- deploy/install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/deploy/install.sh b/deploy/install.sh index 87bf0aa7d5..7cc343ff44 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -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() {