summaryrefslogtreecommitdiffstats
path: root/perl-install/network/wireless.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-08-05 13:47:38 +0000
committerOlivier Blin <oblin@mandriva.org>2005-08-05 13:47:38 +0000
commite840dfdc1f9cb640007a7dd52c1d0bbeab533f44 (patch)
tree99d7a8c69e74e7a523e8479a88ee1215a8161c60 /perl-install/network/wireless.pm
parent7bacf3feb1c444a6a7f68edd46bed6f299e19a4a (diff)
downloaddrakx-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar
drakx-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.gz
drakx-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.bz2
drakx-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.xz
drakx-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.zip
overwrite previous wpa_supplicant entries with same ssid or bssid
Diffstat (limited to 'perl-install/network/wireless.pm')
-rw-r--r--perl-install/network/wireless.pm18
1 files changed, 12 insertions, 6 deletions
diff --git a/perl-install/network/wireless.pm b/perl-install/network/wireless.pm
index bdfc9fd55..784d45851 100644
--- a/perl-install/network/wireless.pm
+++ b/perl-install/network/wireless.pm
@@ -99,7 +99,7 @@ sub wpa_supplicant_get_driver {
sub wpa_supplicant_add_network {
my ($essid, $enc_mode, $key) = @_;
my $conf = wpa_supplicant_read_conf();
- push @$conf, {
+ my $network = {
ssid => qq("$essid"),
scan_ssid => 1,
$enc_mode eq 'wpa-psk' ?
@@ -115,9 +115,19 @@ sub wpa_supplicant_add_network {
) :
()
};
+ @$conf = difference2($conf, [ wpa_supplicant_find_similar($conf, $network) ]);
+ push @$conf, $network;
wpa_supplicant_write_conf($conf);
}
+sub wpa_supplicant_find_similar {
+ my ($conf, $network) = @_;
+ grep {
+ my $current = $_;
+ any { exists $network->{$_} && $network->{$_} eq $current->{$_} } qw(ssid bssid);
+ } @$conf;
+}
+
sub wpa_supplicant_read_conf() {
my @conf;
my $network;
@@ -154,11 +164,7 @@ sub wpa_supplicant_write_conf {
#- end of network block, write it
$buf .= "network={$network->{comment}\n";
- my $new_network = find {
- my $current = $_;
- any { exists $network->{$_} && $network->{$_} eq $current->{$_} } qw(ssid bssid);
- } @conf;
-
+ my $new_network = first(wpa_supplicant_find_similar(\@conf, $network));
foreach (@{$network->{entries}}) {
my $key = $_->{key};
if ($new_network) {