diff options
Diffstat (limited to 'perl-install/network/netconnect.pm')
| -rw-r--r-- | perl-install/network/netconnect.pm | 534 |
1 files changed, 295 insertions, 239 deletions
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index 91c5ec7e2..dda85ae1a 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -7,29 +7,30 @@ use detect_devices; use run_program; use modules; use any; +use fs; use mouse; use network::network; use network::tools; use MDK::Common::Globals "network", qw($in); sub detect { - my ($auto_detect, $o_class) = @_; + my ($modules_conf, $auto_detect, $o_class) = @_; my %l = ( isdn => sub { require network::isdn; - $auto_detect->{isdn} = network::isdn::detect_backend(); + $auto_detect->{isdn} = network::isdn::detect_backend($modules_conf); }, lan => sub { # ethernet - modules::load_category('network/main|gigabit|usb'); require network::ethernet; - $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards() }; + modules::load_category($modules_conf, network::ethernet::get_eth_categories()); + $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) }; }, adsl => sub { require network::adsl; $auto_detect->{adsl} = network::adsl::adsl_detect(); }, modem => sub { - $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem() }; + $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) }; }, ); $l{$_}->() foreach $o_class || keys %l; @@ -74,22 +75,22 @@ sub get_subwizard { # configuring all network devices sub real_main { - my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; + my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; my $netc = $o_netc ||= {}; my $mouse = $o_mouse ||= {}; my $intf = $o_intf ||= {}; my $first_time = $o_first_time || 0; - my ($network_configured, $direct_net_install, $cnx_type, $type, $interface, @all_cards, %eth_intf); + my ($network_configured, $cnx_type, $type, @all_cards, %eth_intf, %all_eth_intf); my (%connections, @connection_list, $is_wireless); my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip); my ($adsl_type, @adsl_devices, $adsl_failed, $adsl_answer, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider); - my ($ntf_name, $ipadr, $netadr, $gateway_ex, $up, $need_restart_network); - my ($isdn, $isdn_name, $isdn_type, %isdn_cards); + my ($ntf_name, $gateway_ex, $up, $need_restart_network); + my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods); my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")"); my ($module, $auto_ip, $protocol, $onboot, $needhostname, $hotplug, $track_network_id, @fields); # lan config my $success = 1; my $ethntf = {}; - my $db_path = "$::prefix/usr/share/apps/kppp/Provider"; + my $db_path = "/usr/share/apps/kppp/Provider"; my (%countries, @isp, $country, $provider, $old_provider); my $config = {}; eval(cat_("$::prefix/etc/sysconfig/drakconnect")); @@ -117,22 +118,20 @@ sub real_main { network::tools::remove_initscript(); init_globals($in); - $netc->{NET_DEVICE} = $netcnx->{NET_DEVICE} if $netcnx->{NET_DEVICE}; # REDONDANCE with read_conf. FIXME - $netc->{NET_INTERFACE} = $netcnx->{NET_INTERFACE} if $netcnx->{NET_INTERFACE}; # REDONDANCE with read_conf. FIXME - network::network::read_all_conf($::prefix, $netc, $intf); - modules::mergein_conf(); + read_net_conf($netcnx, $netc, $intf); $netc->{autodetect} = {}; my $lan_detect = sub { - detect($netc->{autodetect}, 'lan'); - modules::interactive::load_category($in, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 0); - @all_cards = network::ethernet::get_eth_cards(); - %eth_intf = network::ethernet::get_eth_cards_names(@all_cards); - require list_modules; + detect($modules_conf, $netc->{autodetect}, 'lan'); + require network::ethernet; + modules::interactive::load_category($in, $modules_conf, network::ethernet::get_eth_categories(), !$::expert, 0); + @all_cards = network::ethernet::get_eth_cards($modules_conf); + %all_eth_intf = network::ethernet::get_eth_cards_names(@all_cards); #- needed not to loose GATEWAYDEV + require list_modules; #- FIXME: check if useful %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } - grep { $is_wireless ^ !c::isNetDeviceWirelessAware($_->[0]) } @all_cards; + grep { to_bool($is_wireless) == c::isNetDeviceWirelessAware($_->[0]) } @all_cards; }; my $find_lan_module = sub { @@ -144,8 +143,7 @@ sub real_main { }; my $is_hotplug_blacklisted = sub { - bool2yesno($is_wireless || - member($module, qw(b44 forcedeth madwifi_pci)) || + bool2yesno(member($module, qw(b44 forcedeth madwifi_pci)) || find { $_->{device} eq $ntf_name } detect_devices::pcmcia_probe()); }; @@ -162,6 +160,7 @@ sub real_main { pptp => N("Point to Point Tunneling Protocol (PPTP)"), pppoe => N("PPP over Ethernet (PPPoE)"), pppoa => N("PPP over ATM (PPPoA)"), + capi => N("DSL over CAPI"), ); my %encapsulations = ( @@ -169,8 +168,8 @@ sub real_main { 2 => N("Bridged Ethernet VC"), 3 => N("Routed IP LLC"), 4 => N("Routed IP VC"), - 5 => N("PPPOA LLC"), - 6 => N("PPPOA VC"), + 5 => N("PPPoA LLC"), + 6 => N("PPPoA VC"), ); my %ppp_auth_methods = ( @@ -182,26 +181,30 @@ sub real_main { ); my $offer_to_connect = sub { - return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && $adsl_devices{$ntf_name}; - return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn)); + return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && !member($adsl_type, qw(manual dhcp)); + return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn isdn_external)); return "end"; }; my $after_start_on_boot_step = sub { - if ($netc->{internet_cnx_choice}) { - write_cnx_script($netc); - $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type} if $netc->{internet_cnx_choice}; + if ($netc->{internet_cnx_choice} && exists $netc->{internet_cnx}{$netc->{internet_cnx_choice}}) { + $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type}; } else { undef $netc->{NET_DEVICE}; } - network::network::configureNetwork2($in, $::prefix, $netc, $intf); + if ($netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)) && member($ntf_name, qw(sagem))) { + #- we need to write sagem specific parameters and load corresponding modules/programs + network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); + } + network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf); $network_configured = 1; - return "restart" if $need_restart_network && $::isStandalone && !$::expert; + return "restart" if $need_restart_network && !$::isInstall && !$::expert; return $offer_to_connect->(); }; my $goto_start_on_boot_ifneeded = sub { - return $after_start_on_boot_step->() if $netcnx->{type} =~ /lan|cable/; + return $after_start_on_boot_step->() if $netcnx->{type} eq "lan"; + return "isdn_dial_on_boot" if $netcnx->{type} =~ /isdn/; return "network_on_boot"; }; @@ -214,14 +217,13 @@ sub real_main { }; my $handle_multiple_cnx = sub { - $need_restart_network = 1 if $netcnx->{type} =~ /adsl|cable|lan/; + $need_restart_network = member($netcnx->{type}, qw(cable lan)) || $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)); my $nb = keys %{$netc->{internet_cnx}}; if (1 < $nb) { return "multiple_internet_cnx"; } else { - $netc->{internet_cnx_choice} = (keys %{$netc->{internet_cnx}})[0] if $nb == 1; - $save_cnx->(); - return $goto_start_on_boot_ifneeded->() + $netc->{internet_cnx_choice} = $nb == 1 ? (keys %{$netc->{internet_cnx}})[0] : $netcnx->{type}; + return $save_cnx->(); } }; @@ -261,7 +263,8 @@ sub real_main { data => \@connection_list, post => sub { $is_wireless = $cnx_type eq N("Wireless connection"); - load_conf($netcnx, $netc, $intf) if $::isInstall; # :-( + #- why read again the net_conf here? + read_net_conf($netcnx, $netc, $intf) if $::isInstall; # :-( $type = $netcnx->{type} = $connections{$cnx_type}; if ($type eq 'cable') { $auto_ip = 1; @@ -310,29 +313,16 @@ sub real_main { ], }, post => sub { - network::isdn::write_config($isdn, $netc); # or return 'isdn_protocol'; + network::isdn::write_config($isdn); $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE'; - # return "static_hostname"; $handle_multiple_cnx->(); }, }, - - - # KILLME?: no longer called and deprecated fonction calls :-( - #go_ethernet => - #{ - # pre => sub { - # conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return; - # $netc->{NET_INTERFACE} = $netc->{NET_DEVICE}; - # configureNetwork($netc, $intf, $first_time) or return; - # }, - #}, - isdn => { pre=> sub { - detect($netc->{autodetect}, 'isdn'); + detect($modules_conf, $netc->{autodetect}, 'isdn'); %isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}}; }, name => N("Select the network interface to configure:"), @@ -347,10 +337,13 @@ sub real_main { if ($isdn_name eq $my_isdn) { return "isdn_ask"; } elsif ($isdn_name eq N("External ISDN modem")) { - detect($netc->{autodetect}, 'modem'); - $netc->{isdntype} = 'isdn_external'; + detect($modules_conf, $netc->{autodetect}, 'modem'); + $netcnx->{type} = $netc->{isdntype} = 'isdn_external'; $netcnx->{isdn_external}{device} = network::modem::first_modem($netc); network::isdn::read_config($netcnx->{isdn_external}); + #- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i + #- it doesn't even work with TA 128 modems + #- http://bugs.mandrakelinux.com/query.php?bug=1033 $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40'; require network::modem; $modem = $netcnx->{isdn_external}; @@ -364,13 +357,17 @@ sub real_main { if ($isdn->{id}) { log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n"); $isdn->{description} =~ s/\|/ -- /; - } - network::isdn::read_config($netcnx->{isdn_internal}); + + network::isdn::read_config($isdn); + $isdn->{driver} = $isdn_cards{$isdn_name}{driver}; #- do not let config overwrite default driver + + #- let the user choose hisax or capidrv if both are available + $isdn->{driver} ne "capidrv" && network::isdn::get_capi_card($isdn) and return "isdn_driver"; return "isdn_protocol"; }, }, - + isdn_ask => { @@ -419,7 +416,24 @@ If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card. } }, - + + isdn_driver => + { + pre => sub { + $isdn_name = "capidrv"; + }, + name => N("A CAPI driver is available for this modem. This CAPI driver can offer more capabilities than the free driver (like sending faxes). Which driver do you want to use?"), + data => sub { [ + { label => N("Driver"), type => "list", val => \$isdn_name, + list => [ $isdn->{driver}, "capidrv" ] } + ] }, + post => sub { + $isdn->{driver} = $isdn_name; + return "isdn_protocol"; + } + }, + + isdn_protocol => { name => N("ISDN Configuration") . "\n\n" . N("Which protocol do you want to use?"), @@ -463,19 +477,13 @@ Take a look at http://www.linmodems.org"), { pre => sub { require network::modem; - detect($netc->{autodetect}, 'modem'); + detect($modules_conf, $netc->{autodetect}, 'modem'); }, name => N("Select the modem to configure:"), data => sub { [ { label => N("Modem"), type => "list", val => \$modem_name, allow_empty_list => 1, list => [ keys %{$netc->{autodetect}{modem}}, N("Manual choice") ], } ], }, - complete => sub { - if ($netc->{autodetect}{modem}{$modem_name}{driver} =~ /^(LT|H[cs]f):/ && c::kernel_version() !~ /^\Q2.4/) { - $in->ask_warn(N("Warning"), N("Sorry, we support only 2.4 and above kernels.")); - } - return 0; - }, post => sub { $modem ||= $netcnx->{modem} ||= {};; return 'choose_serial_port' if $modem_name eq N("Manual choice"); @@ -487,26 +495,36 @@ Take a look at http://www.linmodems.org"), my $type; my %pkgs2path = ( - hcfpcimodem => "$::prefix/usr/sbin/hcfpciconfig", - hsflinmodem => "$::prefix/usr/sbin/hsfconfig", - ltmodem => "$::prefix/etc/devfs/conf.d/ltmodem.conf", + hcfpcimodem => "/usr/sbin/hcfpciconfig", + hsflinmodem => "/usr/sbin/hsfconfig", + ltmodem => "/etc/devfs/conf.d/ltmodem.conf", + slmodem => "/usr/sbin/slmodemd", ); my %devices = (ltmodem => '/dev/ttyS14', - hsflinmodem => '/dev/ttySHSF0' + hsflinmodem => '/dev/ttySHSF0', + slmodem => '/dev/ttySL0' ); if (my $driver = $netc->{autodetect}{modem}{$modem_name}{driver}) { - $driver =~ /^Hcf:/ and $type = "hcfpcimodem"; - $driver =~ /^Hsf:/ and $type = "hsflinmodem"; + $driver =~ /^Hcf:/ and $type = "hcfmodem"; + $driver =~ /^Hsf:/ and $type = "hsfmodem"; $driver =~ /^LT:/ and $type = "ltmodem"; - $type = undef if !($type && (-f $pkgs2path{$type} || $in->do_pkgs->ensure_is_installed_if_available($type, $pkgs2path{$type}))); - $modem->{device} = $devices{$type} || '/dev/modem' if $type; # automatically linked by /etc/devfs/conf entry + #- we need a better agreement to use list_modules::category2modules('network/slmodem') + member($driver, qw(slamr slusb)) and $type = "slmodem"; + if ($type && (my $packages = $in->do_pkgs->check_kernel_module_packages("$type-kernel", if_(! -f $pkgs2path{$type}, $type)))) { + if ($in->do_pkgs->install(@$packages)) { + # start slmodemd when installing it (thus preventing the average user to have to restart + # his machine in order to get a working connection): + system("service slmodemd start") if $::isStandalone && $type eq 'slmodem'; + } + $modem->{device} = $devices{$type} || '/dev/modem'; + return "ppp_provider"; + } } - - #- fallback to modem configuration (beware to never allow test it). - return $type ? "ppp_provider" : "no_supported_winmodem"; + + return "no_supported_winmodem"; }, }, @@ -517,7 +535,7 @@ Take a look at http://www.linmodems.org"), interactive_help_id => 'selectSerialPort', data => sub { [ { val => \$modem->{device}, format => \&mouse::serial_port2text, type => "list", - list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0') ] } ], + list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ], }, post => sub { $ntf_name = $modem->{device}; @@ -531,30 +549,35 @@ Take a look at http://www.linmodems.org"), pre => sub { network::modem::ppp_read_conf($netcnx, $netc) if !$modem_conf_read; $modem_conf_read = 1; + $in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path); + my $p_db_path = "$::prefix$db_path"; @isp = map { my $country = $_; map { - s!$db_path/$country!!; + s!$p_db_path/$country!!; s/%([0-9]{3})/chr(int($1))/eg; $countries{$country} ||= translate($country); join('', $countries{$country}, $_); - } grep { !/.directory$/ } glob_("$db_path/$country/*") - } map { s!$db_path/!!o; s!_! !g; $_ } glob_("$db_path/*"); + } grep { !/.directory$/ } glob_("$p_db_path/$country/*") + } map { s!$p_db_path/!!o; s!_! !g; $_ } glob_("$p_db_path/*"); $old_provider = $provider; }, name => N("Select your provider:"), data => sub { - [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/', list => \@isp } ] + [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/', + list => [ N("Unlisted - edit manually"), @isp ] } ] }, post => sub { - ($country, $provider) = split('/', $provider); - $country = { reverse %countries }->{$country}; - my %l = getVarsFromSh("$db_path/$country/$provider"); - if (defined $old_provider && $old_provider ne $provider) { - $modem->{connection} = $l{Name}; - $modem->{phone} = $l{Phonenumber}; - $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask); - ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS}); + if ($provider ne N("Unlisted - edit manually")) { + ($country, $provider) = split('/', $provider); + $country = { reverse %countries }->{$country}; + my %l = getVarsFromSh("$::prefix$db_path/$country/$provider"); + if (defined $old_provider && $old_provider ne $provider) { + $modem->{connection} = $l{Name}; + $modem->{phone} = $l{Phonenumber}; + $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask); + ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS}); + } } return "ppp_account"; }, @@ -566,10 +589,6 @@ Take a look at http://www.linmodems.org"), pre => sub { $mouse ||= {}; $mouse->{device} ||= readlink "$::prefix/dev/mouse"; - set_cnx_script($netc, "modem", join("\n", if_($::testing, "/sbin/route del default"), "ifup ppp0"), - q(ifdown ppp0 -killall pppd -), $netcnx->{type}); }, name => N("Dialup: account options"), data => sub { @@ -635,7 +654,6 @@ killall pppd post => sub { network::modem::ppp_configure($in, $modem); $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE'; - $in->do_pkgs->ensure_is_installed('kdenetwork-kppp', '/usr/bin/kppp'); $handle_multiple_cnx->(); }, }, @@ -646,33 +664,49 @@ killall pppd pre => sub { get_subwizard($wiz, 'adsl'); $lan_detect->(); - detect($netc->{autodetect}, 'adsl'); @adsl_devices = keys %eth_intf; + + detect($modules_conf, $netc->{autodetect}, 'adsl'); foreach my $modem (keys %adsl_devices) { push @adsl_devices, $modem if $netc->{autodetect}{adsl}{$modem}; } + + detect($modules_conf, $netc->{autodetect}, 'isdn'); + if (my @isdn_modems = @{$netc->{autodetect}{isdn}}) { + require network::isdn; + %isdn_cards = map { $_->{description} => $_ } grep { $_->{driver} =~ /dsl/i } map { network::isdn::get_capi_card($_) } @isdn_modems; + push @adsl_devices, keys %isdn_cards; + } }, name => N("ADSL configuration") . "\n\n" . N("Select the network interface to configure:"), data => [ { label => N("Net Device"), type => "list", val => \$ntf_name, allow_empty_list => 1, - list => \@adsl_devices, format => sub { $eth_intf{$_[0]} || $adsl_devices{$_[0]} } } ], + list => \@adsl_devices, format => sub { $eth_intf{$_[0]} || $adsl_devices{$_[0]} || $_[0] } } ], post => sub { my %packages = ( 'eci' => [ 'eciadsl', 'missing' ], - 'sagem' => [ 'eagle-usb', "$::prefix/usr/sbin/eaglectrl" ], - 'speedtouch' => [ 'speedtouch', "$::prefix/usr/share/speedtouch/speedtouch.sh" ], + 'sagem' => [ 'eagle-usb', "/usr/sbin/eaglectrl" ], + 'speedtouch' => [ 'speedtouch', "/usr/sbin/modem_run" ], ); return 'adsl_unsupported_eci' if $ntf_name eq 'eci'; - $in->do_pkgs->install($packages{$ntf_name}[0]) if $packages{$ntf_name} && !-e $packages{$ntf_name}->[1]; + # FIXME: check that the package installation succeeds, else retry or abort + $in->do_pkgs->ensure_is_installed(@{$packages{$ntf_name}}) if $packages{$ntf_name}; if ($ntf_name eq 'speedtouch') { - $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "$::prefix/usr/share/speedtouch/mgmt.o"); + $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "/usr/share/speedtouch/mgmt.o"); return 'adsl_speedtouch_firmware' if ! -e "$::prefix/usr/share/speedtouch/mgmt.o"; } $netcnx->{bus} = $netc->{autodetect}{adsl}{bewan}{bus} if $ntf_name eq 'bewan'; if ($ntf_name eq 'bewan' && !$::testing) { - $in->do_pkgs->ensure_is_installed_if_available('unicorn', "$::prefix/usr/bin/bewan_adsl_status"); + if (my @unicorn_packages = $in->do_pkgs->check_kernel_module_packages('unicorn-kernel', 'unicorn')) { + $in->do_pkgs->install(@unicorn_packages); + } } - return 'adsl_provider' if $adsl_devices{$ntf_name}; - return 'adsl_protocol'; + if (exists($isdn_cards{$ntf_name})) { + require network::isdn; + $netcnx->{capi} = $isdn_cards{$ntf_name}; + $adsl_type = "capi"; + return 'adsl_account'; + } + return 'adsl_provider'; }, }, @@ -761,15 +795,17 @@ and copy the mgmt.o in /usr/share/speedtouch", 'http://prdownloads.sourceforge.n # preselect right protocol for ethernet though connections: if (!exists $adsl_devices{$ntf_name}) { $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; - $adsl_type = $ethntf->{BOOTPROTO} || "dhcp"; + $adsl_type ||= $ethntf->{BOOTPROTO} || "dhcp"; + #- pppoa shouldn't be selected by default for ethernet devices, fallback on pppoe + $adsl_type = "pppoe" if $adsl_type eq "pppoa"; } }, name => N("Connect to the Internet") . "\n\n" . N("The most common way to connect with adsl is pppoe. -Some connections use pptp, a few use dhcp. -If you don't know, choose 'use pppoe'"), +Some connections use PPTP, a few use DHCP. +If you don't know, choose 'use PPPoE'"), data => [ - { text => N("ADSL connection type :"), val => \$adsl_type, type => "list", + { text => N("ADSL connection type:"), val => \$adsl_type, type => "list", list => [ sort { $adsl_types{$a} cmp $adsl_types{$b} } keys %adsl_types ], format => sub { $adsl_types{$_[0]} }, }, @@ -779,13 +815,19 @@ If you don't know, choose 'use pppoe'"), # blacklist bogus driver, enable ifplugd support else: $find_lan_module->(); $ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->(); + if ($ntf_name eq "sagem" && member($adsl_type, qw(manual dhcp))) { + #- "fctStartAdsl -i" builds ifcfg-ethX from ifcfg-sagem and echoes ethX + #- it auto-detects dhcp/static modes thanks to encapsulation setting + $ethntf = $intf->{sagem} ||= {}; + $ethntf->{DEVICE} = "`/usr/sbin/fctStartAdsl -i`"; + $ethntf->{MII_NOT_SUPPORTED} = "yes"; + } # process static/dhcp ethernet devices: - if (!exists $adsl_devices{$ntf_name} && member($adsl_type, qw(manual dhcp))) { + if (exists($intf->{$ntf_name}) && member($adsl_type, qw(manual dhcp))) { + $ethntf->{TYPE} = "ADSL"; $auto_ip = $adsl_type eq 'dhcp'; return 'lan_intf'; } - network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name); - $netc->{NET_DEVICE} = $ntf_name if $adsl_type eq 'pppoe'; return 'adsl_account'; }, }, @@ -793,6 +835,11 @@ If you don't know, choose 'use pppoe'"), adsl_account => { + pre => sub { + network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name); + $netc->{NET_DEVICE} = member($adsl_type, 'pppoe', 'pptp') ? $ntf_name : 'ppp0'; + $netc->{NET_INTERFACE} = 'ppp0'; + }, name => N("Connection Configuration") . "\n\n" . N("Please fill or check the field below"), data => sub { @@ -802,10 +849,12 @@ If you don't know, choose 'use pppoe'"), { label => N("Second DNS Server (optional)"), val => \$netc->{dnsServer3} }, { label => N("Account Login (user name)"), val => \$netcnx->{login} }, { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1 }, - { label => N("Virtual Path ID (VPI):"), val => \$netc->{vpi}, advanced => 1 }, - { label => N("Virtual Circuit ID (VCI):"), val => \$netc->{vci}, advanced => 1 }, + if_($adsl_type ne "capi", + { label => N("Virtual Path ID (VPI):"), val => \$netc->{vpi}, advanced => 1 }, + { label => N("Virtual Circuit ID (VCI):"), val => \$netc->{vci}, advanced => 1 } + ), if_($ntf_name eq "sagem", - { label => N("Encapsulation :"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ], + { label => N("Encapsulation:"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ], format => sub { $encapsulations{$_[0]} }, advanced => 1, }, ), @@ -813,7 +862,7 @@ If you don't know, choose 'use pppoe'"), }, post => sub { $netc->{internet_cnx_choice} = 'adsl'; - network::adsl::adsl_conf_backend($in, $netcnx, $netc, $ntf_name, $adsl_type, $netcnx); #FIXME + network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); #FIXME $config->{adsl} = { kind => $ntf_name, protocol => $adsl_type }; $handle_multiple_cnx->(); }, @@ -838,11 +887,12 @@ You can find a driver on http://eciadsl.flashtux.org/"), allow_empty_list => 1, format => sub { translate($eth_intf{$_[0]} || $_[0]) } } ]; }, post => sub { - $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; if ($ntf_name eq "Manually load a driver") { - modules::interactive::load_category__prompt($in, 'network/main|gigabit|pcmcia|usb|wireless'); + require network::ethernet; + modules::interactive::load_category__prompt($in, $modules_conf, network::ethernet::get_eth_categories()); return 'lan'; } + $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; $::isInstall && $netc->{NET_DEVICE} eq $ethntf->{DEVICE} ? 'lan_alrd_cfg' : 'lan_protocol'; }, }, @@ -850,9 +900,10 @@ You can find a driver on http://eciadsl.flashtux.org/"), lan_alrd_cfg => { name => N("WARNING: this device has been previously configured to connect to the Internet. -Simply accept to keep this device configured. -Modifying the fields below will override this configuration."), +Modifying the fields below will override this configuration. +Do you really want to reconfigure this device?"), type => "yesorno", + default => "no", post => sub { my ($res) = @_; return $res ? "lan_protocol" : "alrd_end"; @@ -873,6 +924,9 @@ Modifying the fields below will override this configuration."), { pre => sub { $find_lan_module->(); + my $intf_type = member($module, list_modules::category2modules('network/gigabit')) ? "ethernet_gigabit" : "ethernet"; + defined($ethntf->{METRIC}) or $ethntf->{METRIC} = network::tools::get_default_metric($intf_type); + $protocol = $l10n_lan_protocols{defined $auto_ip ? ($auto_ip ? 'dhcp' : 'static') : $ethntf->{BOOTPROTO}} || 0; }, name => sub { @@ -904,6 +958,7 @@ Modifying the fields below will override this configuration."), $track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop(); delete $ethntf->{NETWORK}; delete $ethntf->{BROADCAST}; + delete $ethntf->{TYPE} unless $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)); @fields = qw(IPADDR NETMASK); $netc->{dhcp_client} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)) || "dhcp-client"; $netc->{dhcp_client} = "dhcp-client" if $netc->{dhcp_client} eq "dhclient"; @@ -927,7 +982,9 @@ notation (for example, 1.2.3.4).")), ), { text => N("Track network card id (useful for laptops)"), val => \$track_network_id, type => "bool" }, { text => N("Network Hotplugging"), val => \$hotplug, type => "bool" }, - { text => N("Start at boot"), val => \$onboot, type => "bool" }, + if_($netcnx->{type} eq "lan", + { text => N("Start at boot"), val => \$onboot, type => "bool" }, + ), if_($auto_ip, { label => N("DHCP client"), val => \$netc->{dhcp_client}, list => [ qw(dhcp-client dhcpcd pump dhcpxd) ], advanced => 1 }, @@ -942,7 +999,15 @@ notation (for example, 1.2.3.4).")), $in->ask_warn(N("Error"), N("IP address should be in format 1.2.3.4")); return 1, $bad[0]; } - $in->ask_warn(N("Error"), N("Warning : IP address %s is usually reserved !", $ethntf->{IPADDR})) if is_ip_forbidden($ethntf->{IPADDR}); + if (is_ip_forbidden($ethntf->{IPADDR})) { + $in->ask_warn(N("Error"), N("Warning: IP address %s is usually reserved!", $ethntf->{IPADDR})); + return 1; + } + #- test if IP address is already used (do not test for sagem DSL devices since it may use many ifcfg files) + if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %$intf) { + $in->ask_warn(N("Error"), N("%s already in use\n", $ethntf->{IPADDR})); + return 1; + } }, focus_out => sub { $ethntf->{NETMASK} ||= netmask($ethntf->{IPADDR}) unless $_[0] @@ -952,14 +1017,8 @@ notation (for example, 1.2.3.4).")), $ethntf->{NEEDHOSTNAME} = bool2yesno($needhostname); $ethntf->{MII_NOT_SUPPORTED} = bool2yesno(!$hotplug); $ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR}; + $netc->{$_} = $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE); $in->do_pkgs->install($netc->{dhcp_client}) if $auto_ip; - set_cnx_script($netc, "cable", qq( -/sbin/ifup $netc->{NET_DEVICE} -), - qq( -/sbin/ifdown $netc->{NET_DEVICE} -), $netcnx->{type}) if $netcnx->{type} eq 'cable'; - return $is_wireless ? "wireless" : "static_hostname"; }, }, @@ -1017,7 +1076,7 @@ or off.") help => N("Here, one can configure some extra wireless parameters such as: ap, channel, commit, enc, power, retry, sens, txpower (nick is already set as the hostname). -See iwpconfig(8) man page for further information."), +See iwconfig(8) man page for further information."), }, { label => #-PO: split the "xyz command extra argument" translated string into two lines if it's bigger than the english one @@ -1047,34 +1106,50 @@ See iwpriv(8) man page for further information."), post => sub { # untranslate parameters $ethntf->{WIRELESS_MODE} = $wireless_mode{$ethntf->{WIRELESS_MODE}}; + if ($module =~ /^prism2_/) { + $in->do_pkgs->install('prism2-utils'); + if ($ethntf->{WIRELESS_ESSID}) { + my $update_vars_in_wlan = sub { #- FIXME: to be improved (quotes, comments) and moved in common files + my ($file, $vars) = @_; + substInFile { + while (my ($key, $value) = each(%$vars)) { + s/^#?\Q$key\E=(?:"[^#]*"|[^#\s]*)(\s*#.*)?/$key=$value$1/ and delete $vars->{$key}; + } + $_ .= join('', map { "$_=$vars->{$_}\n" } keys %$vars) if eof; + } $file; + }; + my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf"; + my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]); + push @wlan_devices, $ethntf->{DEVICE} unless member($ethntf->{DEVICE}, @wlan_devices); + #- enable device and make it use the choosen ESSID + $update_vars_in_wlan->($wlan_conf_file, + { + WLAN_DEVICES => qq("@wlan_devices"), + "SSID_$ethntf->{DEVICE}" => qq("$ethntf->{WIRELESS_ESSID}"), + "ENABLE_$ethntf->{DEVICE}" => "y" + }); + my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$ethntf->{WIRELESS_ESSID}"; + #- copy default settings for this ESSID if config file doesn't exist + -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file); + #- enable/disable encryption + $update_vars_in_wlan->($wlan_ssid_file, + { + (map { $_ => $ethntf->{WIRELESS_ENC_KEY} ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)), + AuthType => $ethntf->{WIRELESS_ENC_KEY} ? qq("sharedkey") : qq("opensystem"), + if_($ethntf->{WIRELESS_ENC_KEY}, + dot11WEPDefaultKeyID => 0, + dot11WEPDefaultKey0 => qq("$ethntf->{WIRELESS_ENC_KEY}") + ) + }); + #- apply settings on wlan interface + require services; + services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan'); + } + } return "static_hostname"; }, }, - conf_network_card => - { - pre => sub { - #-type =static or dhcp - modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1); - @all_cards = network::ethernet::get_eth_cards() or - # FIXME: fix this - $in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system. -I cannot set up this connection type.")), return; - - }, - name => N("Choose the network interface") . "\n\n" . - N("Please choose which network adapter you want to use to connect to Internet."), - data => [ { val => \$interface, type => "list", list => \@all_cards, } ], - format => sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") }, - - post => sub { - network::ethernet::write_ether_conf(); - modules::write_conf() if $::isStandalone; - my $_device = network::ethernet::conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr); - return "lan"; - }, - }, - static_hostname => { pre => sub { @@ -1082,6 +1157,11 @@ I cannot set up this connection type.")), return; $netc->{dnsServer} ||= dns($ethntf->{IPADDR}); $gateway_ex = gateway($ethntf->{IPADDR}); # $netc->{GATEWAY} ||= gateway($ethntf->{IPADDR}); + if ($ntf_name eq "sagem") { + my @sagem_ip = split(/\./, $ethntf->{IPADDR}); + @sagem_ip[3] = 254; + $netc->{GATEWAY} = join(".", @sagem_ip); + } } }, name => N("Please enter your host name. @@ -1099,8 +1179,8 @@ N("Last but not least you can also type in your DNS server IP addresses."), help => N("By default search domain will be set from the fully-qualified host name") }, { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} }, if_(@all_cards > 1, - { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ sort keys %eth_intf ], - format => sub { $eth_intf{$_[0]} } }, + { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ sort keys %all_eth_intf ], + format => sub { $all_eth_intf{$_[0]} } }, ), ), ], @@ -1151,7 +1231,7 @@ It is not necessary on most networks."), apply_settings => { - name => N("Configuration is complete, do you want to apply settings ?"), + name => N("Configuration is complete, do you want to apply settings?"), type => "yesorno", }, @@ -1168,25 +1248,52 @@ It is not necessary on most networks."), my ($res) = @_; $netc->{at_boot} = $res; $res = bool2yesno($res); - substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } - $netc->{internet_cnx_choice} eq 'adsl' ? - "$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0" : - "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0"; + $ethntf->{ONBOOT} = $res if $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)); + my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}"; + -f $ifcfg_file and substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } $ifcfg_file; + return $after_start_on_boot_step->(); + }, + }, + + isdn_dial_on_boot => + { + pre => sub { + $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written + @isdn_dial_methods = ({ name => N("Automatically at boot"), + ONBOOT => 1, DIAL_ON_IFUP => 1 }, + { name => N("By using Net Applet in the system tray"), + ONBOOT => 0, DIAL_ON_IFUP => 1 }, + { name => N("Manually (the interface would still be activated at boot)"), + ONBOOT => 1, DIAL_ON_IFUP => 0 }); + my $method = find { + $_->{ONBOOT} eq text2bool($intf->{ippp0}{ONBOOT}) && + $_->{DIAL_ON_IFUP} eq text2bool($intf->{ippp0}{DIAL_ON_IFUP}) + } @isdn_dial_methods; + #- use net_applet by default + $isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name}; + }, + name => N("How do you want to dial this connection?"), + data => sub { + [ { type => "list", val => \$isdn->{dial_method}, list => [ map { $_->{name} } @isdn_dial_methods ] } ] + }, + post => sub { + my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods; + $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP); return $after_start_on_boot_step->(); }, }, restart => { - name => N("The network needs to be restarted. Do you want to restart it ?"), + name => N("The network needs to be restarted. Do you want to restart it?"), type => "yesorno", post => sub { my ($a) = @_; - network::ethernet::write_ether_conf($in, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan'; + network::ethernet::write_ether_conf($in, $modules_conf, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan'; if ($a && !$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) { $success = 0; $in->ask_okcancel(N("Network Configuration"), - N("A problem occured while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0); + N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0); } return $offer_to_connect->(); }, @@ -1203,7 +1310,7 @@ It is not necessary on most networks."), if ($a) { # local $::isWizard = 0; my $_w = $in->wait_message('', N("Testing your connection..."), 1); - connect_backend(); + connect_backend($netc); my $s = 30; $type =~ /modem/ and $s = 50; $type =~ /adsl/ and $s = 35; @@ -1226,7 +1333,7 @@ Try to reconfigure your connection."); no_back => 1, end => 1, post => sub { - $::isInstall and disconnect_backend(); + $::isInstall and disconnect_backend($netc); return "end"; }, }, @@ -1238,7 +1345,7 @@ Try to reconfigure your connection."); "), if_($::isStandalone && $in->isa('interactive::gtk'), N("After this is done, we recommend that you restart your X environment to avoid any hostname-related problems."))) : - N("Problems occured during configuration. + N("Problems occurred during configuration. Test your connection via net_monitor or mcc. If your connection doesn't work, you might want to relaunch the configuration."); }, end => 1, @@ -1256,13 +1363,7 @@ Click on Ok to keep your configuration, or cancel to reconfigure your Internet & "), 1) and do { $netcnx->{type} = 'lan'; - # should use write_cnx_file: - output_with_perm("$::prefix$network::tools::connect_file", 0755, qq(ifup eth0 -)); - output("$::prefix$network::tools::disconnect_file", 0755, qq( -ifdown eth0 -)); - $direct_net_install = 1; + $netc->{$_} = 'eth0' foreach qw(NET_DEVICE NET_INTERFACE); $use_wizard = 0; }; } @@ -1275,68 +1376,24 @@ ifdown eth0 mouse => $mouse, intf => $intf, }; - wizards->new->safe_process($wiz, $in); + wizards->new->process($wiz, $in); } # install needed packages: - $network_configured or network::network::configureNetwork2($in, $::prefix, $netc, $intf); - - my $connect_cmd; - if ($netcnx->{type} =~ /modem/ || $netcnx->{type} =~ /isdn_external/) { - $connect_cmd = qq( -#!/bin/bash -if [ -n "\$DISPLAY" ]; then - if [ -e /usr/bin/kppp ]; then - /sbin/route del default - /usr/bin/kppp & - else - /usr/sbin/net_monitor --connect - fi - else - $network::tools::connect_file -fi -); - } elsif ($netcnx->{type}) { - $connect_cmd = qq( -#!/bin/bash -if [ -n "\$DISPLAY" ]; then - /usr/sbin/net_monitor --connect -else - $network::tools::connect_file -fi -); - } else { - $connect_cmd = qq( -#!/bin/bash -/usr/sbin/drakconnect -); - } - if ($direct_net_install) { - $connect_cmd = qq( -#!/bin/bash -if [ -n "\$DISPLAY" ]; then - /usr/sbin/net_monitor --connect -else - $network::tools::connect_file -fi -); - } - output_with_perm("$::prefix$network::tools::connect_prog", 0755, $connect_cmd) if $connect_cmd; + $network_configured or network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf); + $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE); $netcnx->{type} =~ /adsl/ or run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null"); - - if ($::isInstall && $::o->{security} >= 3) { - require network::drakfirewall; - network::drakfirewall::main($in, $::o->{security} <= 3); - } } sub main { - my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; - eval { real_main('', , $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) }; + my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; + eval { real_main('', , $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) }; my $err = $@; if ($err) { # && $in->isa('interactive::gtk') - local $::isEmbedded = 0; # to prevent sub window embedding + $err =~ /wizcancel/ and $in->exit(0); + + local $::isEmbedded = 0; # to prevent sub window embedding local $::isWizard = 0 if !$::isInstall; # to prevent sub window embedding #err_dialog(N("Error"), N("An unexpected error has happened:\n%s", $err)); $in->ask_warn(N("Error"), N("An unexpected error has happened:\n%s", $err)); @@ -1373,14 +1430,6 @@ sub get_profiles() { map { if_(m!([^/]*)/$!, $1) } glob("$::prefix/etc/netprofile/profiles/*/"); } -sub load_conf { - my ($netcnx, $netc, $intf) = @_; - my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") }; - - $netcnx->{PROFILE} = $current->{PROFILE} || 'default'; - network::network::read_all_conf($::prefix, $netc, $intf, $netcnx); -} - sub get_net_device() { my $connect_file = $network::tools::connect_file; my $network_file = "$::prefix/etc/sysconfig/network"; @@ -1396,23 +1445,30 @@ sub get_net_device() { } sub read_net_conf { - my ($_prefix, $netcnx, $netc) = @_; - $netc->{$_} = $netcnx->{$_} foreach 'NET_DEVICE', 'NET_INTERFACE'; - $netcnx->{$netcnx->{type}} ||= {}; + my ($netcnx, $netc, $intf) = @_; + my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") }; + + $netcnx->{PROFILE} = $current->{PROFILE} || 'default'; + network::network::read_all_conf($::prefix, $netc, $intf, $netcnx); + + foreach ('NET_DEVICE', 'NET_INTERFACE') { + $netc->{$_} = $netcnx->{$_} if $netcnx->{$_} + } + $netcnx->{$netcnx->{type}} ||= {} if $netcnx->{type}; } sub start_internet { my ($o) = @_; init_globals($o); #- give a chance for module to be loaded using kernel-BOOT modules... - $::isStandalone or modules::load_category('network/main|gigabit|usb'); - run_program::rooted($::prefix, $network::tools::connect_file); + $::isStandalone or modules::load_category($o->{modules_conf}, 'network/*'); + connect_backend($o->{netc}); } sub stop_internet { my ($o) = @_; init_globals($o); - run_program::rooted($::prefix, $network::tools::disconnect_file); + disconnect_backend($o->{netc}); } 1; @@ -1431,7 +1487,7 @@ local $in = class_discard->new; network::netconnect::init_globals($in); my %i; -&network::netconnect::detect(\%i); +network::netconnect::detect($modules_conf, \%i); print Dumper(\%i),"\n"; =cut |
