diff options
author | carlosg <carlosg> | 2007-07-06 09:47:44 +0000 |
---|---|---|
committer | carlosg <carlosg> | 2007-07-06 09:47:44 +0000 |
commit | 99bddda22a19ea4c51ffedf2bda832035bd07e40 (patch) | |
tree | b370ebf7cf1dba4df542dc92aedd337909e6bbfb | |
parent | edf29cc2350c9fe9f89fd598288bd66a0f3ccfe5 (diff) |
2007-07-06 Carlos Garnacho <carlosg@gnome.org>
* Network/Ifaces.pm (get_encrypted_wpa_psk): function to get encrypted
psk.
(set_debian_key): use it here.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Network/Ifaces.pm | 22 |
2 files changed, 27 insertions, 1 deletions
@@ -1,5 +1,11 @@ 2007-07-06 Carlos Garnacho <carlosg@gnome.org> + * Network/Ifaces.pm (get_encrypted_wpa_psk): function to get encrypted + psk. + (set_debian_key): use it here. + +2007-07-06 Carlos Garnacho <carlosg@gnome.org> + * Network/Ifaces.pm (get_available_encryptions): add wpa to plain debian too. diff --git a/Network/Ifaces.pm b/Network/Ifaces.pm index 767c97e..6e7c61e 100644 --- a/Network/Ifaces.pm +++ b/Network/Ifaces.pm @@ -664,9 +664,28 @@ sub set_wep_key_full &$func (@_); } +sub get_encrypted_wpa_psk +{ + my ($key, $essid) = @_; + my ($output); + + # FIXME: not good to pass directly keys to processes, + # probably the network one won't be so important + # to keep secret to other users. + $output = &Utils::File::run_backtick ("wpa_passphrase $essid $key"); + + if ($output =~ /\tpsk=(.*)\n/) + { + return $1; + } + + return undef; +} + sub set_debian_key { my ($file, $iface, $key, $essid, $key_type) = @_; + my ($psk); #remove undesired options, due to syntax duality &Utils::Replace::set_interfaces_option_str ($file, $iface, "wireless-key", ""); @@ -689,7 +708,8 @@ sub set_debian_key { if ($key) { - &Utils::Replace::set_interfaces_option_str ($file, $iface, "wpa-psk", $key); + $psk = &get_encrypted_wpa_psk ($key, $essid); + &Utils::Replace::set_interfaces_option_str ($file, $iface, "wpa-psk", $psk); &Utils::Replace::set_interfaces_option_str ($file, $iface, "wpa-driver", "wext"); &Utils::Replace::set_interfaces_option_str ($file, $iface, "wpa-key-mgmt", "WPA-PSK"); |