diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2008-02-06 02:58:39 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2008-02-06 02:59:01 +0100 |
commit | c91a72996a3ef8a815f3ad4608c82d99ea16494f (patch) | |
tree | f92baeda2128943334ac0fde37ef6b6d5bdf03cc | |
parent | b4805c8d29a1888d27f7740317da9ddb96254379 (diff) |
Several fixes to slackware ethernet/wifi configuration.
* Use rc.inet1.conf keys for wifi instead of the ancient wireless.opts.
* Treat empty values as undef ones
* clean out the wireless.opts parsing/replacing, this isn't used anymore
-rw-r--r-- | Network/Ifaces.pm | 12 | ||||
-rw-r--r-- | Utils/Parse.pm | 54 | ||||
-rw-r--r-- | Utils/Replace.pm | 43 |
3 files changed, 10 insertions, 99 deletions
diff --git a/Network/Ifaces.pm b/Network/Ifaces.pm index 506701c..e045254 100644 --- a/Network/Ifaces.pm +++ b/Network/Ifaces.pm @@ -2522,9 +2522,9 @@ sub get_interface_parse_table [ "gateway", \&get_gateway, RC_INET_CONF, GATEWAY, "%address%", "%netmask%" ], [ "auto", \&Utils::Parse::get_trivial, 1 ], [ "bootproto", \&get_slackware_bootproto, [RC_INET_CONF, IFACE]], - [ "essid", \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, ESSID ], - [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_wireless_opts, WIRELESS, IFACE, \&get_wireless_ifaces, KEY ]], - [ "key", \&get_wep_key, [ \&Utils::Parse::get_wireless_opts, WIRELESS, IFACE, \&get_wireless_ifaces, KEY ]], + [ "essid", \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], WLAN_ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_rcinet1conf, RC_INET_CONF, IFACE, WLAN_KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_rcinet1conf, RC_INET_CONF, IFACE, WLAN_KEY ]], # Modem stuff [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]], [ "noauth", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]], @@ -3222,9 +3222,9 @@ sub get_interface_replace_table [ "netmask", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], NETMASK ], [ "gateway", \&Utils::Replace::set_rcinet1conf_global, RC_INET_CONF, GATEWAY ], [ "bootproto", \&set_slackware_bootproto, [ RC_INET_CONF, IFACE ] ], - [ "essid", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, ESSID ], - [ "key", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY ], - [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_wireless_opts, WIRELESS, IFACE, \&get_wireless_ifaces, KEY, "%key%" ]], + [ "essid", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], WLAN_ESSID ], + [ "key", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], WLAN_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_rcinet1conf, RC_INET_CONF, IFACE, WLAN_KEY, "%key%" ]], # Modem stuff [ "phone_number", \&check_type, [TYPE, "modem", \&create_pppscript, CHAT ]], [ "phone_number", \&check_type, [TYPE, "modem", \&create_pppgo ]], diff --git a/Utils/Parse.pm b/Utils/Parse.pm index 87dc106..de41a11 100644 --- a/Utils/Parse.pm +++ b/Utils/Parse.pm @@ -1159,14 +1159,16 @@ sub get_fq_domain sub get_rcinet1conf { my ($file, $iface, $kw) = @_; - my ($line); + my ($line, $val); $iface =~ s/eth//; #we must double escape those [] $line = "$kw\\[$iface\\]"; + $val = &get_sh ($file, $line); - return &get_sh ($file, $line); + return undef if ($val eq ""); + return $val; } sub get_rcinet1conf_bool @@ -1180,54 +1182,6 @@ sub get_rcinet1conf_bool return (&Utils::Util::read_boolean ($ret)? 1: 0); } -sub get_wireless_opts -{ - my ($file, $iface, $proc, $kw) = @_; - my $ifaces = &$proc (); - my $found = 0; - my $search = 1; - my $val = ""; - my $fd; - - foreach $i (@$ifaces) - { - $found = 1 if ($iface eq $i); - } - - return undef if (!$found); - - $fd = &Utils::File::open_read_from_names ($file); - while (<$fd>) - { - $line = $_; - - if ($line =~ /^case/) - { - # we don't want to search inside the case - $search = 0; - } - elsif ($line =~ /^esac/) - { - # continue searching - $search = 1; - } - elsif (($line =~ /^[ \t]*$kw/ ) && ($search)) - { - $line =~ s/.*=//; - - if ($line =~ /"(.*)"/) - { - $line = $1; - } - - $val = $line; - } - } - - &Utils::File::close_file ($fd); - return $val; -} - # function for parsing /etc/start_if.$iface files in FreeBSD sub get_startif { diff --git a/Utils/Replace.pm b/Utils/Replace.pm index 1deeeca..32b04c5 100644 --- a/Utils/Replace.pm +++ b/Utils/Replace.pm @@ -1205,49 +1205,6 @@ sub set_rcinet1conf_global return &split ($file, $kw, "[ \t]*=[ \t]*", $val) } -sub set_wireless_opts -{ - my ($file, $iface, $proc, $kw, $value) = @_; - my $ifaces = &$proc (); - my $found = 0; - my $search = 1; - my $buff; - - foreach $i (@$ifaces) - { - $found = 1 if ($iface eq $i); - } - - $buff = &Utils::File::load_buffer ($file); - - foreach $i (@$buff) - { - if (/^case/) - { - # we don't want to search inside the case - $search = 0; - } - elsif (/^esac/) - { - # we want to continue searching - $search = 1; - } - if ((/^[ \t]*$kw/) && ($search)) - { - $_ = "$kw=\"$value\""; - $found = 1; - } - } - - if (!$found) - { - push @$buff, "$kw=\"$value\""; - } - - &Utils::File::clean_buffer ($buff); - return &Utils::File::save_buffer ($buff, $file); -} - # Functions for replacing in FreeBSD's /etc/ppp/ppp.conf sub set_pppconf_common { |