Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Line #1158 of /usr/sbin/wag-profiles.sh
- # http://www.pearltrees.com/s243a/getwpapsk-profiles-puppylinux/id16403226
- # A function to get the psk from wpa_passphrase (moved out of useWpaSupplicant
- getWpaPSK(){
- # If key is not hex, then convert to hex
- echo "$PROFILE_KEY" | grep -Eq "^[0-9a-fA-F]{64}$"
- if [ $? -eq 0 ] ; then
- PSK="$PROFILE_KEY"
- else
- #KEY_SIZE=`echo "${PROFILE_KEY}" | wc -c`
- KEY_SIZE=${#PROFILE_KEY}
- if [ $KEY_SIZE -lt 8 ] || [ $KEY_SIZE -gt 64 ] ; then
- giveErrorDialog "Error!
- Shared key must be either
- - ASCII between 8 and 63 characters
- - 64 characters hexadecimal
- "
- return 1
- else #if [ $KEY_SIZE -lt 8 ] || [ $KEY_SIZE -gt 64 ]
- # Dougal: add escaping of funny chars in passphrase
- # also quote the inner subshell
- # No! don't need subshell apparently, escaping chars is unneeded
- #"$( echo "$PROFILE_KEY" | sed 's%\$%\\$%g ; s%`%\\`%g ; s%"%\\"%g' )"
- ## Strage: the first grep below was enough for me, but a user got
- ##+ errors, because it didn't filter out the "#psk" line!
- PSK=$(wpa_passphrase "$PROFILE_ESSID" "$PROFILE_KEY" | \
- grep -F "psk=" | grep -Fv '#psk' | cut -d"=" -f2 )
- echo "PSK is |$PSK|" >> $DEBUG_OUTPUT
- # make sure we got something!
- if [ ! "$PSK" ] ; then
- giveErrorDialog "$L_MESSAGE_Bad_PSK"
- return 1
- fi
- fi #if [ $KEY_SIZE -lt 8 ] || [ $KEY_SIZE -gt 64 ] ; then
- fi #if [ $? -eq 0 ] ; then #check for hex
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement