summaryrefslogtreecommitdiffstats
path: root/perl-install/network/wireless.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-04-24 21:46:43 +0000
committerOlivier Blin <oblin@mandriva.org>2005-04-24 21:46:43 +0000
commit1155fe22f750d0ee446b6a729cd574c2b068e480 (patch)
treef8e627a8b46516aae094b2d5b953891a253f68df /perl-install/network/wireless.pm
parent5c0448ea44d1b03b528fd8d378062037640b5153 (diff)
downloaddrakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar
drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.gz
drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.bz2
drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.tar.xz
drakx-1155fe22f750d0ee446b6a729cd574c2b068e480.zip
handle errors in wireless packages installation, simplify
Diffstat (limited to 'perl-install/network/wireless.pm')
-rw-r--r--perl-install/network/wireless.pm70
1 files changed, 36 insertions, 34 deletions
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),