diff options
Diffstat (limited to 'perl-install/network')
-rw-r--r-- | perl-install/network/adsl.pm | 289 | ||||
-rw-r--r-- | perl-install/network/adsl_consts.pm | 252 | ||||
-rw-r--r-- | perl-install/network/drakfirewall.pm | 202 | ||||
-rw-r--r-- | perl-install/network/ethernet.pm | 109 | ||||
-rw-r--r-- | perl-install/network/isdn.pm | 226 | ||||
-rw-r--r-- | perl-install/network/isdn_consts.pm | 339 | ||||
-rw-r--r-- | perl-install/network/modem.pm | 176 | ||||
-rw-r--r-- | perl-install/network/netconnect.pm | 1284 | ||||
-rw-r--r-- | perl-install/network/network.pm | 432 | ||||
-rw-r--r-- | perl-install/network/nfs.pm | 69 | ||||
-rw-r--r-- | perl-install/network/shorewall.pm | 164 | ||||
-rw-r--r-- | perl-install/network/smb.pm | 181 | ||||
-rw-r--r-- | perl-install/network/smbnfs.pm | 45 | ||||
-rw-r--r-- | perl-install/network/tools.pm | 226 |
14 files changed, 0 insertions, 3994 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm deleted file mode 100644 index 68ad935d8..000000000 --- a/perl-install/network/adsl.pm +++ /dev/null @@ -1,289 +0,0 @@ -package network::adsl; # $Id$ - -use common; -use run_program; -use network::tools; -use network::ethernet; -use modules; -use vars qw(@ISA @EXPORT); - -@ISA = qw(Exporter); -@EXPORT = qw(adsl_conf_backend); - - -sub get_wizard { - my ($wiz) = @_; - my $netc = $wiz->{var}{netc}; - - my %l = ( - 'pppoe' => N("use pppoe"), - 'pptp' => N("use pptp"), - 'dhcp' => N("use dhcp"), - 'speedtouch' => N("Alcatel speedtouch usb") . if_($netc->{autodetect}{adsl}{speedtouch}, N(" - detected")), - 'sagem' => N("Sagem (using pppoa) usb") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")), - 'sagem_dhcp' => N("Sagem (using dhcp) usb") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")), - # 'eci' => N("ECI Hi-Focus"), # this one needs eci agreement - ); - - $wiz->{var}{adsl} = { - connection_list => \%l, - type => "", - }; - add2hash($wiz->{pages}, - { - adsl_old => { - 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'"), - data => [ - { - label => N("ADSL connection type :"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] }, - ], - pre => sub { - $wiz->{var}{adsl}{type} = $l{sagem}; # debug - $wiz->{var}{adsl}{type} ||= find { $netc->{autodetect}{adsl}{$_} } keys %l; - print "\n\ntype is «$wiz->{var}{adsl}{type}»\n\n"; - }, - post => sub { - $wiz->{var}{adsl}{type} = find { $l{$_} eq $wiz->{var}{adsl}{type} } keys %l; - my $adsl = $wiz->{var}{adsl}{connection}; - my $type = $wiz->{var}{adsl}{type}; - my $netcnx = $wiz->{var}{netcnx}; - $netcnx->{type} = "adsl_$type"; - - $netcnx->{"adsl_$type"} = {}; - $netcnx->{"adsl_$type"}{vpivci} = '' if $type =~ /eci|speedtouch/; - return 'ethernet' if $type eq 'dhcp'; - adsl_probe_info($adsl, $netc, $type); - # my ($adsl, $netc, $intf, $adsl_type) = @_; - # ask_info2($adsl, $netc); - return "hw_account"; - }, - }, - }); -}; - -sub adsl_probe_info { - my ($adsl, $netc, $adsl_type, $adsl_modem) = @_; - my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf"; - my $pptp_file = "$::prefix/etc/sysconfig/network-scripts/net_cnx_up"; - my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type eq 'pppoe') && -f $pppoe_file; - my $login = $pppoe_conf{USER}; - foreach (qw(/etc/ppp/peers/adsl /etc/ppp/options /etc/ppp/options.adsl)) { - ($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$::prefix/$_") if !$login && -r "$::prefix/$_"; - } - ($login) = map { if_(/\sname\s+([^ \n]+)/, $1) } cat_($pptp_file) if (! defined $adsl_type || $adsl_type eq 'pptp') && -r $pptp_file; - my $passwd = passwd_by_login($login); - ($netc->{vpi}, $netc->{vci}) = - map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, $1, $2) } cat_("$::prefix/etc/ppp/peers/adsl") if member($adsl_modem, qw(eci speedtouch)); - $pppoe_conf{DNS1} ||= ''; - $pppoe_conf{DNS2} ||= ''; - add2hash($netc, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' }); - add2hash($adsl, { login => $login, passwd => $passwd, passwd2 => '' }); -} - -sub adsl_detect() { - my $adsl = {}; - require detect_devices; - ($adsl->{speedtouch}) = detect_devices::getSpeedtouch(); - ($adsl->{sagem}) = detect_devices::getSagem(); - ($adsl->{eci}) = detect_devices::getECI(); - return $adsl; -} - -sub adsl_conf_backend { - my ($in, $adsl, $netc, $adsl_device, $adsl_type, $o_netcnx) = @_; - # FIXME: should not be needed: - defined $o_netcnx and $netc->{adsltype} = $o_netcnx->{type}; - $netc->{adsltype} ||= "adsl_$adsl_type"; - - # all supported modems came with their own pppoa module, so no need for "plugin pppoatm.so" - my %modems = ( - speedtouch => - { - start => '/usr/sbin/modem_run -v 0 -f /usr/share/speedtouch/mgmt.o', - overide_script => 1, - server => { - pppoa => qq("/usr/sbin/pppoa3 -e 1 -c -vpi $netc->{vpi} -vci $netc->{vci}"), - }, - ppp_options => qq( -sync -noaccomp), - aliases => [ - ['speedtch', 'off'], # disable kernel driver, we use userland stuff but for firmware upload - ['char-major-108', 'ppp_generic'], - ['tty-ldisc-3', 'ppp_async'], - ['tty-ldisc-13', 'n_hdlc'], - ['tty-ldisc-14', 'ppp_synctty'], - ['ppp-compress-21', 'bsd_comp'], - ['ppp-compress-24', 'ppp_deflate'], - ['ppp-compress-26', 'ppp_deflate'] - ], - }, - sagem => - { - start => "/usr/sbin/eaglectrl -w", - get_intf => "/usr/sbin/eaglectrl -i", - server => { - pppoa => qq("/usr/sbin/pppoa -I `/usr/sbin/eaglectrl -s; /usr/sbin/eaglectrl -i`"), - }, - ppp_options => qq( -mru 1492 -mtu 1492 -nobsdcomp -nodeflate -noaccomp -am -novjccomp), - aliases => [ - ['char-major-108', 'ppp_generic'], - ['tty-ldisc-14', 'ppp_synctty'], - ['tty-ldisc-13', 'n_hdlc'] - ], - }, - eci => - { - start => '/usr/bin/startmodem', - server => { - pppoe => qq("/usr/bin/pppoeci -v 1 -vpi $netc->{vpi} -vci $netc->{vci}"), - }, - ppp_options => qq( -noipdefault -sync -noaccomp -linkname eciadsl -noauth -lcp-echo-interval 0) - }, - ); - - - if ($adsl_type =~ /^pp/) { - mkdir_p("$::prefix/etc/ppp"); - $in->do_pkgs->install('ppp') if !$>; - output("$::prefix/etc/ppp/options", - qq(lock -noipdefault -persist -noauth -usepeerdns -defaultroute) - ); - - output("$::prefix/etc/ppp/peers/adsl", -qq(noauth -noipdefault -pty $modems{$adsl_device}{server}{$adsl_type} -$modems{$adsl_device}{ppp_options} -kdebug 1 -nopcomp -noccp -novj -holdoff 4 -maxfail 25 -persist -usepeerdns -defaultroute -user "$adsl->{login}" -)); - - write_secret_backend($adsl->{login}, $adsl->{passwd}); - - if ($adsl_type eq 'pppoe') { - substInFile { - s/ETH=.*\n/ETH=$netc->{NET_DEVICE}\n/; - s/USER=.*\n/USER=$adsl->{login}\n/; - s/DNS1=.*\n/DNS1=$netc->{dnsServer2}\n/; - s/DNS2=.*\n/DNS2=$netc->{dnsServer3}\n/; - } "$::prefix/etc/ppp/pppoe.conf"; - } - - my %ppp_options = - ( - pptp => { - connect => "/usr/bin/pptp 10.0.0.138 name $adsl->{login}", - disconnect => "/usr/bin/killall pptp pppd\n", - }, - - pppoe => { - # we do not call directly pppd, rp-pppoe take care of "plugin rp-pppoe.so" peers option and the like - connect => "LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /usr/sbin/adsl-start $netc->{NET_DEVICE} $adsl->{login}", - disconnect => qq(/usr/sbin/adsl-stop -/usr/bin/killall pppoe pppd\n), - }, - - pppoa => { - disconnect => qq(/usr/sbin/adsl-stop -/usr/bin/killall pppoe pppd\n), - }, - ); - set_cnx_script($netc, "adsl", join("\n", - "/sbin/route del default", - $modems{$adsl_device}{start}, - # /usr/sbin/pppd call adsl - $modems{$adsl_device}{server}{$adsl_type} || "/usr/sbin/pppd file /etc/ppp/peers/adsl", - $ppp_options{$adsl_type}{connect} - ), - $ppp_options{$adsl_type}{disconnect}, - $netc->{adsltype} - ); - - } elsif ($adsl_type eq 'dhcp') { - set_cnx_script($netc, 'adsl', - qq( -/sbin/route del default -#$modems{$adsl_device}{start} -INTERFACE=`$modems{$adsl_device}{get_intf}` -/sbin/dhcpcd \$INTERFACE -#/sbin/ifconfig \$INTERFACE 192.168.60.30 netmask 255.255.255.0 up -/usr/sbin/pppd file /etc/ppp/peers/adsl\n), - qq( -INTERFACE=`$modems{$adsl_device}{get_intf}` -/sbin/ifdown \$INTERFACE\n"), - $netc->{adsltype}); - } elsif ($adsl_type eq 'static') { - # TODO: handle manually configured (new feature) - set_cnx_script($netc, 'adsl', - qq( -/sbin/route del default -#$modems{$adsl_device}{start} -INTERFACE=`$modems{$adsl_device}{get_intf}` -/sbin/ifconfig \$INTERFACE 192.168.60.30 netmask 255.255.255.0 up -/usr/sbin/pppd file /etc/ppp/peers/adsl\n), - qq( -INTERFACE=`$modems{$adsl_device}{get_intf}` -/sbin/ifdown \$INTERFACE\n"), - $netc->{adsltype}); - } - - - # sagem specific stuff - if ($adsl_device eq 'sagem') { - my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation); - # set vpi and vci parameters for sagem - substInFile { - s/VCI=.*\n/VCI=$l{vci}\n/; - s/VPI=.*\n/VPI=$l{vpi}\n/; - s/Encapsulation=.*\n/Encapsulation=$l{Encapsulation}\n/; - } "$::prefix/etc/analog/adiusbadsl.conf"; - } elsif ($adsl_device eq 'speedtouch') { - # speedtouch really is used only with pppoa, let its own script handle firmware upload and the like: - set_cnx_script($netc, 'adsl', - qq(/sbin/route del default -/usr/share/speedtouch/speedtouch.sh start\n), - "/usr/share/speedtouch/speedtouch.sh stop\n", - $netc->{adsltype}); - } - - - # set aliases: - if (exists $modems{$adsl_device}{modules}) { - modules::add_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{modules}}; - $::isStandalone and modules::write_conf(); - } - - $netc->{NET_INTERFACE} = 'ppp0'; - write_cnx_script($netc); -} - -1; diff --git a/perl-install/network/adsl_consts.pm b/perl-install/network/adsl_consts.pm deleted file mode 100644 index 2906be191..000000000 --- a/perl-install/network/adsl_consts.pm +++ /dev/null @@ -1,252 +0,0 @@ -package network::adsl_consts; # $Id$ - -# This should probably be splited out into ldetect-lst as some provider db - -use vars qw(@ISA @EXPORT); -use common; - -@ISA = qw(Exporter); -@EXPORT = qw(@adsl_data); - -# From: -# http://fast800.tuxfamily.org/pub/article.php3?id_article=23 -# http://baud123.blogdrive.com/archive/cm-10_cy-2003_m-10_d-1_y-2003_o-0.html -# http://www.sagem.com/web-modems/download/support-fast1000-fr.htm -# http://perso.wanadoo.fr/michel-m/protocolesfai.htm - -our %adsl_data = ( - # country|provider => { VPI, VCI_hexa, ... } - # dns are provided for when !usepeerdns in peers config file - N("Belgium") . "|Tiscali BE" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '212.35.2.1', - dnsServer3 => '212.35.2.2', - DOMAINNAME2 => 'tiscali.be', - }, - - N("Belgium") . "|Belgacom" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - }, - - N("France") . "|Free non dégroupé 512/128" => - { - vpi => 8, - vci => 23, - Encapsulation => 4, - dnsServer2 => '213.228.0.68', - dnsServer3 => '212.27.32.176', - method => 'pppoa', - DOMAINNAME2 => 'free.fr', - }, - - N("France") . "|Free dégroupé 1024/256 (mini)" => - { - vpi => 8, - vci => 24, - Encapsulation => 6, - dnsServer2 => '213.228.0.68', - dnsServer3 => '212.27.32.176', - DOMAINNAME2 => 'free.fr', - }, - - N("France") . "|9online 512" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '62.62.156.12', - dnsServer3 => '62.62.156.13', - method => 'pppoa', - }, - - N("France") . "|Club-Internet" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '194.117.200.10', - dnsServer3 => '194.117.200.15', - method => 'pppoa', - DOMAINNAME2 => 'club-internet.fr', - }, - - N("France") . "|Wanadoo" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '193.252.19.3', - dnsServer3 => '193.252.19.4', - method => 'pppoa', - DOMAINNAME2 => 'wanadoo.fr', - }, - - N("France") . "|Télé2 128k " => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '212.151.136.242', - dnsServer3 => '130.244.127.162', - method => 'pppoa', - }, - - N("France") . "|Tiscali.fr 128k" => - { - vpi => 8, - vci => 23, - Encapsulation => 5, - dnsServer2 => '213.36.80.1', - dnsServer3 => '213.36.80.2', - method => 'pppoa', - }, - - N("France") . "|Tiscali.fr 512k" => - { - vpi => 8, - vci => 23, - dnsServer2 => '213.36.80.1', - dnsServer3 => '213.36.80.2', - method => 'pppoa', - }, - - N("Finland") . "|Sonera" => - { - vpi => 0, - vci => 64, - Encapsulation => 1, - }, - - N("Germany") . "|Deutsche Telekom (DT)" => - { - vpi => 1, - vci => 20, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Germany") . "|1&1" => - { - vpi => 1, - vci => 20, - Encapsulation => 1, - dnsServer2 => '195.20.224.234', - dnsServer3 => '194.25.2.129', - method => 'pppoe', - }, - - N("Hungary") . "|Matav" => - { - vpi => 1, - vci => 20, - }, - - N("Italy") . "|Telecom Italia" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '195.20.224.234', - dnsServer3 => '194.25.2.129', - method => 'pppoa', - }, - - N("Italy") . "|Tiscali.it" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '195.20.224.234', - dnsServer3 => '194.25.2.129', - method => 'pppoa', - }, - - N("Netherlands") . "|KPN" => - { - vpi => 8, - vci => 30, - Encapsulation => 6, - }, - - N("Poland") . "|Telekomunikacja Polska (TPSA/neostrada)" => - { - vpi => 0, - vci => 23, - Encapsulation => 6, - dnsServer2 => '194.204.152.34', - dnsServer3 => '217.98.63.164', - method => 'pppoa', - }, - - N("Portugal") . "|PT" => - { - vpi => 0, - vci => 23, - }, - - N("Spain") . "|Retevision " => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - }, - - N("Spain") . "|Telefónica IP dinámica" => - { - vpi => 8, - vci => 20, - Encapsulation => 1, - dnsServer2 => '80.58.32.33', - dnsServer3 => '80.58.0.97', - method => 'pppoe', - }, - N("Spain") . "|Telefonica ip fija" => - { - vpi => 8, - vci => 20, - Encapsulation => 3, - protocol => 'static', - dnsServer2 => '80.58.32.33', - dnsServer3 => '80.58.0.97', - method => 'static', - }, - - N("Spain") . "|Wanadoo/Eresmas" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '80.58.0.33', - dnsServer3 => '80.58.32.97', - method => 'pppoa', - }, - - N("Sweden") . "|Telia" => - { - vpi => 8, - vci => 23, - Encapsulation => 1, - }, - - N("United Kingdom") . "|Tiscali UK " => - { - vpi => 0, - vci => 26, - Encapsulation => 6, - }, - - N("United Kingdom") . "|British Telecom " => - { - vpi => 0, - vci => 26, - Encapsulation => 6, - }, - ); - -1; diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm deleted file mode 100644 index fb8647a44..000000000 --- a/perl-install/network/drakfirewall.pm +++ /dev/null @@ -1,202 +0,0 @@ -package network::drakfirewall; # $Id$ - -use strict; -use diagnostics; - -use network::shorewall; -use common; - -my @all_servers = -( - { - name => N_("Web Server"), - pkg => 'apache apache-mod_perl boa', - ports => '80/tcp 443/tcp', - }, - { - name => N_("Domain Name Server"), - pkg => 'bind', - ports => '53/tcp 53/udp', - }, - { - name => N_("SSH server"), - pkg => 'openssh-server', - ports => '22/tcp', - }, - { - name => N_("FTP server"), - pkg => 'ftp-server-krb5 wu-ftpd proftpd pure-ftpd', - ports => '20/tcp 21/tcp', - }, - { - name => N_("Mail Server"), - pkg => 'sendmail postfix qmail', - ports => '25/tcp', - }, - { - name => N_("POP and IMAP Server"), - pkg => 'imap courier-imap-pop', - ports => '109/tcp 110/tcp 143/tcp', - }, - { - name => N_("Telnet server"), - pkg => 'telnet-server-krb5', - ports => '23/tcp', - hide => 1, - }, - { - name => N_("Samba server"), - pkg => 'samba-server', - ports => '137/tcp 137/udp 138/tcp 138/udp 139/tcp 139/udp ', - hide => 1, - }, - { - name => N_("CUPS server"), - pkg => 'cups', - ports => '631/tcp 631/udp', - hide => 1, - }, - { - name => N_("Echo request (ping)"), - ports => '8/icmp', - force_default_selection => 0, - }, -); - -sub port2server { - my ($port) = @_; - find { - any { $port eq $_ } split(' ', $_->{ports}); - } @all_servers; -} - -sub check_ports_syntax { - my ($ports) = @_; - foreach (split ' ', $ports) { - my ($nb, $range, $nb2) = m!^(\d+)(:(\d+))?/(tcp|udp|icmp)$! or return $_; - foreach my $port ($nb, if_($range, $nb2)) { - 1 <= $port && $port <= 65535 or return $_; - } - $nb < $nb2 or return $_ if $range; - } - ''; -} - -sub to_ports { - my ($servers, $unlisted) = @_; - my $ports = join(' ', (map { $_->{ports} } @$servers), if_($unlisted, $unlisted)); - \$ports; -} - -sub from_ports { - my ($ports) = @_; - - my @l; - my @unlisted; - foreach (split ' ', $$ports) { - if (my $s = port2server($_)) { - push @l, $s; - } else { - push @unlisted, $_; - } - } - [ uniq(@l) ], join(' ', @unlisted); -} - -sub default_from_pkgs { - my ($in) = @_; - my @pkgs = $in->do_pkgs->are_installed(map { split ' ', $_->{pkg} } @all_servers); - [ grep { - my $s = $_; - exists $s->{force_default_selection} ? - $s->{force_default_selection} : - any { member($_, @pkgs) } split(' ', $s->{pkg}); - } @all_servers ]; -} - -sub get_ports { - my ($in, $_ports) = @_; - my $shorewall = network::shorewall::read($in, 'silent') or return; - \$shorewall->{ports}; -} - -sub set_ports { - my ($in, $disabled, $ports) = @_; - my $shorewall = network::shorewall::read($in, 'not_silent') || network::shorewall::default_interfaces($in) or die \N("No network card"); - if (!$disabled || -x "$::prefix/sbin/shorewall") { - $in->do_pkgs->ensure_is_installed('shorewall', '/sbin/shorewall', $::isInstall) or return; - - $shorewall->{disabled} = $disabled; - $shorewall->{ports} = $$ports; - network::shorewall::write($shorewall); - } -} - -sub get_conf { - my ($in, $disabled, $o_ports) = @_; - - my $possible_servers = default_from_pkgs($in); - $_->{hide} = 0 foreach @$possible_servers; - - if ($o_ports) { - $disabled, from_ports($o_ports); - } elsif (my $shorewall = network::shorewall::read($in, 'silent')) { - $shorewall->{disabled}, from_ports(\$shorewall->{ports}); - } else { - $in->ask_okcancel('', N("drakfirewall configurator - -This configures a personal firewall for this Mandrake Linux machine. -For a powerful and dedicated firewall solution, please look to the -specialized MandrakeSecurity Firewall distribution."), 1) or return; - - $in->ask_okcancel('', N("drakfirewall configurator - -Make sure you have configured your Network/Internet access with -drakconnect before going any further."), 1) or return; - - $disabled, $possible_servers, ''; - } -} - -sub choose { - my ($in, $disabled, $servers, $unlisted) = @_; - - $_->{on} = 0 foreach @all_servers; - $_->{on} = 1 foreach @$servers; - my @l = grep { $_->{on} || !$_->{hide} } @all_servers; - - $in->ask_from_({ - messages => N("Which services would you like to allow the Internet to connect to?"), - advanced_messages => N("You can enter miscellaneous ports. -Valid examples are: 139/tcp 139/udp. -Have a look at /etc/services for information."), - callbacks => { - complete => sub { - if (my $invalid_port = check_ports_syntax($unlisted)) { - $in->ask_warn('', N("Invalid port given: %s. -The proper format is \"port/tcp\" or \"port/udp\", -where port is between 1 and 65535. - -You can also give a range of ports (eg: 24300:24350/udp)", $invalid_port)); - return 1; - } - }, - } }, - [ - { text => N("Everything (no firewall)"), val => \$disabled, type => 'bool' }, - (map { { text => translate($_->{name}), val => \$_->{on}, type => 'bool', disabled => sub { $disabled } } } @l), - { label => N("Other ports"), val => \$unlisted, advanced => 1, disabled => sub { $disabled } } - ]) or return; - - $disabled, to_ports([ grep { $_->{on} } @l ], $unlisted); -} - -sub main { - my ($in, $disabled) = @_; - - ($disabled, my $servers, my $unlisted) = get_conf($in, $disabled) or return; - - ($disabled, my $ports) = choose($in, $disabled, $servers, $unlisted) or return; - - set_ports($in, $disabled, $ports); -} diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm deleted file mode 100644 index 5ac1a3110..000000000 --- a/perl-install/network/ethernet.pm +++ /dev/null @@ -1,109 +0,0 @@ -package network::ethernet; # $Id$ - -use c; -use network::network; -use modules; -use modules::interactive; -use detect_devices; -use common; -use run_program; -use network::tools; -use vars qw(@ISA @EXPORT); - -@ISA = qw(Exporter); -@EXPORT = qw(conf_network_card_backend); - -# FIXME: unused code to merge in into wizard -sub ether_conf { - my ($in, $netcnx, $netc, $intf) = @_; - configureNetwork2($in, $::prefix, $netc, $intf); - $netc->{NETWORKING} = "yes"; - if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) { - $netcnx->{type} = 'lan'; - $netcnx->{NET_DEVICE} = $netc->{NET_DEVICE} = ''; - $netcnx->{NET_INTERFACE} = 'lan'; #$netc->{NET_INTERFACE}; - set_cnx_script($netc, "local network", -qq( -/etc/rc.d/init.d/network restart -), -qq( -/etc/rc.d/init.d/network stop -/sbin/ifup lo -), $netcnx->{type}); - } - $::isStandalone and modules::write_conf(); - 1; -} - - -sub mapIntfToDevice { - my ($interface) = @_; - my ($bus, $slot, $_func) = map { hex($_) } (c::getHwIDs($interface) =~ /([0-9a-f])+:([0-9a-f])+\.([0-9a-f]+)/); - grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot } detect_devices::probeall(); -} - - -# return list of [ intf_name, module, device_description ] tuples such as: -# [ "eth0", "3c59x", "3Com Corporation|3c905C-TX [Fast Etherlink]" ] -sub get_eth_cards() { - my @all_cards = detect_devices::getNet(); - - my @devs = detect_devices::pcmcia_probe(); - modules::mergein_conf("$::prefix/etc/modules.conf"); - my $saved_driver; - return map { - my $interface = $_; - my $a = c::getNetDriver($interface) || modules::get_alias($interface); - my $b = find { $_->{device} eq $interface } @devs; - $a ||= $b->{driver}; - $a and $saved_driver = $a; # handle multiple cards managed by the same driver - my ($device) = mapIntfToDevice($interface); - [ $interface, $saved_driver, if_($device, $device->{description}) ] - } @all_cards; -} - - -#- conf_network_card_backend : configure the network cards and return the list of them, or configure one specified interface : WARNING, you have to setup the ethernet cards, by calling load_category($in, 'network/main|gigabit|usb', !$::expert, 1) or load_category_backend before calling this function. Basically, you call this function in 2 times. -#- input -#- $prefix -#- $netc -#- $intf -#- $type : type of interface, must be given if $interface is : string : "static" or "dhcp" -#- $interface : facultative, if given, set this interface and return it in a proper form. If not, return @all_cards -#- $ipadr : facultative, ip address of the interface : string -#- $netadr : facultative, netaddress of the interface : string -#- when $interface is given, informations are written in $intf and $netc. If not, @all_cards is returned. -#- $intf output: $device is the result of -#- $intf->{$device}->{DEVICE} : which device is concerned : $device is the result of $interface =~ /(eth[0-9]+)/; my $device = $1;; -#- $intf->{$device}->{BOOTPROTO} : $type -#- $intf->{$device}->{NETMASK} : '255.255.255.0' -#- $intf->{$device}->{NETWORK} : $netadr -#- $intf->{$device}->{ONBOOT} : "yes" -#- $netc output: -#- $netc->{NET_DEVICE} : this is used to indicate that this eth card is used to connect to internet : $device -#- output: -#- $device : only returned in case $interface was given it's $interface, but filtered by /eth[0-9+]/ : string : /eth[0-9+]/ -sub conf_network_card_backend { - my ($netc, $intf, $type, $interface, $o_ipadr, $o_netadr) = @_; - #-type =static or dhcp - - $interface =~ /eth[0-9]+/ or die("the interface is not an ethx"); - - # FIXME: this is wrong regarding some wireless interfaces or/and if user play if ifname(1): - $netc->{NET_DEVICE} = $interface; #- one consider that there is only ONE Internet connection device.. - - @{$intf->{$interface}}{qw(DEVICE BOOTPROTO NETMASK NETWORK ONBOOT)} = ($interface, $type, '255.255.255.0', $o_netadr, 'yes'); - - $intf->{$interface}{IPADDR} = $o_ipadr if $o_ipadr; - $interface; -} - -# automatic net aliases configuration -sub configure_eth_aliases() { - foreach (detect_devices::getNet()) { - my $driver = c::getNetDriver($_) or next; - modules::add_alias($_, $driver); - } -} - -1; diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm deleted file mode 100644 index 153233b58..000000000 --- a/perl-install/network/isdn.pm +++ /dev/null @@ -1,226 +0,0 @@ -package network::isdn; # $Id$ - -use strict; -use network::isdn_consts; -use common; -use any; -use modules; -use run_program; -use log; -use network::tools; -use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in); -use MDK::Common::File; - - -@ISA = qw(Exporter); -@EXPORT = qw(isdn_write_config isdn_write_config_backend get_info_providers_backend isdn_ask_info isdn_ask_protocol isdn_ask isdn_detect_backend isdn_get_list isdn_get_info); - - -sub isdn_write_config { - my ($isdn, $netc) = @_; - $in->do_pkgs->install('isdn4net', if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils'); - isdn_write_config_backend($isdn, $netc); - 1; -} - -sub isdn_write_config_backend { - my ($isdn, $netc, $o_netcnx) = @_; - defined $o_netcnx and $netc->{isdntype} = $o_netcnx->{type}; - - output_with_perm("$::prefix/etc/isdn/profile/link/myisp", 0600, - qq( -I4L_USERNAME="$isdn->{login}" -I4L_SYSNAME="" -I4L_LOCALMSN="$isdn->{phone_in}" -I4L_REMOTE_OUT="$isdn->{phone_out}" -I4L_DIALMODE="$isdn->{dialing_mode}" -) . if_($isdn->{speed} =~ /128/, 'SLAVE="ippp1" -')); - output "$::prefix/etc/isdn/profile/card/mycard", - qq( -I4L_MODULE="$isdn->{driver}" -I4L_TYPE="$isdn->{type}" -I4L_IRQ="$isdn->{irq}" -I4L_MEMBASE="$isdn->{mem}" -I4L_PORT="$isdn->{io}" -I4L_IO0="$isdn->{io0}" -I4L_IO1="$isdn->{io1}" -I4L_ID="HiSax" -I4L_FIRMWARE="$isdn->{firmware}" -); - - output "$::prefix/etc/ppp/ioptions", - "lock -usepeerdns -defaultroute -"; - system "$::prefix/etc/rc.d/init.d/isdn4linux restart"; - - substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0"; - - # we start the virtual interface at boot (we dial only on demand. - substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=yes\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp$isdn->{intf_id}"; - - write_secret_backend($isdn->{login}, $isdn->{passwd}); - - set_cnx_script($netc, "isdn", -"#/sbin/route del default -#/sbin/ifup ippp0 -/usr/sbin/isdnctrl dial ippp0 -" . if_($isdn->{speed} =~ /128/, "service ibod restart -"), -"/usr/sbin/isdnctrl hangup ippp0 -#/sbin/ifdown ippp0 -" . if_($isdn->{speed} =~ /128/, "service ibod stop -"), $netc->{isdntype}); - 1; -} - -sub isdn_read_config { - my ($isdn) = @_; - - my %match = (I4L_USERNAME => 'login', - I4L_LOCALMSN => 'phone_in', - I4L_REMOTE_OUT => 'phone_out', - I4L_DIALMODE => 'dialing_mode', - I4L_MODULE => 'driver', - I4L_TYPE => 'type', - I4L_IRQ => 'irq', - I4L_MEMBASE => 'mem', - I4L_PORT => 'io', - I4L_IO0 => 'io0', - I4L_IO1 => 'io1', - I4L_FIRMWARE => 'firmware'); - foreach ('link/myisp', 'card/mycard') { - my %conf = getVarsFromSh("$::prefix/etc/isdn/profile/$_"); - foreach (keys %conf) { - $isdn->{$match{$_}} = $conf{$_} if $match{$_}; - } - } - - $isdn->{passwd} = network::tools::passwd_by_login($isdn->{login}); - #$isdn->{description} = ''; - #$isdn->{vendor} = ''; - #$isdn->{passwd2} = ''; - $isdn; -} - -sub get_info_providers_backend { - my ($isdn, $_netc, $name, $file) = @_; - $name eq 'Unlisted - edit manually' and return; - foreach (catMaybeCompressed($file)) { - chop; - my ($name_, $phone, $real, $dns1, $dns2) = split '=>'; - if ($name eq $name_) { - @$isdn{qw(user_name phone_out DOMAINNAME2 dnsServer3 dnsServer2)} = - ((split(/\|/, $name_))[2], $phone, $real, $dns1, $dns2); - } - } -} - -sub isdn_ask_info { - my ($isdn, $netc) = @_; - my $f = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db"; - $f = "$::prefix$f" if !-e $f; - isdn_ask_info_step1: - my $str = $in->ask_from_treelist(N("ISDN Configuration"), N("Select your provider.\nIf it isn't listed, choose Unlisted."), - '|', ['Unlisted - edit manually', - read_providers_backend($f)], 'Unlisted - edit manually') - or return; - get_info_providers_backend($isdn, $netc, $str || 'Unlisted - edit manually', $f); - $isdn->{huptimeout} = 180; - $isdn->{$_} ||= '' foreach qw(phone_in phone_out dialing_mode login passwd passwd2 idl speed); - add2hash($netc, { dnsServer2 => '', dnsServer3 => '', DOMAINNAME2 => '' }); - ask_info2($isdn, $netc) or goto isdn_ask_info_step1; -} - -sub isdn_ask_protocol() { - my @toto = ( - { description => $::expert ? N("European protocol (EDSS1)") : N("European protocol"), - protokol => 2 }, - { description => $::expert ? N("Protocol for the rest of the world\nNo D-Channel (leased lines)") : N("Protocol for the rest of the world"), - protokol => 3 } - ); - my $e = $in->ask_from_listf(N("ISDN Configuration"), - N("Which protocol do you want to use?"), - sub { $_[0]{description} }, - \@toto) or return 0; - $e->{protokol}; -} - -sub isdn_ask { - my ($isdn, $netc, $label) = @_; - - #- ISDN card already detected - if (!$::expert && defined $netc->{autodetect}{isdn}{card_type}) { - $in->ask_yesorno(N("ISDN Configuration"), N("Found \"%s\" interface do you want to use it ?", $netc->{autodetect}{isdn}{description}), 1) or return; - $isdn->{$_} = $netc->{autodetect}{isdn}{$_} foreach qw(description vendor id card_type driver type mem io io0 io1 irq firmware); - goto isdn_ask_step_3; - } - - isdn_ask_step_1: - my $e = $in->ask_from_list_(N("ISDN Configuration"), - $label . "\n" . N("What kind of card do you have?"), - [ N_("ISA / PCMCIA"), N_("PCI"), N_("USB"), N_("I don't know") ] - ) or return; - isdn_ask_step_1b: - if ($e =~ /PCI/) { - $isdn->{card_type} = 'pci'; - } elsif ($e =~ /USB/) { - $isdn->{card_type} = 'usb'; - } else { - $in->ask_from_list_(N("ISDN Configuration"), - N(" -If you have an ISA card, the values on the next screen should be right.\n -If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card. -"), - [ N_("Continue"), N_("Abort") ]) eq 'Continue' or goto isdn_ask_step_1; - $isdn->{card_type} = 'isa'; - } - - isdn_ask_step_2: - $e = $in->ask_from_listf(N("ISDN Configuration"), - N("Which of the following is your ISDN card?"), - sub { $_[0]{description} }, - [ grep { $_->{card} eq $isdn->{card_type} } @isdndata ]) or goto($isdn->{card_type} =~ /usb|pci/ ? 'isdn_ask_step_1' : 'isdn_ask_step_1b'); - $e->{$_} and $isdn->{$_} = $e->{$_} foreach qw(driver type mem io io0 io1 irq firmware); - - isdn_ask_step_3: - $isdn->{protocol} = isdn_ask_protocol() or goto isdn_ask_step_2; - isdn_ask_step_4: - isdn_ask_info($isdn, $netc) or goto isdn_ask_step_3; - isdn_write_config($isdn, $netc) or goto isdn_ask_step_4; - 1; -} - -sub isdn_detect_backend() { - my $isdn = { }; - each_index { - my $c = $_; - $isdn->{$::i} = { map { $_ => $c->{$_} } qw(description vendor id driver card_type type) }; - my $isdn = $isdn->{$::i}; - $isdn->{intf_id} = $::i; - $isdn->{$_} = sprintf("%0x", $isdn->{$_}) foreach 'vendor', 'id'; - $isdn->{card_type} = $c->{bus} eq 'USB' ? 'usb' : 'pci'; - ($isdn->{type}) = $isdn->{options} =~ /type=(\d+)/; - $isdn->{description} =~ s/.*\|//; -# $c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax"; - if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) { - modules::set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol}); - } - $c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1; - } modules::probe_category('network/isdn'); - $isdn; -} - -sub isdn_get_list() { - map { $_->{description} } @isdndata; -} - -sub isdn_get_info { - my ($desc) = @_; - find { $_->{description} eq $desc } @isdndata; -} - -1; diff --git a/perl-install/network/isdn_consts.pm b/perl-install/network/isdn_consts.pm deleted file mode 100644 index c38297641..000000000 --- a/perl-install/network/isdn_consts.pm +++ /dev/null @@ -1,339 +0,0 @@ -package network::isdn_consts; # $Id$ -use vars qw(@ISA @EXPORT); -@ISA = qw(Exporter); -@EXPORT = qw(@isdndata); - -our @isdndata = - ( - { description => "Teles 16.0 (ISA)", #1 irq, mem, io - driver => 'hisax', - type => '1', - irq => '5', - mem => '0xd000', - io => '0xd80', - card => 'isa', - }, - { description => "Teles 8.0 (ISA)", #2 irq, mem - driver => 'hisax', - type => '2', - irq => '9', - mem => '0xd800', - card => 'isa', - }, - { description => "Teles 16.3 (ISA non PnP)", #3 irq, io - driver => 'hisax', - type => '3', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Teles 16.3c (ISA PnP)", #14 irq, io - driver => 'hisax', - type => '14', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Creatix/Teles (ISA PnP)", #4 irq, io0 (ISAC), io1 (HSCX) - driver => 'hisax', - type => '4', - irq => '5', - io0 => '0x0000', - io1 => '0x0000', - card => 'isa', - }, - { description => "Teles generic (PCI)", #21 no parameter - driver => 'hisax', - type => '21', - card => 'pci', - }, - { description => "Teles 16.3 (PCMCIA)", #8 irq, io - driver => 'hisax', - type => '8', - irq => '', - io => '0x', - card => 'isa', - }, - { description => "Teles S0Box", #25 irq, io (of the used lpt port) - driver => 'hisax', - type => '25', - irq => '7', - io => '0x378', - card => 'isa', - }, - { description => "ELSA PCC/PCF cards (ISA)", #6 io or nothing for autodetect (the io is required only if you have n>1 ELSA card) - driver => 'hisax', - type => '6', - io => "", - card => 'isa', - }, - { description => "ELSA Quickstep 1000 (ISA)", #7 irq, io (from isapnp setup) - driver => 'hisax', - type => '7', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "ELSA Quickstep 1000 (PCI)", #18 no parameter - driver => 'hisax', - type => '18', - card => 'pci', - }, - { description => "ELSA Quickstep 3000 (PCI)", #18 no parameter - driver => 'hisax', - type => '18', - card => 'pci', - }, - { description => "ELSA generic (PCMCIA)", #10 irq, io (set with card manager) - driver => 'hisax', - type => '10', - irq => '', - io => '0x', - card => 'isa', - }, - { description => "ELSA MicroLink (PCMCIA)", #10 irq, io (set with card manager) - driver => 'elsa_cs', - card => 'isa', - }, - { description => "ITK ix1-micro Rev.2 (ISA)", #9 irq, io - driver => 'hisax', - type => '9', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Eicon.Diehl Diva (ISA PnP)", #11 irq, io - driver => 'hisax', - type => '11', - irq => '9', - io => '0x180', - card => 'isa', - }, - { description => "Eicon.Diehl Diva 20 (PCI)", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl Diva 20PRO (PCI)", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl Diva 20_U (PCI)", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl Diva 20PRO_U (PCI)", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "ASUS COM ISDNLink (ISA)", #12 irq, io (from isapnp setup) - driver => 'hisax', - type => '12', - irq => '5', - io => '0x200', - card => 'isa', - }, - { description => "ASUS COM ISDNLink (PCI)", - driver => 'hisax', - type => '35', - card => 'pci', - }, - { description => "DynaLink (PCI)", - driver => 'hisax', - type => '12', - card => 'pci', - }, - { description => "DynaLink IS64PH, ASUSCOM (PCI)", #36 - driver => 'hisax', - type => '36', - card => 'pci', - }, - { description => "HFC-2BS0 based cards (ISA)", #13 irq, io - driver => 'hisax', - type => '13', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "HFC 2BDS0 (PCI)", #35 none - driver => 'hisax', - type => '35', - card => 'pci', - }, - { description => "HFC 2BDS0 S+, SP (PCMCIA)", #37 irq,io (pcmcia must be set with cardmgr) - driver => 'hisax', - type => '37', - card => 'isa', - }, - { description => "Sedlbauer Speed Card (ISA)", #15 irq, io - driver => 'hisax', - type => '15', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Sedlbauer PC/104 (ISA)", #15 irq, io - driver => 'hisax', - type => '15', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Sedlbauer Speed Card (PCI)", #15 no parameter - driver => 'hisax', - type => '15', - card => 'pci', - }, - { description => "Sedlbauer Speed Star (PCMCIA)", #22 irq, io (set with card manager) - driver => 'sedlbauer_cs', - card => 'isa', - }, - { description => "Sedlbauer Speed Fax+ (ISA Pnp)", #28 irq, io (from isapnp setup) - driver => 'hisax', - type => '28', - irq => '9', - io => '0xd80', - card => 'isa', - firmware => '/usr/lib/isdn/ISAR.BIN', - }, - { description => "Sedlbauer Speed Fax+ (PCI)", #28 no parameter - driver => 'hisax', - type => '28', - card => 'pci', - firmware => '/usr/lib/isdn/ISAR.BIN', - }, - { description => "USR Sportster internal (ISA)", #16 irq, io - driver => 'hisax', - type => '16', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "MIC card (ISA)", #17 irq, io - driver => 'hisax', - type => '17', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Compaq ISDN S0 card (ISA)", #19 irq, io0, io1, io (from isapnp setup io=IO2) - driver => 'hisax', - type => '19', - irq => '5', - io => '0x0000', - io0 => '0x0000', - io1 => '0x0000', - card => 'isa', - }, - { description => "NETjet card (PCI)", #20 no parameter - driver => 'hisax', - type => '20', - card => 'pci', - }, - { description => "Dr. Neuhaus Niccy (ISA PnP)", #24 irq, io0, io1 (from isapnp setup) - driver => 'hisax', - type => '24', - irq => '5', - io0 => '0x0000', - io1 => '0x0000', - card => 'isa', - }, - { description => "Dr. Neuhaus Niccy (PCI)", ##24 no parameter - driver => 'hisax', - type => '24', - card => 'pci', - }, - { description => "AVM A1 (Fritz) (ISA non PnP)", #5 irq, io - driver => 'hisax', - type => '5', - irq => '10', - io => '0x300', - card => 'isa', - }, - { description => "AVM (ISA Pnp)", #27 irq, io (from isapnp setup) - driver => 'hisax', - type => '27', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "AVM A1 (Fritz) (PCMCIA)", #26 irq, io (set with card manager) - driver => 'hisax', - type => '26', - irq => '', - card => 'isa', - }, - { description => "AVM PCI (Fritz!) (PCI)", #27 no parameter - driver => 'hisax', - type => '27', - card => 'pci', - }, - { description => "AVM B1 (PCI)", - driver => 'b1pci', - card => 'pci', - }, - { description => "Siemens I-Surf 1.0 (ISA Pnp)", #29 irq, io, memory (from isapnp setup) - driver => 'hisax', - type => '29', - irq => '9', - io => '0xd80', - mem => '0xd000', - card => 'isa', - }, - { description => "ACER P10 (ISA Pnp)", #30 irq, io (from isapnp setup) - driver => 'hisax', - type => '30', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "HST Saphir (ISA Pnp)", #31 irq, io - driver => 'hisax', - type => '31', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "Telekom A4T (PCI)", #32 none - driver => 'hisax', - type => '32', - card => 'pci', - }, - { description => "Scitel Quadro (PCI)", #33 subcontroller (4*S0, subctrl 1...4) - driver => 'hisax', - type => '33', - card => 'pci', - }, - { description => "Gazel ISDN cards (ISA)", #34 irq,io - driver => 'hisax', - type => '34', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "Gazel ISDN cards (PCI)", #34 none - driver => 'hisax', - type => '34', - card => 'pci', - }, - { description => "W6692 and Winbond based cards (PCI)", #36 none - driver => 'hisax', - type => '36', - card => 'pci', - }, - { description => "BeWAN R834 (USB)", - driver => 'hisax_st5481', - type => '99', - card => 'usb', - }, - { description => "Gazel 128 (USB)", - driver => 'hisax_st5481', - type => '99', - card => 'usb', - }, - ); - -1; diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm deleted file mode 100644 index dbeefe318..000000000 --- a/perl-install/network/modem.pm +++ /dev/null @@ -1,176 +0,0 @@ -package network::modem; # $Id$ - -use strict; -use common; -use any; -use modules; -use detect_devices; -use mouse; -use network::tools; - - -#-----modem conf -sub ppp_configure { - my ($in, $modem) = @_; - $modem or return; - $in->do_pkgs->install('ppp') if !$::testing; - $in->do_pkgs->install('kdenetwork-kppp') if !$::testing &&$in->do_pkgs->is_installed('kdebase'); - - any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem"; - - my %toreplace = map { $_ => $modem->{$_} } qw(Authentication AutoName connection dns1 dns2 domain IPAddr login passwd phone SubnetMask); - $toreplace{phone} =~ s/[a-zA-Z]//g; - if ($modem->{auto_dns} ne N("Automatic")) { - $toreplace{dnsserver} = join ',', map { $modem->{$_} } "dns1", "dns2"; - $toreplace{dnsserver} .= $toreplace{dnsserver} && ','; - } - - #- using peerdns or dns1,dns2 avoid writing a /etc/resolv.conf file. - $toreplace{peerdns} = "yes"; - - $toreplace{connection} ||= 'DialupConnection'; - $toreplace{domain} ||= 'localdomain'; - $toreplace{intf} ||= 'ppp0'; - $toreplace{papname} = $toreplace{login} if member($modem->{Authentication}, 1, 3, 4); - - # handle static/dynamic settings: - if ($modem->{auto_ip} eq N("Automatic")) { - $toreplace{$_} = '0.0.0.0' foreach qw(IPAddr SubnetMask) ; - } else { - $toreplace{$_} = $modem->{$_} foreach qw(IPAddr SubnetMask) ; - } - $toreplace{Gateway} = $modem->{auto_gateway} eq N("Automatic") ? '0.0.0.0' : $modem->{Gateway}; - - - #- build ifcfg-ppp0. - my $various = <<END; -DEVICE="$toreplace{intf}" -ONBOOT="no" -USERCTL="no" -MODEMPORT="/dev/modem" -LINESPEED="115200" -PERSIST="yes" -DEFABORT="yes" -DEBUG="yes" -INITSTRING="ATZ" -DEFROUTE="yes" -HARDFLOWCTL="yes" -ESCAPECHARS="no" -PPPOPTIONS="" -PAPNAME="$toreplace{papname}" -REMIP="" -NETMASK="" -IPADDR="" -MRU="" -MTU="" -DISCONNECTTIMEOUT="5" -RETRYTIMEOUT="60" -BOOTPROTO="none" -PEERDNS="$toreplace{peerdns}" -END - output("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0", - $various, - if_($modem->{auto_dns} ne N("Automatic"), map { qq(DNS$_=$toreplace{"dns$_"}\n) } grep { $toreplace{"dns$_"} } 1..2)); - - #- build chat-ppp0. - my @chat = <<END; -'ABORT' 'BUSY' -'ABORT' 'ERROR' -'ABORT' 'NO CARRIER' -'ABORT' 'NO DIALTONE' -'ABORT' 'Invalid Login' -'ABORT' 'Login incorrect' -'' 'ATZ' -END - if ($modem->{special_command}) { - push @chat, <<END; -'OK' '$modem->{special_command}' -END - } - push @chat, <<END; -'OK' 'ATDT$toreplace{phone}' -'CONNECT' '' -END - if (member($modem->{Authentication}, 0, 2)) { - push @chat, <<END; -'ogin:--ogin:' '$toreplace{login}' -'ord:' '$toreplace{passwd}' -END - } - push @chat, <<END; -'TIMEOUT' '5' -'~--' '' -END - my $chat_file = "$::prefix/etc/sysconfig/network-scripts/chat-ppp0"; - output_with_perm($chat_file, 0600, @chat); - - write_secret_backend($toreplace{login}, $toreplace{passwd}); - - #- install kppprc file according to used configuration. - mkdir_p("$::prefix/usr/share/config"); - - output("$::prefix/usr/share/config/kppprc", c::to_utf8(<<END)); -# KDE Config File - -[Account0] -ExDNSDisabled=0 -AutoName=$toreplace{AutoName} -ScriptArguments= -AccountingEnabled=0 -DialString=ATDT -Phonenumber=$toreplace{phone} -IPAddr=$toreplace{IPAddr} -Domain=$toreplace{domain} -Name=$toreplace{connection} -VolumeAccountingEnabled=0 -pppdArguments= -Password=$toreplace{passwd} -BeforeDisconnect= -Command= -ScriptCommands= -Authentication=$toreplace{Authentication} -DNS=$toreplace{dnsserver} -SubnetMask=$toreplace{SubnetMask} -AccountingFile= -DefaultRoute=1 -Username=$toreplace{login} -Gateway=$toreplace{Gateway} -StorePassword=1 -DisconnectCommand= - -[Modem] -BusyWait=0 -Enter=CR -FlowControl=CRTSCTS -Volume=0 -Timeout=60 -UseCDLine=0 -UseLockFile=1 -Device=/dev/modem -Speed=115200 - -[Graph] -InBytes=0,0,255 -Text=0,0,0 -Background=255,255,255 -Enabled=true -OutBytes=255,0,0 - -[General] -QuitOnDisconnect=0 -ShowLogWindow=0 -DisconnectOnXServerExit=1 -DefaultAccount=$toreplace{connection} -iconifyOnConnect=1 -Hint_QuickHelp=0 -AutomaticRedial=0 -PPPDebug=0 -NumberOfAccounts=1 -ShowClock=1 -DockIntoPanel=0 -pppdTimeout=30 -END - network::network::proxy_configure($::o->{miscellaneous}); -} - -1; diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm deleted file mode 100644 index 393140113..000000000 --- a/perl-install/network/netconnect.pm +++ /dev/null @@ -1,1284 +0,0 @@ -package network::netconnect; # $Id$ - -use strict; -use common; -use log; -use detect_devices; -use run_program; -use modules; -use any; -use mouse; -use network::network; -use network::tools; -use MDK::Common::Globals "network", qw($in); - -sub detect { - my ($auto_detect, $o_class) = @_; - my %l = ( - isdn => sub { - require network::isdn; - $auto_detect->{isdn} = network::isdn::isdn_detect_backend(); - }, - lan => sub { # ethernet - modules::load_category('network/main|gigabit|usb'); - require network::ethernet; - $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards() }; - }, - 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() }; - }, - ); - $l{$_}->() foreach ($o_class || (keys %l)); - return; -} - -sub init_globals { - my ($in) = @_; - MDK::Common::Globals::init(in => $in); -} - -sub detect_timezone() { - my %tmz2country = ( - 'Europe/Paris' => N("France"), - 'Europe/Amsterdam' => N("Netherlands"), - 'Europe/Rome' => N("Italy"), - 'Europe/Brussels' => N("Belgium"), - 'America/New_York' => N("United States"), - 'Europe/London' => N("United Kingdom") - ); - my %tm_parse = MDK::Common::System::getVarsFromSh('/etc/sysconfig/clock'); - my @country; - foreach (keys %tmz2country) { - if ($_ eq $tm_parse{ZONE}) { - unshift @country, $tmz2country{$_}; - } else { push @country, $tmz2country{$_} }; - } - \@country; -} - -# load sub category's wizard pages into main wizard data structure -sub get_subwizard { - my ($wiz, $type) = @_; - my %net_conf_callbacks = (adsl => sub { require network::adsl; &network::adsl::get_wizard }, - cable => sub { require network::ethernet; &network::ethernet::get_wizard }, - isdn => sub { require network::isdn; &network::isdn::get_wizard }, - lan => sub { require network::ethernet; &network::ethernet::get_wizard }, - modem => sub { require network::modem; &network::modem::get_wizard }, - ); - $net_conf_callbacks{$type}->($wiz); -} - -# configuring all network devices - sub main { - my ($_prefix, $netcnx, $in, $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, @devices, %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_protocol, @adsl_devices, $adsl_failed, $adsl_answer, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider); - my ($ntf_name, $ipadr, $netadr, $gateway_ex, $up, $isdn, $isdn_type, $need_restart_network); - my ($module, $auto_ip, $onboot, $needhostname, $hotplug, $track_network_id, @fields); # lan config - my $success = 1; - my $ethntf = {}; - my $db_path = "/usr/share/apps/kppp/Provider"; - my (%countries, @isp, $country, $provider, $old_provider); - - - my %wireless_mode = (N("Ad-hoc") => "Ad-hoc", - N("Managed") => "Managed", - N("Master") => "Master", - N("Repeater") => "Repeater", - N("Secondary") => "Secondary", - N("Auto") => "Auto", - ); - my %l10n_lan_protocols = ( - static => N("Manual configuration"), - dhcp => N("Automatic IP (BOOTP/DHCP)"), - if_(0, - dhcp_zeroconf => N("Automatic IP (BOOTP/DHCP/Zeroconf)"), - ) - ); - - - 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("$::prefix/etc/modules.conf"); - - $netc->{autodetect} = {}; - - my $first_modem = sub { first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}}) }; - - my $handle_multiple_cnx = sub { - $need_restart_network = 1 if $netcnx->{type} =~ /lan|cable/; - 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; - return $::isInstall ? "network_on_boot" : "apply_settings"; - } - }; - - my $lan_detect = sub { - detect($netc->{autodetect}, 'lan'); - modules::interactive::load_category($in, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 1); - @all_cards = network::ethernet::get_eth_cards(); - foreach my $card (@all_cards) { - modules::remove_alias($card->[1]); - modules::add_alias($card->[0], $card->[1]); - } - %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards; - if ($is_wireless) { - require list_modules; - my @wmodules = list_modules::category2modules('network/wireless'); - %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } grep { member($_->[1], @wmodules) } @all_cards; - } else { - %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards; - } - }; - - my $find_lan_module = sub { $module ||= (find { $_->[0] eq $ethntf->{DEVICE} } @all_cards)->[1] }; - - my %adsl_devices = ( - speedtouch => N("Alcatel speedtouch USB modem"), - sagem => N("Sagem USB modem"), - bewan_usb => N("Bewan USB modem"), - bewan_pci => N("Bewan PCI modem"), - eci => N("ECI Hi-Focus modem"), # this one needs eci agreement - ); - - my %adsl_types = ( - dhcp => N("Dynamic Host Configuration Protocol (DHCP)"), - manual => N("Manual TCP/IP configuration"), - pptp => N("Point to Point Tunneling Protocol (PPTP)"), - pppoe => N("PPP over Ethernet (PPPoE)"), - pppoa => N("PPP over ATM (PPPoA)"), - ); - - my %encapsulations = ( - 1 => N("Bridged Ethernet LLC"), - 2 => N("Bridged Ethernet VC"), - 3 => N("Routed IP LLC"), - 4 => N("Routed IP VC"), - 5 => N("PPPOA LLC"), - 6 => N("PPPOA VC"), - ); - - my %ppp_auth_methods = ( - 0 => N("Script-based"), - 1 => N("PAP"), - 2 => N("Terminal-based"), - 3 => N("CHAP"), - 4 => N("PAP/CHAP"), - ); - - # main wizard: - my $wiz; - $wiz = - { - defaultimage => "wiz_drakconnect.png", - name => N("Network & Internet Configuration"), - pages => { - welcome => - { - pre => sub { - # keep b/c of translations in case they can be reused somewhere else: - my @_a = (N("(detected on port %s)", 'toto'), - #-PO: here, "(detected)" string will be appended to eg "ADSL connection" - N("(detected %s)", 'toto'), N("(detected)")); - my @connections = - ([ N("Modem connection"), "modem" ], - [ N("ISDN connection"), "isdn" ], - [ N("ADSL connection"), "adsl" ], - [ N("Cable connection"), "cable" ], - [ N("LAN connection"), "lan" ], - [ N("Wireless connection"), "lan" ], - ); - - foreach (@connections) { - my ($string, $type) = @$_; - $connections{$string} = $type; - } - @connection_list = ({ val => \$cnx_type, type => 'list', list => [ map { $_->[0] } @connections ], }); - }, - no_back => 1, - name => N("Choose the connection you want to configure"), - interactive_help_id => 'configureNetwork', - data => \@connection_list, - post => sub { - $is_wireless = $cnx_type eq N("Wireless connection"); - load_conf($netcnx, $netc, $intf) if $::isInstall; # :-( - $type = $netcnx->{type} = $connections{$cnx_type}; - if ($type eq 'cable') { - $auto_ip = 1; - return "lan"; - } - return $type; - }, - }, - - prepare_detection => - { - name => N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.", - translate($type), N("Next")), - post => $handle_multiple_cnx, - }, - - - hw_account => - { - name => N("Connection Configuration") . "\n\n" . - N("Please fill or check the field below"), - data => [ - (map { - my ($dstruct, $field, $item) = @$_; - $item->{val} = \$dstruct->{$field}; - if__($dstruct->{$field}, $item); - } ([ $netcnx, "irq", { label => N("Card IRQ") } ], - [ $netcnx, "mem", { label => N("Card mem (DMA)") } ], - [ $netcnx, "io", { label => N("Card IO") } ], - [ $netcnx, "io0", { label => N("Card IO_0") } ], - [ $netcnx, "io1", { label => N("Card IO_1") } ], - [ $netcnx, "phone_in", { label => N("Your personal phone number") } ], - [ $netc, "DOMAINNAME2", { label => N("Provider name (ex provider.net)") } ], - [ $netcnx, "phone_out", { label => N("Provider phone number") } ], - [ $netc, "dnsServer2", { label => N("Provider DNS 1 (optional)") } ], - [ $netc, "dnsServer3", { label => N("Provider DNS 2 (optional)") } ], - [ $netcnx, "dialing_mode", { label => N("Dialing mode"), list => ["auto", "manual"] } ], - [ $netcnx, "speed", { label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"] } ], - [ $netcnx, "huptimeout", { label => N("Connection timeout (in sec)") } ], - ) - ), - ({ label => N("Account Login (user name)"), val => \$netcnx->{login} }, - { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1 }, - ) - ], - post => sub { - $handle_multiple_cnx->(); - }, - }, - - - 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'); - # FIXME: offer to pick any card from values %{$netc->{autodetect}{isdn}} - $isdn = top(values %{$netc->{autodetect}{isdn}}); - isdn_step_1: - defined $isdn->{id} and goto intern_pci; - }, - # !intern_pci: - name => N("What kind is your ISDN connection?"), - data => [ { val => \$isdn_type, type => "list", list => [ N_("Internal ISDN card"), N_("External ISDN modem") ], } ], - post => sub { - if ($isdn_type =~ /card/) { - intern_pci: - $netc->{isdntype} = 'isdn_internal'; - $netcnx->{isdn_internal} = $isdn; - $netcnx->{isdn_internal} = isdn_read_config($netcnx->{isdn_internal}); - isdn_detect($netcnx->{isdn_internal}, $netc) or goto isdn_step_1; - } else { - detect($netc->{autodetect}, 'modem'); - $netc->{isdntype} = 'isdn_external'; - $netcnx->{isdn_external}{device} = $first_modem->(); - $netcnx->{isdn_external} = isdn_read_config($netcnx->{isdn_external}); - $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40'; - require network::modem; - $modem = $netcnx->{isdn_external}; - return "ppp_account"; - }; - - }, - }, - - isdn_detect => - { - pre => sub { - my ($isdn, $netc) = @_; - if ($isdn->{id}) { - log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n"); - $isdn->{description} =~ s/\|/ -- /; - - isdn_detect_step_0: - defined $isdn->{type} and my $new = $in->ask_yesorno(N("ISDN Configuration"), N("Do you want to start a new configuration ?"), 1); - - if ($isdn->{type} eq '' || $new) { - isdn_ask($isdn, $netc, N("I have detected an ISDN PCI card, but I don't know its type. Please select a PCI card on the next screen.")) or goto isdn_detect_step_0; - } else { - isdn_detect_step_1: - $isdn->{protocol} = isdn_ask_protocol() or goto isdn_detect_step_0; - isdn_detect_step_2: - isdn_ask_info($isdn, $netc) or goto isdn_detect_step_1; - isdn_write_config($isdn, $netc) or goto isdn_detect_step_2; - } - } else { - isdn_ask($isdn, $netc, N("No ISDN PCI card found. Please select one on the next screen.")) or return; - } - $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE'; - 1; - } - }, - - no_supported_winmodem => - { - name => N("Warning") . "\n\n" . N("Your modem isn't supported by the system. -Take a look at http://www.linmodems.org"), - end => 1, - }, - - - modem => - { - pre => sub { - detect($netc->{autodetect}, 'modem'); - }, - name => N("Select the modem to configure:"), - data => sub { - [ { label => N("Modem"), type => "list", val => \$modem_name, list => [ keys %{$netc->{autodetect}{modem}} ], allow_empty_list => 1 } ], - }, - post => sub { - $ntf_name = $netc->{autodetect}{modem}{$modem_name}{device} || $netc->{autodetect}{modem}{$modem_name}{description}; - - return "ppp_provider" if $ntf_name =~ m!^/dev/!; - return "choose_serial_port" if !$ntf_name; - - my %relocations = (ltmodem => $in->do_pkgs->check_kernel_module_packages('ltmodem')); - my $type; - - detect($netc->{autodetect}, 'lan'); - - foreach (map { $_->{description} } values %{$netc->{autodetect}{modem}}) { - /Hcf/ and $type = "hcfpcimodem"; - /Hsf/ and $type = "hsflinmodem"; - /LT/ and $type = "ltmodem"; - $relocations{$type} || $type && $in->do_pkgs->what_provides($type) or $type = undef; - } - - return "no_supported_winmodem" if !$type; - - $in->do_pkgs->install($relocations{$type} ? @{$relocations{$type}} : $type); - - #$type eq 'ltmodem' and $netc->{autodetect}{modem} = '/dev/ttyS14'; - - #- fallback to modem configuration (beware to never allow test it). - return "ppp_provider"; - }, - }, - - - choose_serial_port => - { - pre => sub { - $modem ||= $netcnx->{modem} ||= {};; - }, - name => N("Please choose which serial port your modem is connected to."), - interactive_help_id => 'selectSerialPort', - data => sub { - [ { var => \$modem->{device}, format => \&mouse::serial_port2text, type => "list", - list => [ grep { $_ ne $o_mouse->{device} } (if_(-e '/dev/modem', '/dev/modem'), mouse::serial_ports()) ] } ], - }, - next => "ppp_provider", - }, - - - ppp_provider => - { - pre => sub { - @isp = map { - my $country = $_; - map { - s!$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/*"); - $old_provider = $provider; - }, - name => N("Select your provider:"), - data => sub { - [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/', list => \@isp } ] - }, - post => sub { - ($country, $provider) = split('/', $provider); - $country = { reverse %countries }->{$country}; - my %l = getVarsFromSh("$db_path/$country/$provider"); - if ($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"; - }, - }, - - - ppp_account => - { - 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}); - return if $modem_conf_read; - $modem_conf_read = 1; - $netcnx->{$netcnx->{type}} ||= {}; - $modem ||= $netcnx->{$netcnx->{type}}; - $modem->{device} ||= $first_modem->()->{device}; - my %l = getVarsFromSh("$::prefix/usr/share/config/kppprc"); - $l{Authentication} = 4 if !exists $l{Authentication}; - $modem->{$_} ||= $l{$_} foreach qw(Authentication Gateway IPAddr SubnetMask); - $modem->{connection} ||= $l{Name}; - $modem->{domain} ||= $l{Domain}; - ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS}); - - foreach (cat_("/etc/sysconfig/network-scripts/chat-ppp0")) { - /.*ATDT(\d*)/ and $modem->{phone} ||= $1; - } - foreach (cat_("/etc/sysconfig/network-scripts/ifcfg-ppp0")) { - /NAME=([\'\"]?)(.*)\1/ and $modem->{login} ||= $2; - } - $modem->{login} ||= $l{Username}; - my $secret = network::tools::read_secret_backend(); - foreach (@$secret) { - $modem->{passwd} ||= $_->{passwd} if $_->{login} eq $modem->{login}; - } - #my $secret = network::tools::read_secret_backend(); - #my @cnx_list = map { $_->{server} } @$secret; - $modem->{$_} ||= '' foreach qw(connection phone login passwd auth domain dns1 dns2); - $modem->{auto_gateway} ||= $modem->{Gateway} eq '0.0.0.0' ? N("Automatic") : N("Manual"); - $modem->{auto_ip} ||= $modem->{IPAdddr} eq '0.0.0.0' ? N("Automatic") : N("Manual"); - $modem->{auto_dns} ||= defined $modem->{dns1} || defined $modem->{dns2} ? N("Manual") : N("Automatic"); - }, - name => N("Dialup: account options"), - data => sub { - [ - { label => N("Connection name"), val => \$modem->{connection} }, - { label => N("Phone number"), val => \$modem->{phone} }, - { label => N("Login ID"), val => \$modem->{login} }, - { label => N("Password"), val => \$modem->{passwd}, hidden => 1 }, - { label => N("Authentication"), val => \$modem->{Authentication}, - list => [ sort keys %ppp_auth_methods ], format => sub { $ppp_auth_methods{$_[0]} } }, - ], - }, - next => "ppp_ip", - }, - - - ppp_ip => - { - pre => sub { - $modem_dyn_ip = sub { $modem->{auto_ip} eq N("Automatic") }; - }, - name => N("Dialup: IP parameters"), - data => sub { - [ - { label => N("IP parameters"), type => "list", val => \$modem->{auto_ip}, list => [ N("Automatic"), N("Manual") ] }, - { label => N("IP address"), val => \$modem->{IPAddr}, disabled => $modem_dyn_ip }, - { label => N("Subnet mask"), val => \$modem->{SubnetMask}, disabled => $modem_dyn_ip }, - ]; - }, - next => "ppp_dns", - }, - - - ppp_dns => - { - pre => sub { - $modem_dyn_dns = sub { $modem->{auto_dns} eq N("Automatic") }; - }, - name => N("Dialup: DNS parameters"), - data => sub { - [ - { label => N("DNS"), type => "list", val => \$modem->{auto_dns}, list => [ N("Automatic"), N("Manual") ] }, - { label => N("Domain name"), val => \$modem->{domain}, disabled => $modem_dyn_dns }, - { label => N("First DNS Server (optional)"), val => \$modem->{dns1}, disabled => $modem_dyn_dns }, - { label => N("Second DNS Server (optional)"), val => \$modem->{dns2}, disabled => $modem_dyn_dns }, - { text => N("Set hostname from IP"), val => \$modem->{AutoName}, type => 'bool', disabled => $modem_dyn_dns }, - ]; - }, - next => "ppp_gateway", - }, - - - ppp_gateway => - { - name => N("Dialup: IP parameters"), - data => sub { - [ - { label => N("Gateway"), type => "list", val => \$modem->{auto_gateway}, list => [ N("Automatic"), N("Manual") ] }, - { label => N("Gateway IP address"), val => \$modem->{Gateway}, - disabled => sub { $modem->{auto_gateway} eq N("Automatic") } }, - ]; - }, - post => sub { - network::modem::ppp_configure($in, $modem); - $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE'; - $in->do_pkgs->install('kdenetwork-kppp') if !-e '/usr/bin/kppp'; - $handle_multiple_cnx->(); - }, - }, - - - adsl => - { - pre => sub { - get_subwizard($wiz, 'adsl'); - $lan_detect->(); - detect($netc->{autodetect}, 'adsl'); - # FIXME: we still need to detect bewan modems - @adsl_devices = keys %eth_intf; - foreach my $modem (keys %adsl_devices) { - push @adsl_devices, $modem if $netc->{autodetect}{adsl}{$modem}; - } - }, - 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]} } } ], - post => sub { - my %packages = ( - 'eci' => [ 'eciadsl', 'missing' ], - 'sagem' => [ 'eagle', '/usr/sbin/eaglectrl' ], - 'speedtouch' => [ 'speedtouch', '/usr/share/speedtouch/speedtouch.sh' ], - ); - return 'adsl_unsupported_eci' if $ntf_name eq 'eci'; - $netconnect::need_restart_network = member($ntf_name, qw(speedtouch eci)); - $in->do_pkgs->install($packages{$ntf_name}->[0]) if $packages{$ntf_name} && !-e $packages{$ntf_name}->[1]; - if ($ntf_name eq 'speedtouch' && ! -r '$::prefix/usr/share/speedtouch/mgmt.o' && !$::testing) { - $in->do_pkgs->what_provides("speedtouch_mgmt") and - $in->do_pkgs->install('speedtouch_mgmt'); - return 'adsl_speedtouch_firmware' if ! -e "$::prefix/usr/share/speedtouch/mgmt.o"; - } - return 'adsl_provider' if $adsl_devices{$ntf_name}; - return 'adsl_protocol'; - }, - }, - - - adsl_provider => - { - pre => sub { - require network::adsl_consts; - %adsl_data = %network::adsl_consts::adsl_data; - $adsl_old_provider = $adsl_provider; - }, - name => N("Please choose your ADSL provider"), - data => sub { - [ { label => N("Provider:"), type => "list", val => \$adsl_provider, separator => '|', list => [ keys %adsl_data ] } ]; - }, - next => 'adsl_protocol', - post => sub { - $adsl_data = $adsl_data{$adsl_provider}; - $adsl_protocol = $adsl_types{pppoa} if $ntf_name eq 'speedtouch'; - if ($adsl_provider ne $adsl_old_provider) { - $netc->{$_} = $adsl_data->{$_} foreach qw(dnsServer2 dnsServer3 DOMAINNAME2 Encapsulation vpi vci); - $adsl_protocol ||= $adsl_types{$adsl_data->{method}}; - } - return 'adsl_protocol'; - }, - }, - - - adsl_speedtouch_firmware => - { - name => N("You need the Alcatel microcode. -You can provide it now via a floppy or your windows partition, -or skip and do it later."), - data => [ { label => "", val => \$adsl_answer, type => "list", - list => [ N("Use a floppy"), N("Use my Windows partition"), N("Do it later") ], } - ], - post => sub { - my $destination = "$::prefix/usr/share/speedtouch/"; - my ($file, $source, $mounted); - if ($adsl_answer eq N("Use a floppy")) { - $mounted = 1; - $file = 'mgmt.o'; - ($source, $adsl_failed) = network::tools::use_floppy($in, $file); - } elsif ($adsl_answer eq N("Use my Windows partition")) { - $file = 'alcaudsl.sys'; - ($source, $adsl_failed) = network::tools::use_windows(); - } - return "adsl_no_firmawre" if $adsl_answer eq N("Do it later"); - - my $_b = before_leaving { fs::umount('/mnt') } if $mounted; - if (!$adsl_failed) { - if (-e "$source/$file") { - cp_af("$source/$file", $destination) if !$::testing; - } else { - $adsl_failed = N("Firmware copy failed, file %s not found", $file); - } - } - log::explanations($adsl_failed || "Firmware copy $file in $destination succeeded"); - -e "$destination/alcaudsl.sys" and rename "$destination/alcaudsl.sys", "$destination/mgmt.o"; - - # kept translations b/c we may want to reuse it later: - my $_msg = N("Firmware copy succeeded"); - return $adsl_failed ? 'adsl_copy_firmware_failled' : 'adsl_provider'; - }, - }, - - - adsl_copy_firmware_failled => - { - name => sub { $adsl_failed }, - next => 'adsl_provider', - }, - - - "adsl_no_firmawre" => - { - name => N("You need the Alcatel microcode. -Download it at: -%s -and copy the mgmt.o in /usr/share/speedtouch", 'http://prdownloads.sourceforge.net/speedtouch/speedtouch-20011007.tar.bz2'), - next => "adsl_protocol", - }, - - - adsl_protocol => - { - 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'"), - data => [ - { text => N("ADSL connection type :"), val => \$adsl_protocol, type => "list", - list => [ sort values %adsl_types ], - }, - ], - post => sub { - $netcnx->{type} = 'adsl'; - $adsl_type = find { $adsl_types{$_} eq $adsl_protocol } keys %adsl_types; - $adsl_type = { reverse %adsl_types }->{$adsl_protocol}; - # process static/dhcp ethernet devices: - if (!exists $adsl_devices{$ntf_name} && member($adsl_type, qw(manual dhcp))) { - $auto_ip = $adsl_type eq 'dchp'; - $find_lan_module->(); - $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; - 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'; - }, - }, - - - adsl_account => - { - pre => sub { - $netc->{dnsServer2} ||= $adsl_data->{dns1}; - $netc->{dnsServer3} ||= $adsl_data->{dns2}; - }, - name => N("Connection Configuration") . "\n\n" . - N("Please fill or check the field below"), - data => sub { - [ - { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} }, - { label => N("First DNS Server (optional)"), val => \$netc->{dnsServer2} }, - { 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 }, - { label => N("Encapsulation :"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ], - format => sub { $encapsulations{$_[0]} }, advanced => 1, - }, - ], - }, - post => sub { - network::adsl::adsl_conf_backend($in, $netcnx, $netc, $ntf_name, $adsl_type); #FIXME - $handle_multiple_cnx->(); - }, - }, - - - adsl_unsupported_eci => - { - name => N("The ECI Hi-Focus modem cannot be supported due to binary driver distribution problem. - -You can find a driver on http://eciadsl.flashtux.org/"), - end => 1, - }, - - - lan => - { - pre => $lan_detect, - name => N("Select the network interface to configure:"), - data => sub { - [ { label => N("Net Device"), type => "list", val => \$ntf_name, list => [ keys %eth_intf ], - allow_empty_list => 1, format => sub { $eth_intf{$_[0]} } } ]; - }, - post => sub { - $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; - $::isInstall && $netc->{NET_DEVICE} eq $ethntf->{DEVICE} ? 'lan_alrd_cfg' : 'lan_protocol'; - }, - }, - - 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."), - type => "yesorno", - post => sub { - my ($res) = @_; - die 'wizcancel' if !$res; - return "lan_protocol"; - } - }, - - lan_protocol => - { - pre => sub { - $find_lan_module->(); - $auto_ip = $l10n_lan_protocols{defined $auto_ip ? ($auto_ip ? 'dhcp' : 'static') : $ethntf->{BOOTPROTO}} || 0; - }, - name => sub { - my $_msg = N("Zeroconf hostname resolution"); - N("Configuring network device %s (driver %s)", $ethntf->{DEVICE}, $module) . "\n\n" . - N("The following protocols can be used to configure an ethernet connection. Please choose the one you want to use") - }, - data => sub { - [ { val => \$auto_ip, type => "list", list => [ values %l10n_lan_protocols ] } ]; - }, - post => sub { - $auto_ip = $auto_ip ne $l10n_lan_protocols{static} || 0; - return 'lan_intf'; - }, - }, - - - # FIXME: is_install: no return for each card "last step" because of manual popping - # better construct an hash of { current_netintf => next_step } which next_step = last_card ? next_eth_step : next_card ? - lan_intf => - { - pre => sub { - $onboot = $ethntf->{ONBOOT} ? $ethntf->{ONBOOT} =~ /yes/ : bool2yesno(!member($ethntf->{DEVICE}, - map { $_->{device} } detect_devices::pcmcia_probe())); - $needhostname = $ethntf->{NEEDHOSTNAME} !~ /no/; - $hotplug = $::isStandalone && !$ethntf->{MII_NOT_SUPPORTED} || 1; - $track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop(); - delete $ethntf->{NETWORK}; - delete $ethntf->{BROADCAST}; - @fields = qw(IPADDR NETMASK); - $netc->{dhcp_client} ||= "dhcp-client"; - }, - name => sub { join('', - N("Configuring network device %s (driver %s)", $ethntf->{DEVICE}, $module), - if_(!$auto_ip, "\n\n" . N("Please enter the IP configuration for this machine. -Each item should be entered as an IP address in dotted-decimal -notation (for example, 1.2.3.4).")), - ) }, - data => sub { - [ $auto_ip ? - ( - { text => N("Assign host name from DHCP address"), val => \$needhostname, type => "bool" }, - { label => N("DHCP host name"), val => \$ethntf->{DHCP_HOSTNAME}, disabled => sub { !$needhostname } }, - ) - : - ( - { label => N("IP address"), val => \$ethntf->{IPADDR}, disabled => sub { $auto_ip } }, - { label => N("Netmask"), val => \$ethntf->{NETMASK}, disabled => sub { $auto_ip } }, - ), - { 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_($auto_ip, - { label => N("DHCP client"), val => \$netc->{dhcp_client}, - list => [ "dhcp-client", "dhcpcd", "dhcpxd" ], advanced => 1 }, - ), - ], - }, - complete => sub { - $ethntf->{BOOTPROTO} = $auto_ip ? "dhcp" : "static"; - $netc->{DHCP} = $auto_ip; - return 0 if $auto_ip; - if (my @bad = map_index { if_(!is_ip($ethntf->{$_}), $::i) } @fields) { - $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}); - }, - focus_out => sub { - $ethntf->{NETMASK} ||= netmask($ethntf->{IPADDR}) unless $_[0] - }, - post => sub { - $ethntf->{ONBOOT} = bool2yesno($onboot); - $ethntf->{NEEDHOSTNAME} = bool2yesno($needhostname); - $ethntf->{MII_NOT_SUPPORTED} = bool2yesno(!$hotplug); - $ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR}; - $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"; - }, - }, - - wireless => - { - pre => sub { - $ethntf->{wireless_eth} = 1; - $netc->{wireless_eth} = 1; - $ethntf->{WIRELESS_MODE} = "Managed"; - $ethntf->{WIRELESS_ESSID} = "any"; - }, - name => N("Please enter the wireless parameters for this card:"), - data => [ - { label => N("Operating Mode"), val => \$ethntf->{WIRELESS_MODE}, - list => [ keys %wireless_mode ] }, - { label => N("Network name (ESSID)"), val => \$ethntf->{WIRELESS_ESSID} }, - { label => N("Network ID"), val => \$ethntf->{WIRELESS_NWID} }, - { label => N("Operating frequency"), val => \$ethntf->{WIRELESS_FREQ} }, - { label => N("Sensitivity threshold"), val => \$ethntf->{WIRELESS_SENS} }, - { label => N("Bitrate (in b/s)"), val => \$ethntf->{WIRELESS_RATE} }, - { label => N("Encryption key"), val => \$ethntf->{WIRELESS_ENC_KEY} }, - { label => N("RTS/CTS"), val => \$ethntf->{WIRELESS_RTS}, - help => N("RTS/CTS adds a handshake before each packet transmission to make sure that the -channel is clear. This adds overhead, but increase performance in case of hidden -nodes or large number of active nodes. This parameter sets the size of the -smallest packet for which the node sends RTS, a value equal to the maximum -packet size disable the scheme. You may also set this parameter to auto, fixed -or off.") - }, - { label => N("Fragmentation"), val => \$ethntf->{WIRELESS_FRAG} }, - { label => N("Iwconfig command extra arguments"), val => \$ethntf->{WIRELESS_IWCONFIG}, advanced => 1, - 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."), - }, - { label => N("Iwspy command extra arguments"), val => \$ethntf->{WIRELESS_IWSPY}, advanced => 1, - help => N("Iwspy is used to set a list of addresses in a wireless network -interface and to read back quality of link information for each of those. - -This information is the same as the one available in /proc/net/wireless : -quality of the link, signal strength and noise level. - -See iwpspy(8) man page for further information."), - }, - { label => N("Iwpriv command extra arguments"), val => \$ethntf->{WIRELESS_IWPRIV}, advanced => 1, - help => N("Iwpriv enable to set up optionals (private) parameters of a wireless network -interface. - -Iwpriv deals with parameters and setting specific to each driver (as opposed to -iwconfig which deals with generic ones). - -In theory, the documentation of each device driver should indicate how to use -those interface specific commands and their effect. - -See iwpriv(8) man page for further information."), - } - ], - complete => sub { - if ($ethntf->{WIRELESS_FREQ} !~ /[0-9.]*[kGM]/) { - $in->ask_warn(N("Error"), N("Freq should have the suffix k, M or G (for example, \"2.46G\" for 2.46 GHz frequency), or add enough '0' (zeroes).")); - return 1, 6; - } - if ($ethntf->{WIRELESS_RATE} !~ /[0-9.]*[kGM]/) { - $in->ask_warn(N("Error"), N("Rate should have the suffix k, M or G (for example, \"11M\" for 11M), or add enough '0' (zeroes).")); - return 1, 8; - } - }, - post => sub { - # untranslate parameters - $ethntf->{WIRELESS_MODE} = $wireless_mode{$ethntf->{WIRELESS_MODE}}; - 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 => [ { var => \$interface, type => "list", list => \@all_cards, } ], - format => sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") }, - - post => sub { - modules::write_conf() if $::isStandalone; - my $_device = conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr); - return "lan"; - }, - }, - - static_hostname => - { - pre => sub { - $netc->{dnsServer} ||= dns($intf->{IPADDR}); - $gateway_ex = gateway($intf->{IPADDR}); - #- $netc->{GATEWAY} ||= gateway($intf->{IPADDR}); - }, - name => N("Please enter your host name. -Your host name should be a fully-qualified host name, -such as ``mybox.mylab.myco.com''. -You may also enter the IP address of the gateway if you have one."), - data => sub { - [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$netc->{HOSTNAME}, advanced => $auto_ip }, - { label => N("DNS server 1"), val => \$netc->{dnsServer} }, - { label => N("DNS server 2"), val => \$netc->{dnsServer2} }, - { label => N("DNS server 3"), val => \$netc->{dnsServer3} }, - { label => N("Search domain"), val => \$netc->{DOMAINNAME}, - help => N("By default search domain will be set from the fully-qualified host name") }, - if_(!$auto_ip, { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} }, - if_(@devices > 1, - { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => \@devices }, - ), - ), - ], - }, - complete => sub { - foreach my $dns (qw(dnsServer dnsServer2 dnsServer3)) { - if ($netc->{$dns} && !is_ip($netc->{$dns})) { - $in->ask_warn(N("Error"), N("DNS server address should be in format 1.2.3.4")); - return 1; - } - } - if ($netc->{GATEWAY} && !is_ip($netc->{GATEWAY})) { - $in->ask_warn(N("Error"), N("Gateway address should be in format 1.2.3.4")); - return 1; - } - }, - #post => $handle_multiple_cnx, - next => "zeroconf", - }, - - - zeroconf => - { - name => N("Enter a Zeroconf host name which will be the one that your machine will get back to other machines on the network:"), - data => [ { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} } ], - complete => sub { - if ($netc->{ZEROCONF_HOSTNAME} =~ /\./) { - $in->ask_warn(N("Error"), N("Zeroconf host name must not contain a .")); - return 1; - } - }, - post => $handle_multiple_cnx, - }, - - - multiple_internet_cnx => - { - name => N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n") . if_(!$::isStandalone, "You may want to configure some profiles after the installation, in the Mandrake Control Center"), - data => [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice}, - list => [ keys %{$netc->{internet_cnx}} ] } ], - post => sub { $::isInstall ? "network_on_boot" : "apply_settings" }, - }, - - apply_settings => - { - name => N("Configuration is complete, do you want to apply settings ?"), - type => "yesorno", - next => "network_on_boot", - }, - - network_on_boot => - { - pre => sub { - # condition is : - member($netc->{internet_cnx_choice}, ('adsl', 'isdn')); # and $netc->{at_boot} = $in->ask_yesorno(N("Network Configuration Wizard"), N("Do you want to start the connection at boot?")); - }, - name => N("Do you want to start the connection at boot?"), - type => "yesorno", - post => sub { - my ($res) = @_; - $netc->{at_boot} = $res; - if ($netc->{internet_cnx_choice}) { - write_cnx_script($netc); - $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type}; - } else { - unlink "$::prefix/etc/sysconfig/network-scripts/net_cnx_up"; - unlink "$::prefix/etc/sysconfig/network-scripts/net_cnx_down"; - undef $netc->{NET_DEVICE}; - } - - network::network::configureNetwork2($in, $::prefix, $netc, $intf); - $network_configured = 1; - $::isInstall ? "restart" : "ask_connect_now"; - }, - }, - - restart => - { - # FIXME: condition is "if ($netconnect::need_restart_network && $::isStandalone && (!$::expert || $in->ask_yesorno(..." - name => N("The network needs to be restarted. Do you want to restart it ?"), - # data => [ { label => N("Connection:"), val => \$type, type => 'list', list => [ sort values %l ] }, ], - post => sub { - if (!$::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); - } - write_initscript(); - return $::isStandalone && member($netc->{internet_cnx_choice}, qw(modem adsl isdn)) ? "ask_connect_now" : "end"; - }, - }, - - ask_connect_now => - { - name => N("Do you want to try to connect to the Internet now?"), - type => "yesorno", - post => sub { - my ($a) = @_; - my ($type) = $netc->{internet_cnx_choice}; - $up = 1; - if ($a) { - # local $::isWizard = 0; - my $_w = $in->wait_message('', N("Testing your connection..."), 1); - connect_backend(); - my $s = 30; - $type =~ /modem/ and $s = 50; - $type =~ /adsl/ and $s = 35; - $type =~ /isdn/ and $s = 20; - sleep $s; - $up = connected(); - } - $success = $up; - return $a ? "disconnect" : "end"; - } - }, - disconnect => - { - name => sub { - $up ? N("The system is now connected to the Internet.") . - if_($::isInstall, N("For security reasons, it will be disconnected now.")) : - N("The system doesn't seem to be connected to the Internet. -Try to reconfigure your connection."); - }, - no_back => 1, - end => 1, - post => sub { - $::isInstall and disconnect_backend(); - return "end"; - }, - }, - - end => - { - name => sub { - return $success ? join('', N("Congratulations, the network and Internet configuration is finished. - -"), 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. -Test your connection via net_monitor or mcc. If your connection doesn't work, you might want to relaunch the configuration."); - }, - end => 1, - }, - }, - }; - - my $use_wizard = 1; - if ($::isInstall) { - if ($first_time && $in->{method} =~ /^(ftp|http|nfs)$/) { - !$::expert && !$o_noauto || $in->ask_okcancel(N("Network Configuration"), - N("Because you are doing a network installation, your network is already configured. -Click on Ok to keep your configuration, or cancel to reconfigure your Internet & Network connection. -"), 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; - $use_wizard = 0; - }; - } - }; - - if ($use_wizard) { - require wizards; - $wiz->{var} = { - netc => $netc, - mouse => $mouse, - intf => $intf, - }; - wizards->new->safe_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; - $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE); - $netcnx->{type} =~ /adsl/ or system("/sbin/chkconfig --del adsl 2> /dev/null"); - - if ($::isInstall && $::o->{security} >= 3) { - require network::drakfirewall; - network::drakfirewall::main($in, $::o->{security} <= 3); - } -} - -sub set_profile { - my ($netcnx) = @_; - system(qq(/sbin/set-netprofile "$netcnx->{PROFILE}")); - log::explanations(qq(Switching to "$netcnx->{PROFILE}" profile)); -} - -sub save_profile { - my ($netcnx) = @_; - system(qq(/sbin/save-netprofile "$netcnx->{PROFILE}")); - log::explanations(qq(Saving "$netcnx->{PROFILE}" profile)); -} - -sub del_profile { - my ($profile) = @_; - return if !$profile || $profile eq "default"; - rm_rf("$::prefix/etc/netprofile/profiles/$profile"); - log::explanations(qq(Deleting "$profile" profile)); -} - -sub add_profile { - my ($netcnx, $profile) = @_; - return if !$profile || $profile eq "default" || member($profile, get_profiles()); - system(qq(/sbin/clone-netprofile "$netcnx->{PROFILE}" "$profile")); - log::explanations(qq("Creating "$profile" profile)); -} - -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); -} - -sub get_net_device() { - my $connect_file = $network::tools::connect_file; - my $network_file = "/etc/sysconfig/network"; - if (cat_("$::prefix$connect_file") =~ /ifup/) { - if_(cat_($connect_file) =~ /^\s*ifup\s+(.*)/m, split(' ', $1)) - } elsif (cat_("$::prefix$connect_file") =~ /network/) { - ${{ getVarsFromSh("$::prefix$network_file") }}{GATEWAYDEV}; - } elsif (cat_("$::prefix$connect_file") =~ /isdn/) { - "ippp+"; - } else { - "ppp+"; - }; -} - -sub read_net_conf { - my ($_prefix, $netcnx, $netc) = @_; - $netc->{$_} = $netcnx->{$_} foreach 'NET_DEVICE', 'NET_INTERFACE'; - $netcnx->{$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); -} - -sub stop_internet { - my ($o) = @_; - init_globals($o); - run_program::rooted($::prefix, $network::tools::disconnect_file); -} - -1; - -=head1 network::netconnect::detect() - -=head2 example of usage - -use lib qw(/usr/lib/libDrakX); -use network::netconnect; -use Data::Dumper; - -use class_discard; - -local $in = class_discard->new; - -network::netconnect::init_globals($in); -my %i; -&network::netconnect::detect(\%i); -print Dumper(\%i),"\n"; - -=cut diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm deleted file mode 100644 index cccd4767d..000000000 --- a/perl-install/network/network.pm +++ /dev/null @@ -1,432 +0,0 @@ -package network::network; # $Id$wir - -#-###################################################################################### -#- misc imports -#-###################################################################################### - -use strict; - -use Socket; -use common; -use detect_devices; -use run_program; -use network::tools; -use any; -use vars qw(@ISA @EXPORT); -use log; - -@ISA = qw(Exporter); -@EXPORT = qw(add2hosts addDefaultRoute configureNetwork2 dns dnsServers findIntf gateway guessHostname is_ip is_ip_forbidden masked_ip netmask read_all_conf read_conf read_interface_conf read_resolv_conf resolv sethostname write_conf write_resolv_conf); - -#-###################################################################################### -#- Functions -#-###################################################################################### -sub read_conf { - my ($file) = @_; - +{ getVarsFromSh($file) }; -} - -sub read_resolv_conf_raw { - my ($file) = @_; - $file ||= "$::prefix/etc/resolv.conf"; - { nameserver => [ cat_($file) =~ /^\s*nameserver\s+(\S+)/mg ], - search => [ if_(cat_($file) =~ /^\s*search\s+(.*)/m, split(' ', $1)) ] }; -} - -sub read_resolv_conf { - my ($file) = @_; - my $resolv_conf = read_resolv_conf_raw($file); - +{ - (mapn { $_[0] => $_[1] } [ qw(dnsServer dnsServer2 dnsServer3) ], $resolv_conf->{nameserver}), - (mapn { $_[0] => $_[1] } [ qw(DOMAINNAME DOMAINNAME2 DOMAINNAME3) ], $resolv_conf->{search}), - }; -} - -sub read_interface_conf { - my ($file) = @_; - my %intf = getVarsFromSh($file); - - $intf{BOOTPROTO} ||= 'static'; - $intf{isPtp} = $intf{NETWORK} eq '255.255.255.255'; - $intf{isUp} = 1; - \%intf; -} - -sub read_dhcpd_conf { - my ($file) = @_; - $file ||= "$::prefix/etc/dhcpd.conf"; - { option_routers => [ cat_($file) =~ /^\s*option routers\s+(\S+);/mg ], - subnet_mask => [ if_(cat_($file) =~ /^\s*option subnet-mask\s+(.*);/mg, split(' ', $1)) ], - domain_name => [ if_(cat_($file) =~ /^\s*option domain-name\s+"(.*)";/mg, split(' ', $1)) ], - domain_name_servers => [ if_(cat_($file) =~ /^\s*option domain-name-servers\s+(.*);/m, split(' ', $1)) ], - dynamic_bootp => [ if_(cat_($file) =~ /^\s*range dynamic-bootp\s+\S+\.(\d+)\s+\S+\.(\d+)\s*;/m, split(' ', $1)) ], - default_lease_time => [ if_(cat_($file) =~ /^\s*default-lease-time\s+(.*);/m, split(' ', $1)) ], - max_lease_time => [ if_(cat_($file) =~ /^\s*max-lease-time\s+(.*);/m, split(' ', $1)) ] }; -} - -sub read_squid_conf { - my ($file) = @_; - $file ||= "$::prefix/etc/squid/squid.conf"; - { http_port => [ cat_($file) =~ /^\s*http_port\s+(.*)/mg ], - cache_size => [ if_(cat_($file) =~ /^\s*cache_dir diskd\s+(.*)/mg, split(' ', $1)) ], - admin_mail => [ if_(cat_($file) =~ /^\s*err_html_text\s+(.*)/mg, split(' ', $1)) ] }; -} - -sub read_tmdns_conf { - my ($file) = @_; - local *F; open F, $file or die "cannot open file $file: $!"; - local $_; - my %outf; - - while (<F>) { - ($outf{ZEROCONF_HOSTNAME}) = /^\s*hostname\s*=\s*(\w+)/ and return \%outf; - } - - \%outf; -} - -sub write_conf { - my ($file, $netc) = @_; - - if ($netc->{HOSTNAME} && $netc->{HOSTNAME} =~ /\.(.+)$/) { - $netc->{DOMAINNAME} = $1; - } - $netc->{NETWORKING} = 'yes'; - - setVarsInSh($file, $netc, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN)); -} - -sub write_zeroconf { - my ($file, $zhostname) = @_; - eval { substInFile { s/^\s*(hostname)\s*=.*/$1 = $zhostname/ } $file }; -} - -sub write_resolv_conf { - my ($file, $netc) = @_; - - my %new = ( - search => [ grep { $_ } uniq(@$netc{'DOMAINNAME', 'DOMAINNAME2', 'DOMAINNAME3'}) ], - nameserver => [ grep { $_ } uniq(@$netc{'dnsServer', 'dnsServer2', 'dnsServer3'}) ], - ); - - my (%prev, @unknown); - foreach (cat_($file)) { - s/\s+$//; - s/^[#\s]*//; - - if (my ($key, $val) = /^(search|nameserver)\s+(.*)$/) { - push @{$prev{$key}}, $val; - } elsif (/^ppp temp entry$/) { - } elsif (/\S/) { - push @unknown, $_; - } - } - unlink $file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever - - if (@{$new{search}} || @{$new{nameserver}}) { - $prev{$_} = [ difference2($prev{$_} || [], $new{$_}) ] foreach keys %new; - - my @search = do { - my @new = if_(@{$new{search}}, "search " . join(' ', @{$new{search}}) . "\n"); - my @old = if_(@{$prev{search}}, "# search " . join(' ', @{$prev{search}}) . "\n"); - @new, @old; - }; - my @nameserver = do { - my @new = map { "nameserver $_\n" } @{$new{nameserver}}; - my @old = map { "# nameserver $_\n" } @{$prev{nameserver}}; - @new, @old; - }; - output_with_perm($file, 0644, @search, @nameserver, (map { "# $_\n" } @unknown), "\n# ppp temp entry\n"); - - #-res_init(); # reinit the resolver so DNS changes take affect - 1; - } else { - log::explanations("neither domain name nor dns server are configured"); - 0; - } -} - -sub write_interface_conf { - my ($file, $intf, $_netc, $_prefix) = @_; - - if ($intf->{HWADDR} && -e "$::prefix/sbin/ip") { - $intf->{HWADDR} = undef; - if (my $s = `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`) { - if ($s =~ m|.*link/ether\s([0-9a-z:]+)\s|) { - $intf->{HWADDR} = $1; - } - } - } - my @ip = split '\.', $intf->{IPADDR}; - my @mask = split '\.', $intf->{NETMASK}; - - add2hash($intf, { - BROADCAST => join('.', mapn { int($_[0]) | ((~int($_[1])) & 255) } \@ip, \@mask), - NETWORK => join('.', mapn { int($_[0]) & $_[1] } \@ip, \@mask), - ONBOOT => bool2yesno(!member($intf->{DEVICE}, map { $_->{device} } detect_devices::pcmcia_probe())), - }); - - $intf->{BOOTPROTO} =~ s/dhcp.*/dhcp/; - - setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR MII_NOT_SUPPORTED), - 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), - if_($intf->{BOOTPROTO} eq "dhcp", qw(DHCP_HOSTNAME NEEDHOSTNAME)) - ); - log::explanations("written $intf->{DEVICE} interface configuration in $file"); -} - -sub add2hosts { - my ($file, $hostname, @ips) = @_; - - my %l = map { if_(/\s*(\S+)(.*)/, $1 => $2) } - grep { !/\s+\Q$hostname\E\s*$/ } cat_($file); - - my $sub_hostname = $hostname =~ /(.*?)\./ ? " $1" : ''; - $l{$_} = "\t\t$hostname$sub_hostname" foreach grep { $_ } @ips; - - log::explanations("writing host information to $file"); - output($file, map { "$_$l{$_}\n" } keys %l); -} - -# The interface/gateway needs to be configured before this will work! -sub guessHostname { - my ($_prefix, $netc, $intf) = @_; - - $intf->{isUp} && dnsServers($netc) or return 0; - $netc->{HOSTNAME} && $netc->{DOMAINNAME} and return 1; - - write_resolv_conf("$::prefix/etc/resolv.conf", $netc); - - my $name = gethostbyaddr(Socket::inet_aton($intf->{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0; - - log::explanations("reverse name lookup worked"); - - add2hash($netc, { HOSTNAME => $name }); - 1; -} - -sub addDefaultRoute { - my ($netc) = @_; - c::addDefaultRoute($netc->{GATEWAY}) if $netc->{GATEWAY}; -} - -sub sethostname { - my ($netc) = @_; - my $text; - syscall_("sethostname", $netc->{HOSTNAME}, length $netc->{HOSTNAME}) ? ($text="set sethostname to $netc->{HOSTNAME}") : ($text="sethostname failed: $!"); - log::explanations($text); -} - -sub resolv($) { - my ($name) = @_; - is_ip($name) and return $name; - my $a = join(".", unpack "C4", (gethostbyname $name)[4]); - #-log::explanations("resolved $name in $a"); - $a; -} - -sub dnsServers { - my ($netc) = @_; - my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3); - sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns; -} - -sub findIntf { - my ($intf, $device) = @_; - $intf->{$device}{DEVICE} = $device; - $intf->{$device}; -} - -my $ip_regexp = qr/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; - -sub is_ip { - my ($ip) = @_; - my @fields = $ip =~ $ip_regexp or return; - every { 0 <= $_ && $_ <= 255 } @fields or return; - @fields; -} - -sub ip_compare { - my ($ip1, $ip2) = @_; - my (@ip1_fields) = $ip1 =~ $ip_regexp; - my (@ip2_fields) = $ip2 =~ $ip_regexp; - - every { $ip1_fields[$_] eq $ip2_fields[$_] } (0 .. 3); -} - -sub is_ip_forbidden { - my ($ip) = @_; - my @forbidden = ('127.0.0.1', '255.255.255.255'); - - any { ip_compare($ip, $_) } @forbidden; -} - -sub is_domain_name { - my ($name) = @_; - my @fields = split /\./, $name; - $name !~ /\.$/ && @fields > 0 && @fields == grep { /^[[:alnum:]](?:[\-[:alnum:]]{0,61}[[:alnum:]])?$/ } @fields; -} - -sub netmask { - my ($ip) = @_; - return "255.255.255.0" unless is_ip($ip); - $ip =~ $ip_regexp or warn "IP_regexp failed\n" and return "255.255.255.0"; - if ($1 >= 1 && $1 < 127) { - "255.0.0.0"; #-1.0.0.0 to 127.0.0.0 - } elsif ($1 >= 128 && $1 <= 191) { - "255.255.0.0"; #-128.0.0.0 to 191.255.0.0 - } elsif ($1 >= 192 && $1 <= 223) { - "255.255.255.0"; - } else { - "255.255.255.255"; #-experimental classes - } -} - -sub masked_ip { - my ($ip) = @_; - my @ip = is_ip($ip) or return ''; - my @mask = netmask($ip) =~ $ip_regexp; - for (my $i = 0; $i < @ip; $i++) { - $ip[$i] &= int $mask[$i]; - } - join(".", @ip); -} - -sub dns { - my ($ip) = @_; - my @masked = masked_ip($ip) =~ $ip_regexp; - $masked[3] = 2; - join(".", @masked); - -} - -sub gateway { - my ($ip) = @_; - my @masked = masked_ip($ip) =~ $ip_regexp; - $masked[3] = 1; - join(".", @masked); -} - -sub miscellaneous_choose { - my ($in, $u) = @_; - - $in->ask_from('', - N("Proxies configuration"), - [ { label => N("HTTP proxy"), val => \$u->{http_proxy} }, - { label => N("FTP proxy"), val => \$u->{ftp_proxy} }, - ], - complete => sub { - $u->{http_proxy} =~ m,^($|http://), or $in->ask_warn('', N("Proxy should be http://...")), return 1,0; - $u->{ftp_proxy} =~ m,^($|ftp://|http://), or $in->ask_warn('', N("URL should begin with 'ftp:' or 'http:'")), return 1,1; - 0; - } - ) or return; - 1; -} - -sub proxy_configure { - my ($u) = @_; - setExportedVarsInSh("$::prefix/etc/profile.d/proxy.sh", $u, qw(http_proxy ftp_proxy)); - chmod 0755, "$::prefix/etc/profile.d/proxy.sh"; - setExportedVarsInCsh("$::prefix/etc/profile.d/proxy.csh", $u, qw(http_proxy ftp_proxy)); - chmod 0755, "$::prefix/etc/profile.d/proxy.csh"; -} - -sub read_all_conf { - my ($_prefix, $netc, $intf, $o_netcnx) = @_; - $netc ||= {}; $intf ||= {}; - my $netcnx = $o_netcnx || {}; - add2hash($netc, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network"; - add2hash($netc, read_resolv_conf()); - add2hash($netc, read_tmdns_conf("$::prefix/etc/tmdns.conf")) if -r "$::prefix/etc/tmdns.conf"; - foreach (all("$::prefix/etc/sysconfig/network-scripts")) { - if (/^ifcfg-(\w+)$/ && $1 ne 'lo') { - my $intf = findIntf($intf, $1); - add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") }); - } - } - $netcnx->{type} or probe_netcnx_type($::prefix, $netc, $intf, $netcnx); -} - -sub probe_netcnx_type { - my ($_prefix, $_netc, $intf, $netcnx) = @_; - #- try to probe $netcnx->{type} which is used almost everywhere. - unless ($netcnx->{type}) { - #- ugly hack to determine network type (avoid saying not configured in summary). - -e "$::prefix/etc/ppp/peers/adsl" and $netcnx->{type} ||= 'adsl'; # enough ? - -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $netcnx->{type} ||= 'isdn'; # enough ? - $intf->{ppp0} and $netcnx->{type} ||= 'modem'; - $intf->{eth0} and $netcnx->{type} ||= 'lan'; - } -} - -sub easy_dhcp { - my ($netc, $intf) = @_; - - return if text2bool($netc->{NETWORKING}); - - require modules; - require network::ethernet; - modules::load_category('network/main|gigabit|usb'); - my @all_cards = network::ethernet::get_eth_cards(); - - #- only for a single network card - (any { $_->[0] eq 'eth0' } @all_cards) && (every { $_->[0] ne 'eth1' } @all_cards) or return; - - log::explanations("easy_dhcp: found eth0"); - - network::ethernet::conf_network_card_backend($netc, $intf, 'dhcp', 'eth0'); - - put_in_hash($netc, { - NETWORKING => "yes", - DHCP => "yes", - }); - 1; -} - -#- configureNetwork2 : configure the network interfaces. -#- input -#- $prefix -#- $netc -#- $intf -#- $netc input -#- NETWORKING : networking flag : string : "yes" by default -#- FORWARD_IPV4 : forward IP flag : string : "false" by default -#- HOSTNAME : hostname : string : "localhost.localdomain" by default -#- DOMAINNAME : domainname : string : $netc->{HOSTNAME} =~ /\.(.*)/ by default -#- DOMAINNAME2 : well it's another domainname : have to look further why we used 2 -#- The following are facultatives -#- DHCP_HOSTNAME : If you have a dhcp and want to set the hostname -#- GATEWAY : gateway -#- GATEWAYDEV : gateway interface -#- NISDOMAIN : nis domain -#- $netc->{dnsServer} : dns server 1 -#- $netc->{dnsServer2} : dns server 2 -#- $netc->{dnsServer3} : dns server 3 : note that we uses the dns1 for the LAN, and the 2 others for the internet conx -#- $intf input: for each $device (for example ethx) -#- $intf->{$device}{IPADDR} : IP address -#- $intf->{$device}{NETMASK} : netmask -#- $intf->{$device}{DEVICE} : DEVICE = $device -#- $intf->{$device}{BOOTPROTO} : boot prototype : "bootp" or "dhcp" or "pump" or ... -sub configureNetwork2 { - my ($in, $_prefix, $netc, $intf) = @_; - my $etc = "$::prefix/etc"; - if (!$::testing) { - $netc->{wireless_eth} and $in->do_pkgs->ensure_is_installed('wireless-tools', '/sbin/iwconfig', 'auto'); - write_conf("$etc/sysconfig/network", $netc); - write_resolv_conf("$etc/resolv.conf", $netc) if ! $netc->{DHCP}; - write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $netc, $::prefix) foreach grep { $_->{DEVICE} ne 'ppp0' } values %$intf; - add2hosts("$etc/hosts", $netc->{HOSTNAME}, map { $_->{IPADDR} } values %$intf) if $netc->{HOSTNAME} && !$netc->{DHCP}; - add2hosts("$etc/hosts", "localhost", "127.0.0.1"); - - any { $_->{BOOTPROTO} eq "dhcp" } values %$intf and $in->do_pkgs->install($netc->{dhcp_client} || 'dhcp-client'); - if ($netc->{ZEROCONF_HOSTNAME}) { - $in->do_pkgs->ensure_is_installed('tmdns', '/sbin/tmdns', 'auto') if !$in->do_pkgs->is_installed('bind'); - $in->do_pkgs->ensure_is_installed('zcip', '/sbin/zcip', 'auto'); - write_zeroconf("$etc/tmdns.conf", $netc->{ZEROCONF_HOSTNAME}); - } else { run_program::rooted($::prefix, "chkconfig", "--del", $_) foreach qw(tmdns zcip) } # disable zeroconf - any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %$intf and $in->do_pkgs->install('pump'); - } -} - -1; diff --git a/perl-install/network/nfs.pm b/perl-install/network/nfs.pm deleted file mode 100644 index 39faa716e..000000000 --- a/perl-install/network/nfs.pm +++ /dev/null @@ -1,69 +0,0 @@ -package network::nfs; # $Id$ - -use strict; -use diagnostics; - -use common; -use network::network; -use network::smbnfs; -use log; - -our @ISA = 'network::smbnfs'; - -sub to_fstab_entry { - my ($class, $e) = @_; - $class->to_fstab_entry_raw($e, 'nfs'); -} -sub comment_to_string { - my ($_class, $comment) = @_; - member($comment, qw(* 0.0.0.0/0.0.0.0 (everyone))) ? '' : $comment; -} -sub from_dev { - my ($_class, $dev) = @_; - $dev =~ m|(.*?):(.*)|; -} -sub to_dev_raw { - my ($_class, $server, $name) = @_; - $server . ':' . $name; -} - -sub check { - my ($_class, $in) = @_; - $in->do_pkgs->ensure_is_installed('nfs-utils-clients', '/usr/sbin/showmount') or return; - system('/etc/init.d/portmap start') if system('/etc/init.d/portmap status') != 0; - 1; -} - -sub find_servers { - open(my $F2, "rpcinfo-flushed -b mountd 2 |"); - open(my $F3, "rpcinfo-flushed -b mountd 3 |"); - - common::nonblock($F2); - common::nonblock($F3); - my $domain = chomp_(`domainname`); - my ($s, %servers); - my $quit; - while (!$quit) { - $quit = 1; - sleep 1; - while ($s = <$F2> || <$F3>) { - $quit = 0; - my ($ip, $name) = $s =~ /(\S+)\s+(\S+)/ or log::explanations("bad line in rpcinfo output"), next; - $name =~ s/\.$//; - $name =~ s/\Q.$domain\E$//; - $servers{$ip} ||= { ip => $ip, if_($name ne '(unknown)', name => $name) }; - } - } - values %servers; -} - -sub find_exports { - my ($_class, $server) = @_; - - my @l; - run_program::raw({ timeout => 1 }, "showmount", '>', \@l, "--no-headers", "-e", $server->{ip} || $server->{name}); - - map { if_(/(\S+(\s*\S+)*)\s+(\S+)/, { name => $1, comment => $3, server => $server }) } @l; -} - -1; diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm deleted file mode 100644 index 99d5c2b00..000000000 --- a/perl-install/network/shorewall.pm +++ /dev/null @@ -1,164 +0,0 @@ -package network::shorewall; # $Id$ - - - - -use detect_devices; -use network::netconnect; -use run_program; -use common; -use log; - -my @drakgw_ports = qw(domain bootps http https 631 imap pop3 smtp nntp ntp); -# Ports for CUPS (631), LPD/LPRng (515), SMB (137, 138, 139) -my @internal_ports = qw(631 515 137 138 139); - -sub check_iptables { - my ($in) = @_; - - my $existing_config = -f "$::prefix/etc/sysconfig/iptables"; - - $existing_config ||= $::isStandalone && do { - system('modprobe iptable_nat'); - -x '/sbin/iptables' && listlength(`/sbin/iptables -t nat -nL`) > 8; - }; - - !$existing_config || $in->ask_okcancel(N("Firewalling configuration detected!"), - N("Warning! An existing firewalling configuration has been detected. You may need some manual fixes after installation.")); -} - -sub set_config_file { - my ($file, @l) = @_; - - my $done; - substInFile { - if (!$done && (/^#LAST LINE/ || eof)) { - $_ = join('', map { join("\t", @$_) . "\n" } @l) . $_; - $done = 1; - } else { - $_ = '' if /^[^#]/; - } - } "$::prefix/etc/shorewall/$file"; -} - -sub get_config_file { - my ($file) = @_; - map { [ split ' ' ] } grep { !/^#/ } cat_("$::prefix/etc/shorewall/$file"); -} - -sub default_interfaces_silent { - my ($_in) = @_; - my %conf; - my @l = detect_devices::getNet() or return; - if (@l == 1) { - $conf{net_interface} = $l[0]; - } else { - $conf{net_interface} = network::netconnect::get_net_device() || $l[0]; - $conf{loc_interface} = [ grep { $_ ne $conf{net_interface} } @l ]; - } - \%conf; -} - -sub default_interfaces { - my ($in) = @_; - my %conf; - my $card_netconnect = network::netconnect::get_net_device() || "eth0"; - defined $card_netconnect and log::l("[drakgw] Information from netconnect: ignore card $card_netconnect"); - - my @l = detect_devices::getNet() or return; - $in->ask_from('', - N("Please enter the name of the interface connected to the internet. - -Examples: - ppp+ for modem or DSL connections, - eth0, or eth1 for cable connection, - ippp+ for a isdn connection. -"), - [ { label => N("Net Device"), val => \$card_netconnect, list => \@l } ]); - $conf{net_interface} = $card_netconnect; - #$conf{net_interface} = network::netconnect::get_net_device() || $l[0]; - $conf{loc_interface} = [ grep { $_ ne $conf{net_interface} } @l ]; - \%conf; -} - -sub read { - my ($in, $mode) = @_; - my %conf = (disabled => !glob_("$::prefix/etc/rc3.d/S*shorewall"), - ports => join(' ', map { - my $e = $_; - map { "$_/$e->[3]" } split(',', $e->[4]); - } grep { $_->[0] eq 'ACCEPT' && $_->[1] eq 'net' } get_config_file('rules')) - ); - - if (my ($e) = get_config_file('masq')) { - $conf{masquerade}{subnet} = $e->[1] if $e->[1]; - } - if ($mode eq 'silent') { - put_in_hash(\%conf, default_interfaces_silent($in)); - } else { - put_in_hash(\%conf, default_interfaces($in)); - }; - foreach (get_config_file('interfaces')) { - my ($name, $interface) = @$_; - if ($name eq 'masq') { - $conf{masquerade}{interface} = $interface; - $conf{loc_interface} = [ difference2($conf{loc_interface}, [$interface]) ]; - } - } - $conf{net_interface} && \%conf; -} - -sub write { - my ($conf) = @_; - my $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up"; - - my %ports_by_proto; - foreach (split ' ', $conf->{ports}) { - m!^(\d+)/(udp|tcp|icmp)$! or die "bad port $_\n"; - push @{$ports_by_proto{$2}}, $1; - } - - set_config_file("zones", - [ 'net', 'Net', 'Internet zone' ], - if_($conf->{masquerade}, [ 'masq', 'Masquerade', 'Masquerade Local' ]), - if_($conf->{loc_interface}, [ 'loc', 'Local', 'Local' ]), - ); - set_config_file('interfaces', - [ 'net', $conf->{net_interface}, 'detect' ], - $conf->{masquerade} ? [ 'masq', $conf->{masquerade}{interface}, 'detect' ] : (), - (map { [ 'loc', $_, 'detect' ] } @{$conf->{loc_interface} || []}), - ); - set_config_file('policy', - if_($conf->{masquerade}, [ 'masq', 'net', 'ACCEPT' ]), - if_($conf->{loc_interface}, [ 'loc', 'net', 'ACCEPT' ]), - [ 'fw', 'net', 'ACCEPT' ], - [ 'net', 'all', 'DROP', 'info' ], - [ 'all', 'all', 'REJECT', 'info' ], - ); - set_config_file('rules', - if_(cat_("$::prefix$connect_file") =~ /pptp/, [ 'ACCEPT', 'fw', 'loc:10.0.0.138', 'tcp', '1723' ]), - if_(cat_("$::prefix$connect_file") =~ /pptp/, [ 'ACCEPT', 'fw', 'loc:10.0.0.138', 'gre' ]), - (map { - map_each { [ 'ACCEPT', $_, 'fw', $::a, join(',', @$::b), '-' ] } %ports_by_proto - } ('net', if_($conf->{masquerade}, 'masq'), if_($conf->{loc_interface}, 'loc'))), - if_($conf->{masquerade}, map { [ 'ACCEPT', 'masq', 'fw', $_, join(',', @drakgw_ports), '-' ] } 'tcp', 'udp'), - if_($conf->{masquerade}, map { [ 'ACCEPT', 'fw', 'masq', $_, join(',', @internal_ports), '-' ] } 'tcp', 'udp'), - ); - set_config_file('masq', - $conf->{masquerade} ? [ $conf->{net_interface}, $conf->{masquerade}{subnet} ] : (), - ); - system('uniq /etc/shorewall/masq > /etc/shorewall/masq.uniq'); - rename("/etc/shorewall/masq.uniq", "/etc/shorewall/masq"); - - if ($conf->{disabled}) { - run_program::rooted($::prefix, 'chkconfig', '--del', 'shorewall'); - run_program::run('service', '>', '/dev/null', 'shorewall', 'stop') if $::isStandalone; - run_program::run('service', '>', '/dev/null', 'shorewall', 'clear') if $::isStandalone; - } else { - run_program::rooted($::prefix, 'chkconfig', '--add', 'shorewall'); - run_program::run('service', '>', '/dev/null', 'shorewall', 'restart') if $::isStandalone; - } -} - -1; - diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm deleted file mode 100644 index 941463c65..000000000 --- a/perl-install/network/smb.pm +++ /dev/null @@ -1,181 +0,0 @@ -package network::smb; # $Id$ - -use strict; -use diagnostics; - -use common; -use fs; -use network::network; -use network::smbnfs; - - -our @ISA = 'network::smbnfs'; - -sub to_fstab_entry { - my ($class, $e) = @_; - my $part = $class->to_fstab_entry_raw($e, 'smbfs'); - if ($e->{server}{username}) { - my ($options, $unknown) = fs::mount_options_unpack($part); - $options->{"$_="} = $e->{server}{$_} foreach qw(username password domain); - fs::mount_options_pack($part, $options, $unknown); - } - $part; -} -sub from_dev { - my ($_class, $dev) = @_; - $dev =~ m|//(.*?)/(.*)|; -} -sub to_dev_raw { - my ($_class, $server, $name) = @_; - '//' . $server . '/' . $name; -} - -sub check { - my ($_class, $in) = @_; - $in->do_pkgs->ensure_is_installed('samba-client', '/usr/bin/nmblookup'); -} - -sub smbclient { - my ($server) = @_; - my $name = $server->{name} || $server->{ip}; - my $ip = $server->{ip} ? "-I $server->{ip}" : ''; - my $group = $server->{group} ? " -W $server->{group}" : ''; - - my $U = $server->{username} ? sprintf("%s/%s%%%s", @$server{'domain', 'username', 'password'}) : '%'; - `smbclient -U $U -L $name $ip$group`; -} - -sub find_servers { - my (undef, @l) = `nmblookup "*"`; - s/\s.*\n// foreach @l; - my @servers = grep { network::network::is_ip($_) } @l; - my %servers; - $servers{$_}{ip} = $_ foreach @servers; - my ($ip, $browse); - foreach (`nmblookup -A @servers`) { - my $nb = /^Looking up status of (\S+)/ .. /^$/ or next; - if ($nb == 1) { - $ip = $1; - } elsif (/<00>/) { - $servers{$ip}{/<GROUP>/ ? 'group' : 'name'} ||= lc first(/(\S+)/); - } elsif (/__MSBROWSE__/) { - $browse ||= $servers{$ip}; - } - } - if ($browse) { - my %l; - foreach (smbclient($browse)) { - my $nb = /^\s*Workgroup/ .. /^$/; - $nb > 2 or next; - my ($group, $name) = split(' ', lc($_)); - - # already done - next if any { $group eq $_->{group} } values %servers; - - $l{$name} = $group; - } - if (my @l = keys %l) { - foreach (`nmblookup @l`) { - $servers{$1} = { name => $2, group => $l{$2} } if /(\S+)\s+([^<]+)<00>/; - } - } - } - values %servers; -} - -sub find_exports { - my ($_class, $server) = @_; - my @l; - - foreach (smbclient($server)) { - chomp; - s/^\t//; - /NT_STATUS_/ and die $_; - my ($name, $type, $comment) = unpack "A15 A10 A*", $_; - if (($name eq '---------' && $type eq '----' && $comment eq '-------') .. /^$/) { - push @l, { name => $name, type => $type, comment => $comment, server => $server } - if $type eq 'Disk' && $name !~ /\$$/ && $name !~ /NETLOGON|SYSVOL/; - } - } - @l; -} - -sub authentications_available { - my ($server) = @_; - map { if_(/^auth.\Q$server->{name}.\E(.*)/, $1) } all("/etc/samba"); -} - -sub to_credentials { - my ($server_name, $username) = @_; - $username or die 'to_credentials'; - "/etc/samba/auth.$server_name.$username"; -} - -sub fstab_entry_to_credentials { - my ($part) = @_; - - my ($server_name) = network::smb->from_dev($part->{device}) or return; - - my ($options, $unknown) = fs::mount_options_unpack($part); - $options->{'username='} && $options->{'password='} or return; - my %h = map { $_ => delete $options->{"$_="} } qw(username domain password); - $h{file} = $options->{'credentials='} = to_credentials($server_name, $h{username}); - fs::mount_options_pack_($part, $options, $unknown), \%h; -} - -sub remove_bad_credentials { - my ($server) = @_; - unlink to_credentials($server->{name}, $server->{username}); -} - -sub save_credentials { - my ($credentials) = @_; - my $file = $credentials->{file}; - output_with_perm("$::prefix$file", 0640, map { "$_ = $credentials->{$_}\n" } qw(username domain password)); -} - - -sub read_credentials_raw { - my ($file) = @_; - my %h = map { /(.*?)\s*=\s*(.*)/ } cat_("$::prefix$file"); - \%h; -} - -sub read_credentials { - my ($server, $username) = @_; - put_in_hash($server, read_credentials_raw(to_credentials($server->{name}, $username))); -} - - -sub write_smb_conf { - my ($domain) = @_; - - #- was going to just have a canned config in samba-winbind - #- and replace the domain, but sylvestre/buchan didn't bless it yet - - my $f = "$::prefix/etc/samba/smb.conf"; - rename $f, "$f.orig"; - output($f, " -[global] - workgroup = $domain - server string = Samba Server %v - security = domain - encrypt passwords = Yes - password server = * - log file = /var/log/samba/log.%m - max log size = 50 - socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 - character set = ISO8859-15 - os level = 18 - local master = No - dns proxy = No - winbind uid = 10000-20000 - winbind gid = 10000-20000 - winbind separator = + - template homedir = /home/%D/%U - template shell = /bin/bash - winbind use default domain = yes -"); -} - -1; diff --git a/perl-install/network/smbnfs.pm b/perl-install/network/smbnfs.pm deleted file mode 100644 index 97f2bd6e6..000000000 --- a/perl-install/network/smbnfs.pm +++ /dev/null @@ -1,45 +0,0 @@ -package network::smbnfs; # $Id$ - -use strict; -use diagnostics; - -use fs; - - -sub new { - my ($class, $o_v) = @_; - bless($o_v || {}, $class); -} - -sub server_to_string { - my ($_class, $server) = @_; - $server->{name} || $server->{ip}; -} -sub comment_to_string { - my ($_class, $comment) = @_; - $comment; -} -sub to_dev { - my ($class, $e) = @_; - $class->to_dev_raw($class->server_to_string($e->{server}), $e->{name} || $e->{ip}); -} -sub to_string { - my ($class, $e) = @_; - my $comment = $class->comment_to_string($e->{comment}); - ($e->{name} || $e->{ip}) . ($comment ? " ($comment)" : ''); -} - -sub to_fullstring { - my ($class, $e) = @_; - my $comment = $class->comment_to_string($e->{comment}); - $class->to_dev($e) . ($comment ? " ($comment)" : ''); -} -sub to_fstab_entry_raw { - my ($class, $e, $type) = @_; - my $fs_entry = { device => $class->to_dev($e), type => $type }; - fs::set_default_options($fs_entry); - $fs_entry; -} - -1; - diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm deleted file mode 100644 index e10518d78..000000000 --- a/perl-install/network/tools.pm +++ /dev/null @@ -1,226 +0,0 @@ -package network::tools; # $Id$ - -use strict; -use common; -use run_program; -use c; -use vars qw(@ISA @EXPORT @EXPORT_OK); -use MDK::Common::System qw(getVarsFromSh); - -@ISA = qw(Exporter); -@EXPORT = qw(connect_backend connected connected_bg disconnect_backend is_dynamic_ip passwd_by_login read_providers_backend read_secret_backend set_cnx_script test_connected write_cnx_script write_initscript write_secret_backend); - -our $connect_prog = "/etc/sysconfig/network-scripts/net_cnx_pg"; -my $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up"; -my $disconnect_file = "/etc/sysconfig/network-scripts/net_cnx_down"; - -sub set_cnx_script { - my ($netc, $type, $up, $down, $type2) = @_; - $netc->{internet_cnx}{$type}{$_->[0]} = $_->[1] foreach [$connect_file, $up], [$disconnect_file, $down]; - $netc->{internet_cnx}{$type}{type} = $type2; -} -sub write_cnx_script { - my ($netc) = @_; - foreach ($connect_file, $disconnect_file) { - output_with_perm("$::prefix$_", 0755, - '#!/bin/bash -' . if_(!$netc->{at_boot}, 'if [ "x$1" == "x--boot_time" ]; then exit; fi -') . $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{$_}); - } -} - -sub write_secret_backend { - my ($a, $b) = @_; - foreach my $i ("$::prefix/etc/ppp/pap-secrets", "$::prefix/etc/ppp/chap-secrets") { - substInFile { s/^'$a'.*\n//; $_ .= "\n'$a' * '$b' * \n" if eof } $i; - #- restore access right to secrets file, just in case. - chmod 0600, $i; - } -} - -sub unquotify { - my ($word) = @_; - $$word =~ s/^(['"]?)(.*)\1$/$2/; -} - -sub read_secret_backend() { - my $conf = []; - foreach my $i ("pap-secrets", "chap-secrets") { - foreach (cat_("$::prefix/etc/ppp/$i")) { - my ($login, $server, $passwd) = split(' '); - if ($login && $passwd) { - unquotify \$passwd; - unquotify \$login; - unquotify \$server; - push @$conf, {login => $login, - passwd => $passwd, - server => $server }; - } - } - } - $conf; -} - -sub passwd_by_login { - my ($login) = @_; - - unquotify \$login; - my $secret = read_secret_backend(); - foreach (@$secret) { - return $_->{passwd} if $_->{login} eq $login; - } -} - -sub connect_backend() { run_program::rooted($::prefix, "$connect_file &") } - -sub disconnect_backend() { run_program::rooted($::prefix, "$disconnect_file &") } - -sub read_providers_backend { my ($file) = @_; map { /(.*?)=>/ } catMaybeCompressed($file) } - -sub connected() { gethostbyname("mandrakesoft.com") ? 1 : 0 } - -# request a ref on a bg_connect and a ref on a scalar -sub connected_bg__raw { - my ($kid_pipe, $status) = @_; - local $| = 1; - if (ref($kid_pipe) && ref($$kid_pipe)) { - my $fd = $$kid_pipe->{fd}; - fcntl($fd, c::F_SETFL(), c::O_NONBLOCK()) or die "can't fcntl F_SETFL: $!"; - my $a = <$fd>; - $$status = $a if defined $a; - } else { $$kid_pipe = check_link_beat() } -} - -my $kid_pipe; -sub connected_bg { - my ($status) = @_; - connected_bg__raw(\$kid_pipe, $status); -} - -# test if connected; -# cmd = 0 : ask current status -# return : 0 : not connected; 1 : connected; -1 : no test ever done; -2 : test in progress -# cmd = 1 : start new connection test -# return : -2 -# cmd = 2 : cancel current test -# return : nothing -# cmd = 3 : return current status even if a test is in progress -my $kid_pipe_connect; -my $current_connection_status; - -sub test_connected { - local $| = 1; - my ($cmd) = @_; - - $current_connection_status = -1 if !defined $current_connection_status; - - if ($cmd == 0) { - connected_bg__raw(\$kid_pipe_connect, \$current_connection_status); - } elsif ($cmd == 1) { - if ($current_connection_status != -2) { - $current_connection_status = -2; - $kid_pipe_connect = check_link_beat(); - } - } elsif ($cmd == 2) { - if (defined($kid_pipe_connect)) { - kill -9, $kid_pipe_connect->{pid}; - undef $kid_pipe_connect; - } - } - return $current_connection_status; -} - -sub check_link_beat() { - bg_command->new(sub { - require Net::Ping; - print Net::Ping->new("icmp")->ping("mandrakesoft.com") ? 1 : 0; - }); -} - -sub write_initscript() { - $::testing and return; - output_with_perm("$::prefix/etc/rc.d/init.d/internet", 0755, - sprintf(<<'EOF', $connect_file, $connect_file, $disconnect_file, $disconnect_file)); -#!/bin/bash -# -# internet Bring up/down internet connection -# -# chkconfig: 2345 11 89 -# description: Activates/Deactivates the internet interfaces -# -# dam's (damien@mandrakesoft.com) - -# Source function library. -. /etc/rc.d/init.d/functions - - case "$1" in - start) - if [ -e %s ]; then - action "Checking internet connections to start at boot" "%s --boot_time" - else - action "No connection to start" "true" - fi - touch /var/lock/subsys/internet - ;; - stop) - if [ -e %s ]; then - action "Stopping internet connection if needed: " "%s --boot_time" - else - action "No connection to stop" "true" - fi - rm -f /var/lock/subsys/internet - ;; - restart) - $0 stop - echo "Waiting 10 sec before restarting the internet connection." - sleep 10 - $0 start - ;; - status) - ;; - *) - echo "Usage: internet {start|stop|status|restart}" - exit 1 -esac -exit 0 -EOF - $::isStandalone ? system("/sbin/chkconfig --add internet") : do { - symlinkf("../init.d/internet", "$::prefix/etc/rc.d/rc$_") foreach - '0.d/K11internet', '1.d/K11internet', '2.d/K11internet', '3.d/S89internet', '5.d/S89internet', '6.d/K11internet'; - }; -} - -sub use_windows() { - my $all_hds = fsedit::get_hds({}, undef); - fs::get_info_from_fstab($all_hds, ''); - my $part = find { $_->{device_windobe} eq 'C' } fsedit::get_fstab(@{$all_hds->{hds}}); - $part or my $failed = N("No partition available"); - my $source = -d "$part->{mntpoint}/windows/" ? "$part->{mntpoint}/windows/system" : "$part->{mntpoint}/winnt/system"; - log::explanations($failed || "Seek in $source to find firmware"); - - return $source, $failed; -} - -sub use_floppy { - my ($in, $file) = @_; - my $floppy = detect_devices::floppy(); - $in->ask_okcancel(N("Insert floppy"), - N("Insert a FAT formatted floppy in drive %s with %s in root directory and press %s", $floppy, $file, N("Next"))) or return; - eval { fs::mount(devices::make($floppy), '/mnt', 'vfat', 'readonly'); 1 } or my $failed = N("Floppy access error, unable to mount device %s", $floppy); - log::explanations($failed || "Mounting floppy device $floppy in /mnt"); - - return '/mnt', $failed; -} - - -sub is_dynamic_ip { - my ($intf) = @_; - any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %$intf; -} - -sub is_dynamic_host { - my ($intf) = @_; - any { defined $_->{DHCP_HOSTNAME} } values %$intf; -} - -1; |