summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-08-30 16:54:21 +0000
committerOlivier Blin <oblin@mandriva.org>2005-08-30 16:54:21 +0000
commit237a287656548315efbbc4e0161cf6edee005c26 (patch)
tree691e3d77c464ffdc086f9cd0924f72ab2732c80f /perl-install/network
parent9478e0e4744c1fd4cc5e2d5bab82b124191b93fd (diff)
downloaddrakx-237a287656548315efbbc4e0161cf6edee005c26.tar
drakx-237a287656548315efbbc4e0161cf6edee005c26.tar.gz
drakx-237a287656548315efbbc4e0161cf6edee005c26.tar.bz2
drakx-237a287656548315efbbc4e0161cf6edee005c26.tar.xz
drakx-237a287656548315efbbc4e0161cf6edee005c26.zip
- configure wpa_supplicant correctly for shared or passwordless connections
- split write_interface_setttings out of network::network::write_interface_conf - wpa_supplicant may list some networks twice, handle it - rewrite drakroam to use wpa_supplicant
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/monitor.pm8
-rw-r--r--perl-install/network/network.pm29
-rw-r--r--perl-install/network/wireless.pm26
3 files changed, 39 insertions, 24 deletions
diff --git a/perl-install/network/monitor.pm b/perl-install/network/monitor.pm
index eea814bc8..38912af97 100644
--- a/perl-install/network/monitor.pm
+++ b/perl-install/network/monitor.pm
@@ -21,8 +21,12 @@ sub list_wireless {
my %networks;
#- bssid / frequency / signal level / flags / ssid
while ($results =~ /^((?:[0-9a-f]{2}:){5}[0-9a-f]{2})\t(\d+)\t(\d+)\t(.*?)\t(.*)$/mg) {
- $networks{$1} = { frequency => $2, signal_level => $3, flags => $4, ssid => $5 };
- $networks{$1}{approx_level} = 20 + min(80, int($3/20)*20);
+ # wpa_supplicant may list the network two times, use ||=
+ $networks{$1}{frequency} ||= $2;
+ $networks{$1}{signal_level} ||= $3;
+ $networks{$1}{flags} ||= $4;
+ $networks{$1}{ssid} ||= $5 if $5 ne '<hidden>';
+ $networks{$1}{approx_level} ||= 20 + min(80, int($3/20)*20);
}
my $list;
eval { $list = $o->call_method('ListNetworks') };
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index afce07917..75c70975b 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -179,6 +179,20 @@ sub update_broadcast_and_network {
$intf->{NETWORK} = join('.', mapn { int($_[0]) & $_[1] } \@ip, \@mask);
}
+sub write_interface_settings {
+ my ($intf, $file) = @_;
+ setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR METRIC MII_NOT_SUPPORTED TYPE USERCTL ATM_ADDR ETHTOOL_OPTS VLAN MTU MS_DNS1 MS_DNS2 DOMAIN),
+ qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV WIRELESS_WPA_DRIVER),
+ qw(DVB_ADAPTER_ID DVB_NETWORK_DEMUX DVB_NETWORK_PID),
+ qw(IPV6INIT IPV6TO4INIT),
+ if_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_CLIENT DHCP_HOSTNAME NEEDHOSTNAME PEERDNS PEERYP PEERNTPD DHCP_TIMEOUT)),
+ if_($intf->{DEVICE} =~ /^ippp\d+$/, qw(DIAL_ON_IFUP))
+ );
+ substInFile { s/^DEVICE='(`.*`)'/DEVICE=$1/g } $file; #- remove quotes if DEVICE is the result of a command
+ chmod $intf->{WIRELESS_ENC_KEY} ? 0700 : 0755, $file; #- hide WEP key for non-root users
+ log::explanations("written $intf->{DEVICE} interface configuration in $file");
+}
+
sub write_interface_conf {
my ($net, $name) = @_;
@@ -198,16 +212,7 @@ sub write_interface_conf {
defined($intf->{METRIC}) or $intf->{METRIC} = network::tools::get_default_metric(network::tools::get_interface_type($intf)),
$intf->{BOOTPROTO} =~ s/dhcp.*/dhcp/;
- setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR METRIC MII_NOT_SUPPORTED TYPE USERCTL ATM_ADDR ETHTOOL_OPTS VLAN MTU MS_DNS1 MS_DNS2 DOMAIN),
- qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV WIRELESS_WPA_DRIVER),
- qw(DVB_ADAPTER_ID DVB_NETWORK_DEMUX DVB_NETWORK_PID),
- qw(IPV6INIT IPV6TO4INIT),
- if_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_CLIENT DHCP_HOSTNAME NEEDHOSTNAME PEERDNS PEERYP PEERNTPD DHCP_TIMEOUT)),
- if_($intf->{DEVICE} =~ /^ippp\d+$/, qw(DIAL_ON_IFUP))
- );
- substInFile { s/^DEVICE='(`.*`)'/DEVICE=$1/g } $file; #- remove quotes if DEVICE is the result of a command
- chmod $intf->{WIRELESS_ENC_KEY} ? 0700 : 0755, $file; #- hide WEP key for non-root users
- log::explanations("written $intf->{DEVICE} interface configuration in $file");
+ write_interface_settings($intf, $file);
}
sub add2hosts {
@@ -507,6 +512,10 @@ sub read_net_conf {
$intf->{DEVICE} ||= $device;
}
}
+ $net->{wireless} ||= {};
+ foreach (all("$::prefix/etc/sysconfig/network-scripts/wireless.d")) {
+ $net->{wireless}{$_} = { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/wireless.d/$_") };
+ }
netprofile_read($net);
if (my $default_intf = network::tools::get_default_gateway_interface($net)) {
$net->{net_interface} = $default_intf;
diff --git a/perl-install/network/wireless.pm b/perl-install/network/wireless.pm
index 62971bcaf..79a6ec9a0 100644
--- a/perl-install/network/wireless.pm
+++ b/perl-install/network/wireless.pm
@@ -108,19 +108,21 @@ sub wpa_supplicant_add_network {
my $network = {
ssid => qq("$essid"),
scan_ssid => 1,
- $enc_mode eq 'wpa-psk' ?
- (
- psk => convert_key_for_wpa_supplicant($key),
- ) :
- member($enc_mode, qw(open restricted)) ?
- (
- key_mgmt => 'NONE',
- wep_key0 => convert_key_for_wpa_supplicant($key),
- wep_tx_keyidx => 0,
- auth_alg => 'SHARED',
- ) :
- ()
};
+
+ if ($enc_mode eq 'wpa-psk') {
+ $network->{psk} = convert_key_for_wpa_supplicant($key);
+ } else {
+ $network->{key_mgmt} = 'NONE';
+ if (member($enc_mode, qw(open restricted))) {
+ put_in_hash($network, {
+ wep_key0 => convert_key_for_wpa_supplicant($key),
+ wep_tx_keyidx => 0,
+ auth_alg => $enc_mode eq 'restricted' ? 'SHARED' : 'OPEN',
+ });
+ }
+ }
+
@$conf = difference2($conf, [ wpa_supplicant_find_similar($conf, $network) ]);
push @$conf, $network;
wpa_supplicant_write_conf($conf);