diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-09-15 04:02:23 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-09-15 04:02:23 +0000 |
commit | 972007c22ac6fdb2790a6125ebc881e91a332fc4 (patch) | |
tree | 96d81a997e6bac353a6616f174e2f73364fb85d0 /perl-install/network | |
parent | a655e543314efbad3a1bd70e193b43f0ecb81300 (diff) | |
download | drakx-972007c22ac6fdb2790a6125ebc881e91a332fc4.tar drakx-972007c22ac6fdb2790a6125ebc881e91a332fc4.tar.gz drakx-972007c22ac6fdb2790a6125ebc881e91a332fc4.tar.bz2 drakx-972007c22ac6fdb2790a6125ebc881e91a332fc4.tar.xz drakx-972007c22ac6fdb2790a6125ebc881e91a332fc4.zip |
better handling of ASCII WEP keys (partial fix for #18558)
Diffstat (limited to 'perl-install/network')
-rw-r--r-- | perl-install/network/wireless.pm | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/perl-install/network/wireless.pm b/perl-install/network/wireless.pm index d86482844..513c8a95e 100644 --- a/perl-install/network/wireless.pm +++ b/perl-install/network/wireless.pm @@ -22,12 +22,20 @@ sub is_wpa_supplicant_blacklisted { is_old_rt2x00($module); } +sub get_hex_key { + my ($key) = @_; + if ($key =~ /^([[:xdigit:]]{4}[\:-]?)+[[:xdigit:]]{2,}$/) { + $key =~ s/[\:-]//g; + return lc($key); + } +} + sub convert_wep_key_for_iwconfig { #- 5 or 13 characters, consider the key as ASCII and prepend "s:" #- else consider the key as hexadecimal, do not strip dashes #- always quote the key as string my ($real_key, $restricted) = @_; - my $key = member(length($real_key), (5, 13)) ? "s:$real_key" : $real_key; + my $key = get_hex_key($real_key) || "s:$real_key"; $restricted ? "restricted $key" : "open $key"; } @@ -35,19 +43,14 @@ sub get_wep_key_from_iwconfig { #- strip "s:" if the key is 5 or 13 characters (ASCII) #- else the key as hexadecimal, do not modify my ($key) = @_; - $key =~ s/^s:// if member(length($key), (7,15)); my ($mode, $real_key) = $key =~ /^(?:(open|restricted)\s+)?(.*)$/; + $real_key =~ s/^s://; ($real_key, $mode eq 'restricted'); } sub convert_key_for_wpa_supplicant { my ($key) = @_; - if ($key =~ /^([[:xdigit:]]{4}[\:-]?)+[[:xdigit:]]{2,}$/) { - $key =~ s/[\:-]//g; - return lc($key); - } else { - return qq("$key"); - } + get_hex_key($key) || qq("$key"); } sub wlan_ng_needed { |