[pkg-wpa-devel] r905 - in /wpasupplicant/trunk/debian: changelog ifupdown/functions.sh

kelmo-guest at users.alioth.debian.org kelmo-guest at users.alioth.debian.org
Fri Nov 30 11:22:48 UTC 2007


Author: kelmo-guest
Date: Fri Nov 30 11:22:47 2007
New Revision: 905

URL: http://svn.debian.org/wsvn/pkg-wpa/?sc=1&rev=905
Log:
* Overhaul wpa_key_check_and_set() function of functions.sh to better handle
  wep keys. Function now does similar checking of wep keys that it does for
  wpa keys. Valid wep keys can be hex of length 10|26|32|58 or ascii with
  length of at least 5.
* Check wpa_cli return value in wpa_cli() function of functions.sh.

Modified:
    wpasupplicant/trunk/debian/changelog
    wpasupplicant/trunk/debian/ifupdown/functions.sh

Modified: wpasupplicant/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/changelog?rev=905&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/changelog (original)
+++ wpasupplicant/trunk/debian/changelog Fri Nov 30 11:22:47 2007
@@ -1,9 +1,14 @@
-wpasupplicant (0.6.1~git20071119-2) unstable; urgency=low
+wpasupplicant (0.6.1~git20071119-2) UNRELEASED; urgency=low
 
   * Allow "wpa-key-mgmt NONE" to form a network block via the wpa_cli calls in
     wpa_conf() of functions.sh.
-
- -- Kel Modderman <kel at otaku42.de>  Fri, 30 Nov 2007 00:09:08 +1000
+  * Overhaul wpa_key_check_and_set() function of functions.sh to better handle
+    wep keys. Function now does similar checking of wep keys that it does for
+    wpa keys. Valid wep keys can be hex of length 10|26|32|58 or ascii with
+    length of at least 5.
+  * Check wpa_cli return value in wpa_cli() function of functions.sh.
+
+ -- Kel Modderman <kel at otaku42.de>  Fri, 30 Nov 2007 21:18:23 +1000
 
 wpasupplicant (0.6.1~git20071119-1) unstable; urgency=low
 

Modified: wpasupplicant/trunk/debian/ifupdown/functions.sh
URL: http://svn.debian.org/wsvn/pkg-wpa/wpasupplicant/trunk/debian/ifupdown/functions.sh?rev=905&op=diff
==============================================================================
--- wpasupplicant/trunk/debian/ifupdown/functions.sh (original)
+++ wpasupplicant/trunk/debian/ifupdown/functions.sh Fri Nov 30 11:22:47 2007
@@ -51,6 +51,8 @@
 #
 wpa_cli () {
 	$WPA_CLI_BIN -p $WPA_CTRL_DIR -i $WPA_IFACE "$@"
+
+	return $?
 }
 
 #####################################################################
@@ -370,6 +372,10 @@
 	wpa_msg action "$WPACLISET_DESC"
 	
 	wpa_cli $WPACLISET_VARIABLE "$WPACLISET_VALUE" >$TO_NULL
+
+	if [ "$?" -ne 0 ]; then
+		wpa_msg stderr "$WPACLISET_DESC failed!"
+	fi
 }
 
 #####################################################################
@@ -410,11 +416,11 @@
 # 256-bit hexadecimal key must be 64 characters in length
 #
 wpa_key_check_and_set () {
-	if [ -z "$1" ]; then
+	if [ "$#" -ne 3 ]; then
 		return 0
 	fi
 
-	local KEY KEY_TYPE
+	local KEY KEY_TYPE ENC_TYPE
 	
 	case "$1" in
 		'"'*'"')
@@ -426,20 +432,65 @@
 			;;
 	esac
 
