Browse code

Merge "Allow only aphanum chars in user-entered passwords"

Jenkins authored on 2011/12/31 03:34:12
Showing 1 changed files
... ...
@@ -247,12 +247,17 @@ function read_password {
247 247
         echo '################################################################################'
248 248
         echo $msg
249 249
         echo '################################################################################'
250
-        echo "This value will be written to your localrc file so you don't have to enter it again."
251
-        echo "It is probably best to avoid spaces and weird characters."
250
+        echo "This value will be written to your localrc file so you don't have to enter it "
251
+        echo "again.  Use only alphanumeric characters."
252 252
         echo "If you leave this blank, a random default value will be used."
253
-        echo "Enter a password now:"
254
-        read -e $var
255
-        pw=${!var}
253
+        pw=" "
254
+        while true; do
255
+            echo "Enter a password now:"
256
+            read -e $var
257
+            pw=${!var}
258
+            [[ "$pw" = "`echo $pw | tr -cd [:alnum:]`" ]] && break
259
+            echo "Invalid chars in password.  Try again:"
260
+        done
256 261
         if [ ! $pw ]; then
257 262
             pw=`openssl rand -hex 10`
258 263
         fi