diff options
author | Olivier Blin <oblin@mandriva.org> | 2004-06-24 05:32:13 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2004-06-24 05:32:13 +0000 |
commit | fb85fae46c73c7cab5d5965fa1281c76a8007bad (patch) | |
tree | 7513b5ae2b97773c0698086ef7ba98ef673ea242 | |
parent | fa6ef617411bdf2082f01cd02a977207f41840a8 (diff) | |
download | drakx-fb85fae46c73c7cab5d5965fa1281c76a8007bad.tar drakx-fb85fae46c73c7cab5d5965fa1281c76a8007bad.tar.gz drakx-fb85fae46c73c7cab5d5965fa1281c76a8007bad.tar.bz2 drakx-fb85fae46c73c7cab5d5965fa1281c76a8007bad.tar.xz drakx-fb85fae46c73c7cab5d5965fa1281c76a8007bad.zip |
properly handle ascii WEP keys (#9884)
-rw-r--r-- | perl-install/network/network.pm | 3 | ||||
-rw-r--r-- | perl-install/network/tools.pm | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 728e0f901..da773c8c2 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -168,7 +168,7 @@ sub write_interface_conf { $intf->{BOOTPROTO} =~ s/dhcp.*/dhcp/; - local $intf->{WIRELESS_ENC_KEY} = qq("$intf->{WIRELESS_ENC_KEY}") if $intf->{WIRELESS_ENC_KEY} !~ /"/; + local $intf->{WIRELESS_ENC_KEY} = network::tools::convert_wep_key_for_iwconfig($intf->{WIRELESS_ENC_KEY}); setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR MII_NOT_SUPPORTED), qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV), if_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_HOSTNAME NEEDHOSTNAME)) @@ -344,6 +344,7 @@ sub read_all_conf { if (/^ifcfg-([A-Za-z0-9.:]+)$/ && $1 ne 'lo') { my $intf = findIntf($intf, $1); add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") }); + $intf->{WIRELESS_ENC_KEY} = network::tools::get_wep_key_from_iwconfig($intf->{WIRELESS_ENC_KEY}); } } $netcnx->{type} or probe_netcnx_type($::prefix, $netc, $intf, $netcnx); diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index 4726e1350..e49e8dc2b 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -189,4 +189,21 @@ sub reread_net_conf { network::network::probe_netcnx_type('', $netc, $intf, $netcnx); } +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 ($key) = @_; + unquotify \$key; + member(length($key), (5, 13)) ? qq("s:$key") : qq("$key"); +} + +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)); + $key; +} + 1; |