diff options
Diffstat (limited to 'knetworkconf/backends/network.pl.in')
-rw-r--r-- | knetworkconf/backends/network.pl.in | 373 |
1 files changed, 204 insertions, 169 deletions
diff --git a/knetworkconf/backends/network.pl.in b/knetworkconf/backends/network.pl.in index 0e8b12c..d3daee4 100644 --- a/knetworkconf/backends/network.pl.in +++ b/knetworkconf/backends/network.pl.in @@ -121,7 +121,7 @@ sub gst_network_get_freebsd_wireless_ifaces sub gst_network_get_wireless_ifaces { my ($plat) = $$tool{"system"}; - + return &gst_network_get_linux_wireless_ifaces if ($plat eq "Linux"); return &gst_network_get_freebsd_wireless_ifaces if ($plat eq "FreeBSD"); } @@ -243,7 +243,7 @@ sub gst_network_enable_modem $command .= " connect \'$command_chat -v -f $chat_file\'"; $ret = &gst_file_run ($command); - + return $ret; } @@ -310,7 +310,7 @@ sub gst_network_enable_iface_with_config $login = $$hash{"configuration"}{"login"}; $pw = $$hash{"configuration"}{"password"}; - &gst_network_set_pap_passwd ("/etc/ppp/pap-secrets", $login, $pw); + &gst_network_set_pap_passwd ("/etc/ppp/pap-secrets", $login, $pw); &gst_network_set_pap_passwd ("/etc/ppp/chap-secrets", $login, $pw); if (&gst_network_check_pppd_plugin ("capiplugin")) @@ -352,7 +352,7 @@ sub gst_network_autodetect_modem { @arr = ("/dev/modem", "/dev/cuaa0", "/dev/cuaa1", "/dev/cuaa2", "/dev/cuaa3"); } - + foreach $tty (@arr) { $temp = `pppd lcp-max-configure 1 nodetach noauth nocrtscts $tty connect \"chat -t1 \'\' AT OK\" 2>/dev/null`; @@ -445,7 +445,7 @@ sub gst_network_ipv4_calc_subnet_vec sub gst_network_ipv4_calc_subnet { my ($addr, $mask) = @_; - + return &gst_network_ipv4_vec2str (&gst_network_ipv4_calc_subnet_vec); } @@ -453,7 +453,7 @@ sub gst_network_ipv4_calc_subnet sub gst_network_ipv4_calc_bcast_vec { my ($addr, $mask) = @_; - + $addrvec = &gst_network_ipv4_str2vec ($addr); $maskvec = &gst_network_ipv4_str2vec ($mask); @@ -506,6 +506,11 @@ sub gst_network_get_broadcast_ping_cmd "ubuntu-7.04" => "debian-2.2", "ubuntu-7.10" => "debian-2.2", "ubuntu-8.04" => "debian-2.2", + "ubuntu-8.10" => "debian-2.2", + "ubuntu-9.04" => "debian-2.2", + "ubuntu-9.10" => "debian-2.2", + "ubuntu-10.10" => "debian-2.2", + "ubuntu-10.10" => "debian-2.2", "mandrake-7.1" => "debian-2.2", "mandrake-7.2" => "debian-2.2", "mandrake-9.0" => "debian-2.2", @@ -654,7 +659,7 @@ sub gst_network_lookup_address_collect { my ($procs) = @_; my ($name, @names, $proc); - + # For every process, if the "ready" flag is on, read info. # Else, populate with the given address. Then kill child and wait for it to die. foreach $proc (@$procs) @@ -722,19 +727,19 @@ sub gst_network_dialing_get "Dialer (.*)" => "dialer", "Modem(.*)" => "modem" ); - + my ($file) = @_; my (%ret, @sections); my ($i, $j, $name, $val); &gst_report_enter (); &gst_report ("network_dialing_get"); - + @sections = &gst_parse_ini_sections ($file); foreach $i (@sections) { my %hash; - + $hash{"type"} = "unknown"; foreach $j (keys %title2type) { @@ -744,7 +749,7 @@ sub gst_network_dialing_get $hash{"type"} = $title2type{$j}; } } - + $ret{$hash{"name"}} = \%hash; foreach $j (keys %vars) @@ -777,7 +782,7 @@ sub gst_network_dialing_get $hash{"phone"} =~ s/^.*[wW]//; } } - + &gst_report_leave (); return \%ret; } @@ -843,7 +848,7 @@ sub gst_network_freebsd_interfaces_get_info $fd = &gst_file_run_pipe_read ("ifconfig"); return {} if $fd eq undef; - + while (<$fd>) { chomp; @@ -853,7 +858,7 @@ sub gst_network_freebsd_interfaces_get_info $ifaces{$dev}{"dev"} = $dev; $ifaces{$dev}{"enabled"} = 1 if ($2 =~ /[<,]UP[,>]/); } - + s/^[ \t]+//; if ($dev) { @@ -863,7 +868,7 @@ sub gst_network_freebsd_interfaces_get_info $ifaces{$dev}{"bcast"} = $1 if /broadcast[ \t]+([^ \t]+)/i; } } - + &gst_file_close ($fd); &gst_report_leave (); return \%ifaces; @@ -878,7 +883,7 @@ sub gst_network_linux_interfaces_get_info $fd = &gst_file_run_pipe_read ("ifconfig -a"); return {} if $fd eq undef; - + while (<$fd>) { chomp; @@ -888,7 +893,7 @@ sub gst_network_linux_interfaces_get_info $ifaces{$dev}{"enabled"} = 0; $ifaces{$dev}{"dev"} = $dev; } - + s/^[ \t]+//; if ($dev) { @@ -899,7 +904,7 @@ sub gst_network_linux_interfaces_get_info $ifaces{$dev}{"enabled"} = 1 if /^UP[ \t]/i; } } - + &gst_file_close ($fd); &gst_report_leave (); return \%ifaces; @@ -937,7 +942,7 @@ sub gst_network_active_interfaces_get $fd = &gst_file_run_pipe_read ("ifconfig"); return undef if $fd eq undef; - + while (<$fd>) { chomp; @@ -994,7 +999,7 @@ sub gst_network_suse70_active_interfaces_get return @ret; } - + sub gst_network_interface_active { my ($search_iface, $proc) = @_; @@ -1016,7 +1021,7 @@ sub gst_network_interface_active sub gst_network_interface_ensure_broadcast_and_network { my ($iface) = @_; - + if (exists $$iface{"netmask"} && exists $$iface{"address"}) { @@ -1037,7 +1042,7 @@ sub gst_network_sysconfig_dir_ifaces_get_existing my ($dir) = @_; my (@ret, $i, $name); local *IFACE_DIR; - + if (opendir IFACE_DIR, "$gst_prefix/$dir") { foreach $i (readdir (IFACE_DIR)) @@ -1059,24 +1064,24 @@ sub gst_network_sysconfig_rh62_ifaces_get_existing sub gst_network_sysconfig_rh72_ifaces_get_existing { my ($ret); - + # This syncs /etc/sysconfig/network-scripts and /etc/sysconfig/networking &gst_file_run ("redhat-config-network-cmd"); - + $ret = &gst_network_sysconfig_dir_ifaces_get_existing ("/etc/sysconfig/networking/profiles/default"); - - &gst_arr_merge ($ret, + + &gst_arr_merge ($ret, &gst_network_sysconfig_dir_ifaces_get_existing ("/etc/sysconfig/networking/devices")); - + return @$ret; } sub gst_network_debian_ifaces_get_existing { my (@ret, @stanzas, $stanza); - + @stanzas = &gst_parse_interfaces_stanzas ("$gst_prefix/etc/network/interfaces", "iface"); foreach $stanza (@stanzas) @@ -1097,7 +1102,7 @@ sub gst_network_suse70_ifaces_get_existing $fd = &gst_file_open_read_from_names ($file); return @ret if !$fd; - + while ($i = <$fd>) { if ($i =~ /^[ \t]*NETDEV_([0-9]+)=/) @@ -1211,7 +1216,7 @@ sub gst_network_suse70_parse_iface_auto { my ($file, $iface, $key) = @_; my ($val, $i); - + $val = &gst_parse_sh_split ($file, $key, "[ \t]+"); foreach $i (@$val) @@ -1226,7 +1231,7 @@ sub gst_network_suse70_replace_iface_auto { my ($file, $iface, $key, $value) = @_; my ($val, $i, $found, @ret); - + $val = &gst_parse_sh_split ($file, $key, "[ \t]+"); foreach $i (@$val) @@ -1273,9 +1278,9 @@ sub gst_network_suse70_set_ifconfig_arg my ($val); $val = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - + return 0 if $val =~ /^dhcpclient$/ || $val =~ /^bootp$/; - + if (! ($val =~ s/([ \t]+$key[ \t]+)[^ \t]+/$1$value/)) { $val =~ s/[ \t]+up$//; @@ -1291,9 +1296,9 @@ sub gst_network_suse70_set_ifconfig_ip my ($file, $iface, $value) = @_; $val = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - + return 0 if $val =~ /^dhcpclient$/ || $val =~ /^bootp$/; - + if (! ($val =~ s/^[0-9\.]+([ \t])/$value$1/)) { $val = "$value $val"; @@ -1362,7 +1367,7 @@ sub gst_network_dial2iface $iface{"file"} = $iface{"name"} = $iface{"section"} = $name; $iface{"update_dns"} = 1 if ($iface{"update_dns"} eq ""); $iface{"set_default_gw"} = 1 if ($iface{"set_default_gw"} eq ""); - + return \%iface; } @@ -1414,9 +1419,9 @@ sub gst_network_suse70_set_ppp if ($$i{"dev"} =~ /^ppp/) { my ($tmp, $wv, $name); - + push @ppp_devs, $i; - + # This takes care of connection name changes. $wv = $$i{"section"}; $name = $$i{"name"}; @@ -1428,7 +1433,7 @@ sub gst_network_suse70_set_ppp $$tmp{"name"} = $name; $$dial{$name} = $tmp; } - + # Then merges interface with dialing. &gst_network_iface2dial ($dial, $i); } @@ -1513,7 +1518,7 @@ sub gst_network_slackware91_create_pppgo { $pppd = &gst_file_locate_tool ("pppd"); $chat = &gst_file_locate_tool ("chat"); - + # create a simple ppp-go from scratch # this script is based on the one that's created by pppsetup $contents = "killall -INT pppd 2>/dev/null \n"; @@ -1726,14 +1731,14 @@ sub gst_network_rh62_get_file $dev = $$iface{"dev"}; $pre = "$gst_prefix/etc/sysconfig/network-scripts/ifcfg-"; - + return $dev if ! -e "$pre$dev"; - + $dev =~ s/[0-9]*$//; $i = 0; $i ++ while (-e "$pre$dev$i"); - + return "$dev$i"; } @@ -1742,21 +1747,21 @@ sub gst_network_rh72_get_file my ($iface) = @_; my ($pre, $i, $dev); - $dev = $$iface{"dev"}; + $dev = $$iface{"dev"}; $pre = "$gst_prefix/etc/sysconfig/networking/devices/ifcfg-"; - + return $dev if ! -e "$pre$dev"; - + $i = 0; $i ++ while (-e "$pre$dev.$i"); - + return "$dev.$i"; } sub gst_network_deb22_get_file { my ($iface) = @_; - + return $$iface{"dev"}; } @@ -1768,7 +1773,7 @@ sub gst_network_suse70_get_file $i = 0; $i ++ while (&gst_parse_sh ($file, "NETDEV_$i") ne ""); - + return $i; } @@ -1776,17 +1781,17 @@ sub gst_network_pld10_get_file { my ($iface) = @_; my ($pre, $i, $dev); - + $dev = $$iface{"dev"}; $pre = "$gst_prefix/etc/sysconfig/interfaces/ifcfg-"; - + return $dev if ! -e "$pre$dev"; - + $dev =~ s/[0-9]*$//; - + $i = 0; $i ++ while (-e "$pre$dev$i"); - + return "$dev$i"; } @@ -1828,13 +1833,18 @@ sub gst_network_get_file "debian-4.0" => \&gst_network_deb22_get_file, "debian-5.0" => \&gst_network_deb22_get_file, "debian-testing" => \&gst_network_deb22_get_file, - "ubuntu-5.04" => \&gst_network_deb22_get_file, - "ubuntu-5.10" => \&gst_network_deb22_get_file, - "ubuntu-6.06" => \&gst_network_deb22_get_file, - "ubuntu-6.10" => \&gst_network_deb22_get_file, - "ubuntu-7.04" => \&gst_network_deb22_get_file, - "ubuntu-7.10" => \&gst_network_deb22_get_file, - "ubuntu-8.04" => \&gst_network_deb22_get_file, + "ubuntu-5.04" => \&gst_network_deb22_get_file, + "ubuntu-5.10" => \&gst_network_deb22_get_file, + "ubuntu-6.06" => \&gst_network_deb22_get_file, + "ubuntu-6.10" => \&gst_network_deb22_get_file, + "ubuntu-7.04" => \&gst_network_deb22_get_file, + "ubuntu-7.10" => \&gst_network_deb22_get_file, + "ubuntu-8.04" => \&gst_network_deb22_get_file, + "ubuntu-8.10" => \&gst_network_deb22_get_file, + "ubuntu-9.04" => \&gst_network_deb22_get_file, + "ubuntu-9.10" => \&gst_network_deb22_get_file, + "ubuntu-10.04" => \&gst_network_deb22_get_file, + "ubuntu-10.10" => \&gst_network_deb22_get_file, "suse-7.0" => \&gst_network_suse70_get_file, "suse-9.0" => \&gst_network_deb22_get_file, "suse-9.1" => \&gst_network_deb22_get_file, @@ -1921,7 +1931,7 @@ sub gst_network_route_set_default_gw /([a-z0-9]+)$/; $curr_gatewaydev = $1; } - + last; } } @@ -1948,7 +1958,7 @@ sub gst_network_run_hostname sub gst_network_dialing_get_section_name { my ($dial) = @_; - + my %type2title = ( "dialer" => "Dialer ", @@ -2053,7 +2063,7 @@ sub gst_network_dialing_set &gst_report_leave (); chmod (0600, $file) if !$ret; - + return $ret; } @@ -2074,7 +2084,7 @@ sub gst_network_rh62_interface_activate_by_dev &gst_report ("network_iface_deactivate", $dev); return -1 if &gst_file_run ("ifdown $dev"); } - + &gst_report_leave (); return 0; @@ -2116,7 +2126,7 @@ sub gst_network_suse9_interface_activate { $dev = $$hash{"dev"}; } - + &gst_network_rh62_interface_activate_by_dev ($dev, $enabled); } } @@ -2130,7 +2140,7 @@ sub gst_network_suse70_interface_activate_by_dev $network = $paths[1] . "/network"; &gst_report_enter (); - + if ($enabled) { &gst_report ("network_iface_deactivate", $hash{"dev"}); @@ -2141,7 +2151,7 @@ sub gst_network_suse70_interface_activate_by_dev &gst_report ("network_iface_activate", $hash{"dev"}); return -1 if &gst_file_run ("$network stop $dev"); } - + &gst_report_leave (); return 0; @@ -2300,7 +2310,7 @@ sub gst_network_remove_pap_entry &gst_report_enter (); &gst_report ("network_remove_pap", $file, $login); - + $buff = &gst_file_buffer_load ($file); foreach $i (@$buff) @@ -2340,7 +2350,7 @@ sub gst_network_rh72_interface_delete $filedev = $$old_hash{"configuration"}{"file"}; $dev = $$old_hash{"dev"}; $login = $$old_hash{"configuration"}{"login"}; - + &gst_network_rh62_interface_activate_by_dev ($filedev, 0); if ($login ne "") @@ -2352,7 +2362,7 @@ sub gst_network_rh72_interface_delete &gst_file_remove ("$gst_prefix/etc/sysconfig/networking/devices/ifcfg-$filedev"); &gst_file_remove ("$gst_prefix/etc/sysconfig/networking/profiles/default/ifcfg-$filedev"); &gst_file_remove ("$gst_prefix/etc/sysconfig/network-scripts/ifcfg-$dev"); - + &gst_file_run ("redhat-config-network-cmd"); } @@ -2363,7 +2373,7 @@ sub gst_network_deb22_interface_delete &gst_network_rh62_interface_activate_by_dev ($dev, 0); &gst_replace_interfaces_iface_stanza_delete ("$gst_prefix/etc/network/interfaces", $dev); - + $login = $old_hash{"configuration"}{"login"}; if ($login ne "") { @@ -2414,16 +2424,16 @@ sub gst_network_pld10_interface_delete my $dev = $$old_hash{"configuration"}{"file"}; my $file = "$gst_prefix/etc/sysconfig/interfaces/ifcfg-$dev"; my $login; - + &gst_network_rh62_interface_activate_by_dev ($dev, 0); - + $login = $old_hash{"configuration"}{"login"}; if ($login ne "") { &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); } - + &gst_file_remove ($file); } @@ -2506,7 +2516,7 @@ sub gst_network_freebsd_interface_delete &gst_file_buffer_clean ($buff); &gst_file_buffer_save ($buff, $pppconf); } - + &gst_replace_sh ($file, "ifconfig_$dev", ""); &gst_file_remove ($startif); } @@ -2568,7 +2578,7 @@ sub gst_network_interface_set sub gst_network_interfaces_set { - my ($old_hash, $values_hash) = @_; + my ($old_hash, $values_hash) = @_; my (%dist_attrib, @ifaces, %fn); my ($value, $proc); my ($i, $j); @@ -2578,7 +2588,7 @@ sub gst_network_interfaces_set &gst_report_enter (); &gst_report ("network_ifaces_set"); - + %dist_attrib = &gst_network_get_interface_replace_table (); $old_hash = $$old_hash{"interface"}; @@ -2587,9 +2597,13 @@ sub gst_network_interfaces_set foreach $i (keys %$values_hash) { - # delete it if it's no longer configured - if (exists $$old_hash{$i}{"configuration"} && - not exists $$values_hash{$i}{"configuration"}) + # delete it if it's no longer configured or boot protocol is dhcp, + # so that network-manager see the card again + if ((exists $$old_hash{$i}{"configuration"} && + not exists $$values_hash{$i}{"configuration"}) || + (exists $$values_hash{$i}{"configuration"} && + $$values_hash{$i}{"configuration"}{"bootproto"} eq "dhcp") + ) { &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); &$delete_proc ($$old_hash{$i}); @@ -2621,7 +2635,7 @@ sub gst_network_conf_set my $values_hash = $_[0]; my $old_hash; my %dist_attrib; - + $old_hash = &gst_network_conf_get (); &gst_network_ensure_loopback ($values_hash, $old_hash); @@ -2646,7 +2660,7 @@ sub gst_network_get_pap_passwd &gst_report_leave (); $passwd =~ s/^\"([^\"]*)\"$/$1/; - + return $passwd; } @@ -2704,7 +2718,7 @@ sub gst_network_set_ppp_options_re chomp $line; $pre_space = $1 if $line =~ s/^([ \t]+)//; $post_comment = $1 if $line =~ s/([ \t]*\#.*)//; - + if ($line =~ /$re/) { $line = "$value\n"; @@ -2716,7 +2730,7 @@ sub gst_network_set_ppp_options_re } push @$buff, "$value\n" if !$replaced; - + &gst_file_buffer_clean ($buff); $ret = &gst_file_buffer_save ($buff, $file); &gst_report_leave (); @@ -2754,17 +2768,17 @@ sub gst_network_get_ppp_options_unsup { $_ = $$line; next if /^[ \t]*$/; - + foreach $re (@known_options) { next GET_LINE if /^$re/; } - + $res .= "$_ "; } - + chop $res; - + return $res; } @@ -2776,7 +2790,7 @@ sub gst_network_set_ppp_options_unsup my @known_options = ("usepeerdns", "mtu", "mru", "user", "/dev/[^ \t]+", "[0-9]+", "defaultroute", "debug", "persist", "escape", "crtscts", "connect", "remotename", "hide-password", "noauth", "noipdefault", "ipparam", "name \".*\""); - + # The options in the last row are those that are on by default in pppd and we don't handle, # so we ignore them, as they are set implicitly if not specified. @@ -2797,10 +2811,10 @@ sub gst_network_set_ppp_options_unsup $line = $pre_space . $post_comment . "\n"; $line = "" if $line =~ /^[ \t]*$/; } - + $value =~ s/[ \t]+([^0-9])/\n$1/g; push @$buff, $value . "\n"; - + &gst_file_buffer_clean ($buff); $ret = &gst_file_buffer_save ($buff, $file); &gst_report_leave (); @@ -2819,7 +2833,7 @@ sub gst_network_rh62_parse_bootproto my $ret; $ret = &gst_parse_sh ($file, $key); - + if (!exists $rh62_to_proto_name{$ret}) { &gst_report ("network_bootproto_unsup", $file, $ret); @@ -2893,7 +2907,7 @@ sub gst_network_deb22_replace_bootproto "none" => "static" ); - my %dev_to_method = + my %dev_to_method = ( "lo" => "loopback", "ppp" => "ppp", @@ -2952,7 +2966,7 @@ sub gst_network_suse70_parse_bootproto &gst_report ("network_bootproto_unsup", $iface, $ret); return "none"; } - + return $suse70_to_proto_name {$ret}; } @@ -2984,7 +2998,7 @@ sub gst_network_pld10_parse_bootproto my $ret; $ret = &gst_parse_sh ($file, $key); - + if (!exists $pld10_to_proto_name{$ret}) { &gst_report ("network_bootproto_unsup", $file, $ret); @@ -3219,7 +3233,7 @@ sub gst_network_get_freebsd5_ppp_persist sub gst_network_pump_get_nodns { my ($file, $iface, $bootproto) = @_; - + return undef if (!&gst_network_pump_iface_supported ($iface)); return &gst_parse_pump_get_iface_kw_not ($file, $iface, "nodns"); @@ -3242,11 +3256,11 @@ sub gst_network_debian_parse_remote_address &gst_report_enter (); &gst_report ("network_get_remote", $iface); - + @tuples = &gst_parse_interfaces_option_tuple ($file, $iface, "up", 1); &gst_report_leave (); - + foreach $tuple (@tuples) { @res = $$tuple[1] =~ /[ \t]+pointopoint[ \t]+([^ \t]+)/; @@ -3260,10 +3274,10 @@ sub gst_network_debian_replace_remote_address { my ($file, $iface, $value) = @_; my ($ifconfig, $ret); - + &gst_report_enter (); &gst_report ("network_set_remote", $iface); - + $ifconfig = &gst_file_locate_tool ("ifconfig"); $ret = &gst_replace_interfaces_option_str ($file, $iface, "up", "$ifconfig $iface pointopoint $value"); @@ -3319,7 +3333,7 @@ sub gst_network_debian_woody_set_auto # I'm including the hash here, although the man page says it's not supported. last if $$buff[$line_no] =~ s/[ \t]$iface([\# \t\n])/$1/; } - + $line_no ++; } @@ -3339,7 +3353,7 @@ sub gst_network_debian_woody_set_auto } $$buff[$line_no] =~ s/auto[ \t]*$//; } - + return &gst_file_buffer_save ($buff, $file); } @@ -3489,7 +3503,7 @@ sub gst_network_suse90_set_auto { my ($file, $key, $enabled) = @_; my ($ret); - + if($enabled) { return &gst_replace_sh($file, $key, "onboot"); @@ -3497,7 +3511,7 @@ sub gst_network_suse90_set_auto else { return &gst_replace_sh($file, $key, "manual"); - } + } } # Return IP address or netmask, depending on $what @@ -3506,10 +3520,10 @@ sub gst_network_pld10_get_ipaddr my ($file, $key, $what) = @_; my ($ipaddr, $netmask, $ret, $i); my @netmask_prefixes = (0, 128, 192, 224, 240, 248, 252, 254, 255); - + $ipaddr = &gst_parse_sh($file, $key); return undef if $ipaddr eq ""; - + if($ipaddr =~ /([^\/]*)\/([[:digit:]]*)/) { $netmask = $2; @@ -3665,13 +3679,13 @@ sub gst_network_suse90_replace_gateway { my ($file, $dev, $address, $netmask, $value) = @_; - - return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") if &gst_network_is_ip_in_same_network ($address, $value, $netmask); -# return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") ; - return undef; + + return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") if &gst_network_is_ip_in_same_network ($address, $value, $netmask); +# return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") ; + return undef; } - + # runs a function if the interface is of type $type sub gst_network_check_type @@ -3778,7 +3792,7 @@ sub gst_network_suse90_replace_provider_file_func sub gst_network_suse90_replace_provider_file { my ($provider, $key, $value) = @_; - #make sure the function is called only by modem + #make sure the function is called only by modem if ($provider =~ /ppp/) { return &gst_network_suse90_replace_provider_file_func ($provider, $key, $value, \&gst_replace_sh); @@ -3788,7 +3802,7 @@ sub gst_network_suse90_replace_provider_file sub gst_network_suse90_replace_provider_file_bool { my ($provider, $key, $value) = @_; - #make sure the function is called only by modem + #make sure the function is called only by modem if ($provider =~ /ppp/) { return &gst_network_suse90_replace_provider_file_func ($provider, $key, $value, \&gst_replace_sh_bool); @@ -3958,13 +3972,18 @@ sub gst_network_ensure_loopback_interface "debian-4.0" => "lo", "debian-5.0" => "lo", "debian-testing" => "lo", - "ubuntu-5.04" => "lo", - "ubuntu-5.10" => "lo", - "ubuntu-6.06" => "lo", - "ubuntu-6.10" => "lo", - "ubuntu-7.04" => "lo", - "ubuntu-7.10" => "lo", - "ubuntu-8.04" => "lo", + "ubuntu-5.04" => "lo", + "ubuntu-5.10" => "lo", + "ubuntu-6.06" => "lo", + "ubuntu-6.10" => "lo", + "ubuntu-7.04" => "lo", + "ubuntu-7.10" => "lo", + "ubuntu-8.04" => "lo", + "ubuntu-8.10" => "lo", + "ubuntu-9.04" => "lo", + "ubuntu-9.10" => "lo", + "ubuntu-10.04" => "lo", + "ubuntu-10.10" => "lo", "suse-7.0" => "", "suse-9.0" => "", "suse-9.1" => "", @@ -4029,7 +4048,7 @@ sub gst_network_statichost_add_alias { return if ($i eq $alias); } - + push @$localhost, $alias; } @@ -4046,7 +4065,7 @@ sub gst_network_statichost_remove_alias } } } - + sub gst_network_ensure_loopback_statichost { my ($statichost, $hostname, $old_hostname, $lo_ip) = @_; @@ -4056,11 +4075,11 @@ sub gst_network_ensure_loopback_statichost { my $localhost = $$statichost{$lo_ip}; &gst_network_statichost_remove_alias ($localhost, $old_hostname) if ($old_hostname); - &gst_network_statichost_add_alias ($localhost, $hostname); + &gst_network_statichost_remove_alias ($localhost, $hostname); } else { - $$statichost{$lo_ip} = [ ("localhost", "localhost.localdomain", $hostname) ]; + $$statichost{$lo_ip} = [ ("localhost") ]; } } @@ -4068,10 +4087,13 @@ sub get_network_get_lo_ip { my ($statichost) = @_; - foreach $i (keys %$statichost) - { - return $i if ($i =~ /^127\./); - } +# Ugly workarround, it is considered you have one lo only, which is wrong, so let's +# force the first to be 127.0.0.1 and let the script work for other ones as if they were +# classic hosts entries... At least sudo won't break... +# foreach $i (keys %$statichost) +# { +# return $i if ($i =~ /^127\./); +# } return "127.0.0.1"; } @@ -4125,8 +4147,8 @@ sub gst_network_get_parse_table "mandriva-2007.1" => "redhat-7.0", "yoper-2.2" => "redhat-7.0", "blackpanther-4.0" => "redhat-7.0", - "conectiva-9" => "redhat-7.0", - "conectiva-10" => "redhat-7.0", + "conectiva-9" => "redhat-7.0", + "conectiva-10" => "redhat-7.0", "debian-2.2" => "debian-2.2", "debian-3.0" => "debian-2.2", "debian-3.1" => "debian-2.2", @@ -4140,6 +4162,11 @@ sub gst_network_get_parse_table "ubuntu-7.04" => "debian-2.2", "ubuntu-7.10" => "debian-2.2", "ubuntu-8.04" => "debian-2.2", + "ubuntu-8.10" => "debian-2.2", + "ubuntu-9.04" => "debian-2.2", + "ubuntu-9.10" => "debian-2.2", + "ubuntu-10.04" => "debian-2.2", + "ubuntu-10.10" => "debian-2.2", "suse-7.0" => "suse-7.0", "suse-9.0" => "suse-9.0", "suse-9.1" => "suse-9.0", @@ -4191,7 +4218,7 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], @@ -4226,7 +4253,7 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], @@ -4265,7 +4292,7 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], @@ -4286,7 +4313,6 @@ sub gst_network_get_parse_table HOST_CONF => "/etc/host.conf", HOSTS => "/etc/hosts", HOSTNAME => "/etc/hostname", - SMB_CONF => "/etc/samba/smb.conf", WVDIAL => "/etc/wvdial.conf" }, table => @@ -4302,12 +4328,6 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_parse_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "samba" ], [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], [ "interface", \&gst_network_interfaces_get ] @@ -4338,14 +4358,14 @@ sub gst_network_get_parse_table [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], # This was to take the values from SuSEConfig, but a better solution is to get # the configuration from /etc/resolv.conf and then replace in rc.config, so those -# files stay in sync. +# files stay in sync. # [ "nameserver", \&gst_parse_sh_split, RC_CONFIG, NAMESERVER, "[ \t]+" ], # [ "searchdomain", \&gst_parse_sh_split, RC_CONFIG, SEARCHLIST, "[ \t]+" ], [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_parse_ini, SMB_CONF, "global", "server string" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "smbdesc", \&gst_parse_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], @@ -4389,7 +4409,7 @@ sub gst_network_get_parse_table [ "gatewaydev", \&gst_network_get_gateway_dev_from_address, "%interface%", "%gateway%" ], ] }, - + "pld-1.0" => { fn => @@ -4413,7 +4433,7 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], @@ -4446,7 +4466,7 @@ sub gst_network_get_parse_table [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], @@ -4520,7 +4540,7 @@ sub gst_network_get_parse_table ] }, ); - + my $dist = $dist_map{$gst_dist}; return %{$dist_tables{$dist}} if $dist; @@ -4571,6 +4591,11 @@ sub gst_network_get_interface_parse_table "ubuntu-7.04" => "debian-3.0", "ubuntu-7.10" => "debian-3.0", "ubuntu-8.04" => "debian-3.0", + "ubuntu-8.10" => "debian-3.0", + "ubuntu-9.04" => "debian-3.0", + "ubuntu-9.10" => "debian-3.0", + "ubuntu-10.04" => "debian-3.0", + "ubuntu-10.10" => "debian-3.0", "suse-7.0" => "suse-7.0", "suse-9.0" => "suse-9.0", "suse-9.1" => "suse-9.0", @@ -4596,7 +4621,7 @@ sub gst_network_get_interface_parse_table "freebsd-5" => "freebsd-5", "freebsd-6" => "freebsd-5", ); - + my %dist_tables = ( "redhat-6.2" => @@ -5369,7 +5394,7 @@ sub gst_network_get_interface_parse_table ] }, ); - + my $dist = $dist_map{$gst_dist}; return %{$dist_tables{$dist}} if $dist; @@ -5419,6 +5444,11 @@ sub gst_network_get_replace_table "ubuntu-7.04" => "debian-2.2", "ubuntu-7.10" => "debian-2.2", "ubuntu-8.04" => "debian-2.2", + "ubuntu-8.10" => "debian-2.2", + "ubuntu-9.04" => "debian-2.2", + "ubuntu-9.10" => "debian-2.2", + "ubuntu-10.04" => "debian-2.2", + "ubuntu-10.10" => "debian-2.2", "suse-7.0" => "suse-7.0", "suse-9.0" => "suse-9.0", "suse-9.1" => "suse-9.0", @@ -5472,7 +5502,7 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], @@ -5481,7 +5511,7 @@ sub gst_network_get_replace_table [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] ] }, - + "redhat-7.0" => { fn => @@ -5507,7 +5537,7 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], @@ -5546,7 +5576,7 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], @@ -5614,13 +5644,13 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], [ "smbuse", \&gst_service_sysv_set_status, 20, "smb", "%smbuse%" ], [ "interface", \&gst_network_suse70_set_ppp, [WVDIAL, "%dialing%"] ], -# We're calling this sepparated cuz we are going to call wvdial to activate. +# We're calling this sepparated cuz we are going to call wvdial to activate. [ "interface", \&gst_network_suse70_activate_ppp ], [ "interface", \&gst_network_interfaces_set, OLD_HASH ], [ "_always_", \&gst_file_run, SUSECONFIG ], @@ -5657,7 +5687,7 @@ sub gst_network_get_replace_table [ "interface", \&gst_network_interfaces_set, OLD_HASH ], ] }, - + "pld-1.0" => { fn => @@ -5683,7 +5713,7 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], @@ -5715,7 +5745,7 @@ sub gst_network_get_replace_table [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], + [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], @@ -5785,7 +5815,7 @@ sub gst_network_get_replace_table ] } ); - + my $dist = $dist_map{$gst_dist}; return %{$dist_tables{$dist}} if $dist; @@ -5835,6 +5865,11 @@ sub gst_network_get_interface_replace_table "ubuntu-7.04" => "debian-3.0", "ubuntu-7.10" => "debian-3.0", "ubuntu-8.04" => "debian-3.0", + "ubuntu-8.10" => "debian-3.0", + "ubuntu-9.04" => "debian-3.0", + "ubuntu-9.10" => "debian-3.0", + "ubuntu-10.04" => "debian-3.0", + "ubuntu-10.10" => "debian-3.0", "suse-7.0" => "suse-7.0", "suse-9.0" => "suse-9.0", "suse-9.1" => "suse-9.0", @@ -5981,7 +6016,7 @@ sub gst_network_get_interface_replace_table [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], ] }, - + "redhat-8.0" => { iface_set => \&gst_network_rh62_interface_activate, @@ -6043,7 +6078,7 @@ sub gst_network_get_interface_replace_table [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], ] }, - + "vine-3.0" => { iface_set => \&gst_network_rh62_interface_activate, @@ -6347,7 +6382,7 @@ sub gst_network_get_interface_replace_table }, table => [ -# bootproto has to go second for suse, as it uses the same value for bootproto and params. +# bootproto has to go second for suse, as it uses the same value for bootproto and params. [ "bootproto", \&gst_network_suse70_replace_bootproto, [IFCFG, IFACE] ], [ "auto", \&gst_network_suse70_replace_iface_auto, [IFCFG, IFACE], NETCONFIG ], [ "dev", \&gst_network_suse70_replace_iface_sh, [IFCFG, IFACE], NETDEV ], @@ -6363,12 +6398,12 @@ sub gst_network_get_interface_replace_table [ "update_dns", \&gst_replace_kw, PPP_OPTIONS, "usepeerdns" ] ] }, - + "suse-9.0" => { - iface_set => \&gst_network_suse9_interface_activate, - iface_delete => \&gst_network_suse90_interface_delete, - ifaces_get => \&gst_network_suse90_ifaces_get_existing, + iface_set => \&gst_network_suse9_interface_activate, + iface_delete => \&gst_network_suse90_interface_delete, + ifaces_get => \&gst_network_suse90_ifaces_get_existing, fn => { IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", @@ -6380,7 +6415,7 @@ sub gst_network_get_interface_replace_table [ [ "auto", \&gst_network_suse90_set_auto, IFCFG, STARTMODE ], [ "bootproto", \&gst_network_suse90_replace_bootproto, IFCFG, BOOTPROTO ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], + [ "address", \&gst_replace_sh, IFCFG, IPADDR ], [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], [ "remote_address", \&gst_replace_sh, IFCFG, REMOTE_IPADDR ], [ "essid", \&gst_replace_sh, IFCFG, WIRELESS_ESSID ], @@ -6594,7 +6629,7 @@ sub gst_network_get_interface_replace_table ] } ); - + my $dist = $dist_map{$gst_dist}; return %{$dist_tables{$dist}} if $dist; |