diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-02-24 17:32:10 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-02-24 17:32:10 +0000 |
commit | 0c79fff50fec0ee6b462b4654cc845f718da7a2f (patch) | |
tree | 31d60979bf6f5c3073bb0da92935413b35ae43b0 /perl-install | |
parent | 4ae35537d7361c603756b81ccce5c4ac5072f73e (diff) | |
download | drakx-backup-do-not-use-0c79fff50fec0ee6b462b4654cc845f718da7a2f.tar drakx-backup-do-not-use-0c79fff50fec0ee6b462b4654cc845f718da7a2f.tar.gz drakx-backup-do-not-use-0c79fff50fec0ee6b462b4654cc845f718da7a2f.tar.bz2 drakx-backup-do-not-use-0c79fff50fec0ee6b462b4654cc845f718da7a2f.tar.xz drakx-backup-do-not-use-0c79fff50fec0ee6b462b4654cc845f718da7a2f.zip |
minimal WPA support
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/network/netconnect.pm | 2 | ||||
-rw-r--r-- | perl-install/network/network.pm | 33 | ||||
-rw-r--r-- | perl-install/network/tools.pm | 11 |
3 files changed, 37 insertions, 9 deletions
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index 479bc4f5c..a7858939b 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -1132,6 +1132,7 @@ notation (for example, 1.2.3.4).")), { label => N("Sensitivity threshold"), val => \$ethntf->{WIRELESS_SENS}, advanced => 1 }, { label => N("Bitrate (in b/s)"), val => \$ethntf->{WIRELESS_RATE}, advanced => 1 }, { label => N("Encryption key"), val => \$ethntf->{WIRELESS_ENC_KEY} }, + { text => N("Use Wi-Fi Protected Access (WPA)"), val => \$ethntf->{WIRELESS_USE_WPA}, type => "bool" }, ]; }, complete => sub { @@ -1197,6 +1198,7 @@ See iwpriv(8) man page for further information."), # untranslate parameters $ethntf->{WIRELESS_MODE} = $wireless_mode{$ethntf->{WIRELESS_MODE}}; $module =~ /^prism2_/ and network::network::wlan_ng_configure($in, $ethntf, $module); + network::network::wpa_supplicant_configure($in, $ethntf); return "static_hostname"; }, }, diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index ff1641d75..c604945b6 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -521,6 +521,23 @@ sub wlan_ng_configure { services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan'); } +sub wpa_supplicant_configure { + my ($in, $ethntf) = @_; + require services; + if (delete $ethntf->{WIRELESS_USE_WPA}) { + $in->do_pkgs->install('wpa_supplicant'); + wpa_supplicant_add_network({ + ssid => qq("$ethntf->{WIRELESS_ESSID}"), + psk => network::tools::convert_key_for_wpa_supplicant($ethntf->{WIRELESS_ENC_KEY}), + }); + services::start_service_on_boot("tmdns"); + services::restart('wpa_supplicant'); + } else { + services::stop("tmdns"); + services::do_not_start_service_on_boot("tmdns"); + } +} + sub wpa_supplicant_add_network { my ($new_network) = @_; my $wpa_supplicant_conf = "$::prefix/etc/wpa_supplicant.conf"; @@ -529,12 +546,12 @@ sub wpa_supplicant_add_network { foreach (cat_($wpa_supplicant_conf)) { if (%network) { #- in a "network = {}" block - if (/^\s*(\w+)\s*=\s*(.*?)(\s*#.*)?$/) { + if (/^\s*(\w+)=(.*?)(\s*#.*)?$/) { push @{$network{entries}}, { key => $1, value => $2, comment => $3 }; $1 eq 'ssid' and $network{ssid} = $2; } elsif (/^·*\}/) { #- end of network block, write it - $s .= "network = { $network{comment}\n"; + $s .= "network={$network{comment}\n"; my $update = $network{ssid} eq $new_network->{ssid}; foreach (@{$network{entries}}) { my $key = $_->{key}; @@ -545,14 +562,14 @@ sub wpa_supplicant_add_network { $_->{value} = delete $new_network->{$key}; } if ($key) { - $s .= " $key = $_->{value}$_->{comment}\n"; + $s .= " $key=$_->{value}$_->{comment}\n"; } else { $s .= " $_->{comment}\n"; } } if ($update) { while (my ($key, $value) = each(%$new_network)) { - $s .= " $key = $value\n"; + $s .= " $key=$value\n"; } } $s .= "}\n"; @@ -563,7 +580,7 @@ sub wpa_supplicant_add_network { push @{$network{entries}}, { comment => $_ }; } } else { - if (/^\s*network\s*=\s*\{(.*)/) { + if (/^\s*network={(.*)/) { #- beginning of a new network block $network{comment} = $1; } else { @@ -574,13 +591,13 @@ sub wpa_supplicant_add_network { } if ($new_network) { #- network wasn't found, write it - $s .= "\nnetwork = {\n"; + $s .= "\nnetwork={\n"; #- write ssid first if (my $ssid = delete $new_network->{ssid}) { - $s .= " ssid = $ssid\n"; + $s .= " ssid=$ssid\n"; } while (my ($key, $value) = each(%$new_network)) { - $s .= " $key = $value\n"; + $s .= " $key=$value\n"; } $s .= "}\n"; } diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index 411e37267..052b0d430 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -203,7 +203,7 @@ sub is_dynamic_host { 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 + #- else consider the key as hexadecimal, do not strip dashes #- always quote the key as string my ($key) = @_; member(length($key), (5, 13)) ? "s:$key" : $key; @@ -217,6 +217,15 @@ sub get_wep_key_from_iwconfig { $key; } +sub convert_key_for_wpa_supplicant { + my ($key) = @_; + if ($key =~ /^([[:xdigit:]]{4}[\:-])+[[:xdigit:]]{2,}$/) { + $key =~ s/[\:-]//g; + return lc($key); + } else { + return qq("$key"); + } +} #- returns interface whose IP address matchs given IP address, according to its network mask sub find_matching_interface { |