Fix escaping stuff in for password of client key

Was overzealously escaping... oops
This commit is contained in:
Kaladin Light 2016-11-11 21:55:47 -05:00
parent 7d34c0cae6
commit 2468c69d9a

View file

@ -52,11 +52,11 @@ function keyPASS() {
printf "Enter the password again to verify: " printf "Enter the password again to verify: "
read -r PASSWD2 read -r PASSWD2
printf "\n" printf "\n"
[ "$PASSWD" = "$PASSWD2" ] && break [ "${PASSWD}" = "${PASSWD2}" ] && break
printf "Passwords do not match! Please try again.\n" printf "Passwords do not match! Please try again.\n"
done done
stty echo stty echo
if [[ -z "$PASSWD" ]]; then if [[ -z "${PASSWD}" ]]; then
echo "You left the password blank" echo "You left the password blank"
echo "If you don't want a password, please run:" echo "If you don't want a password, please run:"
echo "pivpn add nopass" echo "pivpn add nopass"
@ -69,15 +69,15 @@ function keyPASS() {
fi fi
#Escape chars in PASSWD #Escape chars in PASSWD
PASSWD=$(echo -n $PASSWD | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/\$/\\\$/g' -e 's/!/\\!/g' -e 's/\./\\\./g' -e "s/'/\\\'/g" -e 's/"/\\"/g' -e 's/\*/\\\*/g' -e 's/\@/\\\@/g' -e 's/\#/\\\#/g' -e 's/£/\\£/g' -e 's/%/\\%/g' -e 's/\^/\\\^/g' -e 's/\&/\\\&/g' -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/-/\\-/g' -e 's/_/\\_/g' -e 's/\+/\\\+/g' -e 's/=/\\=/g' -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' -e 's/;/\\;/g' -e 's/:/\\:/g' -e 's/|/\\|/g' -e 's/</\\</g' -e 's/>/\\>/g' -e 's/,/\\,/g' -e 's/?/\\?/g' -e 's/~/\\~/g' -e 's/{/\\{/g' -e 's/}/\\}/g') PASSWD=$(echo -n ${PASSWD} | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/\$/\\\$/g' -e 's/!/\\!/g' -e 's/\./\\\./g' -e "s/'/\\\'/g" -e 's/"/\\"/g' -e 's/\*/\\\*/g' -e 's/\@/\\\@/g' -e 's/\#/\\\#/g' -e 's/£/\\£/g' -e 's/%/\\%/g' -e 's/\^/\\\^/g' -e 's/\&/\\\&/g' -e 's/(/\\(/g' -e 's/)/\\)/g' -e 's/-/\\-/g' -e 's/_/\\_/g' -e 's/\+/\\\+/g' -e 's/=/\\=/g' -e 's/\[/\\\[/g' -e 's/\]/\\\]/g' -e 's/;/\\;/g' -e 's/:/\\:/g' -e 's/|/\\|/g' -e 's/</\\</g' -e 's/>/\\>/g' -e 's/,/\\,/g' -e 's/?/\\?/g' -e 's/~/\\~/g' -e 's/{/\\{/g' -e 's/}/\\}/g')
#Build the client key and then encrypt the key #Build the client key and then encrypt the key
expect << EOF expect << EOF
set timeout -1 set timeout -1
spawn ./build-key-pass "$NAME" spawn ./build-key-pass "$NAME"
expect "Enter PEM pass phrase" { send "\\\$PASSWD\\r" } expect "Enter PEM pass phrase" { send "${PASSWD}\r" }
expect "Verifying - Enter PEM pass phrase" { send "\\\$PASSWD\\r" } expect "Verifying - Enter PEM pass phrase" { send "${PASSWD}\r" }
expect "Country Name" { send "\r" } expect "Country Name" { send "\r" }
expect "State or Province Name" { send "\r" } expect "State or Province Name" { send "\r" }
expect "Locality Name" { send "\r" } expect "Locality Name" { send "\r" }
@ -98,9 +98,9 @@ EOF
expect << EOF expect << EOF
set timeout -1 set timeout -1
spawn openssl rsa -in "$NAME$OKEY" -des3 -out "$NAME$KEY" spawn openssl rsa -in "$NAME$OKEY" -des3 -out "$NAME$KEY"
expect "Enter pass phrase for" { send "\\\$PASSWD\\r" } expect "Enter pass phrase for" { send "${PASSWD}\r" }
expect "Enter PEM pass phrase" { send "\\\$PASSWD\\r" } expect "Enter PEM pass phrase" { send "${PASSWD}\r" }
expect "Verifying - Enter PEM pass" { send "\\\$PASSWD\\r" } expect "Verifying - Enter PEM pass" { send "${PASSWD}\r" }
expect eof expect eof
EOF EOF
} }