diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-08-05 13:47:38 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-08-05 13:47:38 +0000 |
commit | e840dfdc1f9cb640007a7dd52c1d0bbeab533f44 (patch) | |
tree | 99d7a8c69e74e7a523e8479a88ee1215a8161c60 /perl-install/network | |
parent | 7bacf3feb1c444a6a7f68edd46bed6f299e19a4a (diff) | |
download | drakx-backup-do-not-use-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar drakx-backup-do-not-use-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.gz drakx-backup-do-not-use-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.bz2 drakx-backup-do-not-use-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.tar.xz drakx-backup-do-not-use-e840dfdc1f9cb640007a7dd52c1d0bbeab533f44.zip |
overwrite previous wpa_supplicant entries with same ssid or bssid
Diffstat (limited to 'perl-install/network')
-rw-r--r-- | perl-install/network/wireless.pm | 18 |
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) { |