-	if ishex "$KEY" && [ "${#KEY}" -eq "64" ]; then
-		KEY_TYPE="raw"
-	else
-		KEY_TYPE="ascii"
-		if [ "${#KEY}" -lt "8" ] || [ "${#KEY}" -gt "63" ]; then
-			wpa_msg stderr \
-				"plaintext or ascii wpa-psk has ${#KEY} characters, it must have between 8 and 63"
-			wpa_msg stderr \
-				"if wpa-psk truly is a 256-bit hexadecimal key, it must have 64 characters"
-		fi
-	fi
-	
-	wpa_cli_do "$KEY" "$KEY_TYPE" \
-		set_network psk wpa-psk
+	case "$2" in
+		wep_key*)
+			ENC_TYPE="WEP"
+			;;
+		psk)
+			ENC_TYPE="WPA"
+			;;
+		*)
+			return 0
+			;;
+	esac
+
+	if [ "$ENC_TYPE" = "WEP" ]; then
+		if ishex "$KEY"; then
+			case "${#KEY}" in
+				10|26|32|58)
+					# 64/128/152/256-bit WEP
+					KEY_TYPE="raw"
+					;;
+				*)
+					KEY_TYPE="ascii"
+					;;
+			esac
+		else
+			KEY_TYPE="ascii"
+		fi
+
+		if [ "$KEY_TYPE" = "ascii" ]; then
+			if [ "${#KEY}" -lt "5" ]; then
+				wpa_msg stderr "WARNING: plaintext or ascii WEP key has ${#KEY} characters,"
+				wpa_msg stderr "it must have at least 5 to be valid."
+			fi
+		fi
+	elif [ "$ENC_TYPE" = "WPA" ]; then
+		if ishex "$KEY"; then
+			case "${#KEY}" in
+				64)
+					# 256-bit WPA
+					KEY_TYPE="raw"
+					;;
+				*)
+					KEY_TYPE="ascii"
+					;;
+			esac
+		else
+			KEY_TYPE="ascii"
+		fi
+
+		if [ "$KEY_TYPE" = "ascii" ]; then
+			if [ "${#KEY}" -lt "8" ] || [ "${#KEY}" -gt "63" ]; then
+				wpa_msg stderr "WARNING: plaintext or ascii WPA key has ${#KEY} characters,"
+				wpa_msg stderr "it must have between 8 and 63 to be valid."
+				wpa_msg stderr "If the WPA key is a 256-bit hexadecimal key, it must have"
+				wpa_msg stderr "exactly 64 characters."
+			fi
+		fi
+	fi
+
+	wpa_cli_do "$KEY" "$KEY_TYPE" set_network "$2" "$3"
 }
 
 #####################################################################
@@ -510,7 +561,8 @@
 		fi
 	
 		if [ -n "$IF_WPA_PSK" ]; then
-			wpa_key_check_and_set "$IF_WPA_PSK"
+			wpa_key_check_and_set "$IF_WPA_PSK" \
+				psk wpa-psk
 		fi
 		
 		wpa_cli_do "$IF_WPA_PAIRWISE" raw \
@@ -630,17 +682,25 @@
 		wpa_cli_do "$IF_WPA_EAPOL_FLAGS" raw \
 			set_network eapol_flags wpa-eapol-flags
 		
-		wpa_cli_do "$IF_WPA_WEP_KEY0" raw \
-			set_network wep_key0 wpa-wep-key0
-		
-		wpa_cli_do "$IF_WPA_WEP_KEY1" raw \
-			set_network wep_key1 wpa-wep-key1
-		
-		wpa_cli_do "$IF_WPA_WEP_KEY2" raw \
-			set_network wep_key2 wpa-wep-key2
-		
-		wpa_cli_do "$IF_WPA_WEP_KEY3" raw \
-			set_network wep_key3 wpa-wep-key3
+		if [ -n "$IF_WPA_WEP_KEY0" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY0" \
+				wep_key0 wpa-wep-key0
+		fi
+		
+		if [ -n "$IF_WPA_WEP_KEY1" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY1" \
+				wep_key1 wpa-wep-key1
+		fi
+
+		if [ -n "$IF_WPA_WEP_KEY2" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY2" \
+				wep_key2 wpa-wep-key2
+		fi
+
+		if [ -n "$IF_WPA_WEP_KEY3" ]; then
+			wpa_key_check_and_set "$IF_WPA_WEP_KEY3" \
+				wep_key3 wpa-wep-key3
+		fi
 		
 		wpa_cli_do "$IF_WPA_WEP_TX_KEYIDX" raw \
 			set_network wep_tx_keyidx wpa-wep-tx-keyidx




More information about the Pkg-wpa-devel mailing list