From 4e6a2b71e398d34267a3aec93fa2f261855ab774 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 29 Dec 2011 17:27:45 -0600 Subject: [PATCH] Allow only aphanum chars in user-entered passwords Fixes bug 885345 Change-Id: Ib41319676d2fd24144a1493bd58543ad71eb8d6c --- stack.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stack.sh b/stack.sh index 19543ca6e0..4307d1f82f 100755 --- a/stack.sh +++ b/stack.sh @@ -244,12 +244,17 @@ function read_password { echo '################################################################################' echo $msg echo '################################################################################' - echo "This value will be written to your localrc file so you don't have to enter it again." - echo "It is probably best to avoid spaces and weird characters." + echo "This value will be written to your localrc file so you don't have to enter it " + echo "again. Use only alphanumeric characters." echo "If you leave this blank, a random default value will be used." - echo "Enter a password now:" - read -e $var - pw=${!var} + pw=" " + while true; do + echo "Enter a password now:" + read -e $var + pw=${!var} + [[ "$pw" = "`echo $pw | tr -cd [:alnum:]`" ]] && break + echo "Invalid chars in password. Try again:" + done if [ ! $pw ]; then pw=`openssl rand -hex 10` fi