Package: linux-wlan-ng Version: 0.2.5-1 Severity: normal Tags: patch
The linux-wlan-ng package (and the prism2 kernel modules) is very picky about how you enter the WEP key. It is of course documented somewhere that the format should be xx:xx:xx:xx:xx, but this is not obvious when using the Gnome Networking user interface. For other types of wireless cards, the wireless-tools library does a reformatting of the entered key in order to be more robust about how the user enters the key. linux-wlan-ng can easily do something similar to be as user friendly. The attached patch removes any delimiters that the users have entered and formats the key in pair of hex digits. The conversion supports any key length and is free of bashisms. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.16-2-486 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages linux-wlan-ng depends on: ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries ii udev 0.093-1 /dev/ and hotplug management daemo ii wireless-tools 28-1 Tools for manipulating Linux Wirel Versions of packages linux-wlan-ng recommends: pn linux-wlan-ng-doc <none> (no description available) -- no debconf information
--- linux-wlan-ng-pre-up.orig 2006-09-12 00:14:15.000000000 +0200 +++ linux-wlan-ng-pre-up 2006-09-15 00:23:24.000000000 +0200 @@ -125,6 +125,26 @@ fi done +# Make the WEP key xx:xx:xx:xx:xx +format_key() { + KEY="$1" + + # Don't touch a string key + if [ x$(printf "%.2s" "$KEY") != "xs:" ]; then + + # Strip any delimiters (all non-digits) + KEY=$(echo $KEY | tr -d -c '[:xdigit:]') + + # Inserts colon between pairs of hex digits + while [ ${#KEY} -gt 2 ]; do + NEWKEY=$(printf "%s%.2s:" "$NEWKEY" "$KEY") + KEY=${KEY#??} + done + KEY=${NEWKEY}${KEY} + fi + echo $KEY +} + if [ "$IF_WIRELESS_ENC" = "on" ]; then # Set up WEP. result=`$WLANCTL $IFACE dot11req_mibget mibattribute=dot11PrivacyOptionImplemented` @@ -173,16 +193,16 @@ done else $WLANCTL $IFACE dot11req_mibset \ - mibattribute=dot11WEPDefaultKey0=$IF_WLAN_NG_KEY0 \ + mibattribute=dot11WEPDefaultKey0=`format_key $IF_WLAN_NG_KEY0` \ >/dev/null $WLANCTL $IFACE dot11req_mibset \ - mibattribute=dot11WEPDefaultKey1=$IF_WLAN_NG_KEY1 \ + mibattribute=dot11WEPDefaultKey1=`format_key $IF_WLAN_NG_KEY1` \ >/dev/null $WLANCTL $IFACE dot11req_mibset \ - mibattribute=dot11WEPDefaultKey2=$IF_WLAN_NG_KEY2 \ + mibattribute=dot11WEPDefaultKey2=`format_key $IF_WLAN_NG_KEY2` \ >/dev/null $WLANCTL $IFACE dot11req_mibset \ - mibattribute=dot11WEPDefaultKey3=$IF_WLAN_NG_KEY3 \ + mibattribute=dot11WEPDefaultKey3=`format_key $IF_WLAN_NG_KEY3` \ >/dev/null fi fi