diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-04-24 21:46:43 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-04-24 21:46:43 +0000 |
commit | 1155fe22f750d0ee446b6a729cd574c2b068e480 (patch) | |
tree | f8e627a8b46516aae094b2d5b953891a253f68df | |
parent | 5c0448ea44d1b03b528fd8d378062037640b5153 (diff) | |
download | drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.gz drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.bz2 drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.xz drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.zip |
handle errors in wireless packages installation, simplify
-rw-r--r-- | perl-install/network/netconnect.pm | 12 | ||||
-rw-r--r-- | perl-install/network/wireless.pm | 70 |
2 files changed, 46 insertions, 36 deletions
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index d3cb57b5c..b753de5e2 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -1277,6 +1277,14 @@ See iwpriv(8) man page for further information."), $in->ask_warn(N("Error"), N("Rate should have the suffix k, M or G (for example, \"11M\" for 11M), or add enough '0' (zeroes).")); return 1, 8; } + if (network::wireless::wlan_ng_needed($module) && !$in->do_pkgs->ensure_is_installed('prism2-utils', '/sbin/wlanctl-ng')) { + $in->ask_warn(N("Error"), N("Could not install the %s package!", 'prism2-utils')); + return 1; + } + if ($wireless_enc_mode eq 'wpa-psk' && !$in->do_pkgs->ensure_is_installed('wpa_supplicant', '/usr/sbin/wpa_supplicant')) { + $in->ask_warn(N("Error"), N("Could not install the %s package!", 'wpa_supplicant')); + return 1; + } }, post => sub { if ($wireless_enc_mode eq 'none') { @@ -1287,11 +1295,11 @@ See iwpriv(8) man page for further information."), } if ($wireless_enc_mode eq 'wpa-psk') { $ethntf->{WIRELESS_WPA_DRIVER} = network::wireless::wpa_supplicant_get_driver($module); - network::wireless::wpa_supplicant_configure($in, $ethntf->{WIRELESS_ESSID}, $wireless_enc_key); + network::wireless::wpa_supplicant_configure($ethntf->{WIRELESS_ESSID}, $wireless_enc_key); } else { delete $ethntf->{WIRELESS_WPA_DRIVER}; } - $module =~ /^prism2_/ and network::wireless::wlan_ng_configure($in, $ethntf, $module); + network::wireless::wlan_ng_needed($module) and network::wireless::wlan_ng_configure($ethntf->{WIRELESS_ESSID}, $wireless_enc_key, $ethntf->{DEVICE}, $module); return "static_hostname"; }, }, diff --git a/perl-install/network/wireless.pm b/perl-install/network/wireless.pm index f78ac5640..d6cf9a6d6 100644 --- a/perl-install/network/wireless.pm +++ b/perl-install/network/wireless.pm @@ -31,6 +31,11 @@ sub convert_key_for_wpa_supplicant { } } +sub wlan_ng_needed { + my ($module) = @_; + $module =~ /^prism2_/; +} + #- FIXME: to be improved (quotes, comments) and moved in common files sub wlan_ng_update_vars { my ($file, $vars) = @_; @@ -43,36 +48,36 @@ sub wlan_ng_update_vars { } sub wlan_ng_configure { - my ($in, $ethntf, $module) = @_; - $in->do_pkgs->install('prism2-utils'); - if ($ethntf->{WIRELESS_ESSID}) { - my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf"; - my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]); - push @wlan_devices, $ethntf->{DEVICE} unless member($ethntf->{DEVICE}, @wlan_devices); - #- enable device and make it use the choosen ESSID - wlan_ng_update_vars($wlan_conf_file, - { - WLAN_DEVICES => qq("@wlan_devices"), - "SSID_$ethntf->{DEVICE}" => qq("$ethntf->{WIRELESS_ESSID}"), - "ENABLE_$ethntf->{DEVICE}" => "y" - }); - my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$ethntf->{WIRELESS_ESSID}"; - #- copy default settings for this ESSID if config file does not exist - -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file); - #- enable/disable encryption - wlan_ng_update_vars($wlan_ssid_file, - { - (map { $_ => $ethntf->{WIRELESS_ENC_KEY} ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)), - AuthType => $ethntf->{WIRELESS_ENC_KEY} ? qq("sharedkey") : qq("opensystem"), - if_($ethntf->{WIRELESS_ENC_KEY}, - dot11WEPDefaultKeyID => 0, - dot11WEPDefaultKey0 => qq("$ethntf->{WIRELESS_ENC_KEY}") - ) - }); - #- hide settings for non-root users - chmod 0600, $wlan_conf_file; - chmod 0600, $wlan_ssid_file; - } + my ($essid, $key, $device, $module) = @_; + my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf"; + my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]); + push @wlan_devices, $device unless member($device, @wlan_devices); + #- enable device and make it use the choosen ESSID + wlan_ng_update_vars($wlan_conf_file, + { + WLAN_DEVICES => qq("@wlan_devices"), + "SSID_$device" => qq("$essid"), + "ENABLE_$device" => "y" + }); + + my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$essid"; + #- copy default settings for this ESSID if config file does not exist + -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file); + + #- enable/disable encryption + wlan_ng_update_vars($wlan_ssid_file, + { + (map { $_ => $key ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)), + AuthType => $key ? qq("sharedkey") : qq("opensystem"), + if_($key, + dot11WEPDefaultKeyID => 0, + dot11WEPDefaultKey0 => qq("$key") + ) + }); + #- hide settings for non-root users + chmod 0600, $wlan_conf_file; + chmod 0600, $wlan_ssid_file; + #- apply settings on wlan interface require services; services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan'); @@ -90,10 +95,7 @@ sub wpa_supplicant_get_driver { } sub wpa_supplicant_configure { - my ($in, $essid, $key) = @_; - require services; - $in->do_pkgs->install('wpa_supplicant'); - + my ($essid, $key) = @_; wpa_supplicant_add_network({ ssid => qq("$essid"), psk => convert_key_for_wpa_supplicant($key), |