[arch-projects] [netcfg] [PATCH 2/2] [scripts/wifi-menu]: Allow hex passphrase

Thomas Bächler thomas at archlinux.org
Tue Aug 7 16:11:49 EDT 2012


WPA allows the use of 64 digit hex passphrases. Allow this in wifi-menu as well.
---
 scripts/wifi-menu | 15 ++++++++++-----
 1 Datei geändert, 10 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/scripts/wifi-menu b/scripts/wifi-menu
index 4b1db24..f5d4857 100755
--- a/scripts/wifi-menu
+++ b/scripts/wifi-menu
@@ -112,12 +112,17 @@ create_profile()
         [[ "$OBSCURE" ]] && box="--insecure --passwordbox" || box="--inputbox"
         msg="Enter $security security key for\n'$1'"
         key=$(dialog $box "$msg" 10 40 --stdout) || return $?
-        [[ "${#key}" -ge 8 && "${#key}" -le 63 ]] || return 4
-        if [[ "$OBSCURE" ]]; then
-            key=$(wpa_passphrase "$1" "$key" | grep -m 1 "^[[:space:]]*psk=")
-            key="KEY=${key#*psk=}"
+        if [[ "${#key}" -ge 8 && "${#key}" -le 63 ]]; then
+            if [[ "$OBSCURE" ]]; then
+                key=$(wpa_passphrase "$1" "$key" | grep -m 1 "^[[:space:]]*psk=")
+                key="KEY=${key#*psk=}"
+            else
+                key="KEY='$(printf "%q" "$key")'"
+            fi
+        elif [[ "${#key}" -eq 64 && ${key} = +([0-9a-fA-F]) ]]; then
+            key="KEY=${key}"
         else
-            key="KEY='$(printf "%q" "$key")'"
+            return 4
         fi
     fi
     cat << EOF > "$PROFILE_DIR/$PROFILE"
-- 
1.7.11.4



More information about the arch-projects mailing list