summaryrefslogtreecommitdiffstats
path: root/perl-install/network/network.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network/network.pm')
-rw-r--r--perl-install/network/network.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 1f1e78a84..c2cf30dd5 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -477,6 +477,50 @@ sub easy_dhcp {
1;
}
+#- FIXME: to be improved (quotes, comments) and moved in common files
+sub wlan_ng_update_vars {
+ my ($file, $vars) = @_;
+ substInFile {
+ while (my ($key, $value) = each(%$vars)) {
+ s/^#?\Q$key\E=(?:"[^#]*"|[^#\s]*)(\s*#.*)?/$key=$value$1/ and delete $vars->{$key};
+ }
+ $_ .= join('', map { "$_=$vars->{$_}\n" } keys %$vars) if eof;
+ } $file;
+}
+
+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}")
+ )
+ });
+ #- apply settings on wlan interface
+ require services;
+ services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan');
+ }
+}
+
sub wpa_supplicant_add_network {
my ($new_network) = @_;
my $wpa_supplicant_conf = "$::prefix/etc/wpa_supplicant.conf";