diff options
Diffstat (limited to 'perl-install/network')
| -rw-r--r-- | perl-install/network/adsl.pm | 327 | ||||
| -rw-r--r-- | perl-install/network/adsl_consts.pm | 400 | ||||
| -rw-r--r-- | perl-install/network/drakfirewall.pm | 208 | ||||
| -rw-r--r-- | perl-install/network/ethernet.pm | 142 | ||||
| -rw-r--r-- | perl-install/network/ipsec.pm | 801 | ||||
| -rw-r--r-- | perl-install/network/isdn.pm | 158 | ||||
| -rw-r--r-- | perl-install/network/isdn_consts.pm | 339 | ||||
| -rw-r--r-- | perl-install/network/modem.pm | 213 | ||||
| -rw-r--r-- | perl-install/network/netconnect.pm | 1464 | ||||
| -rw-r--r-- | perl-install/network/network.pm | 430 | ||||
| -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 | 217 | ||||
| -rw-r--r-- | perl-install/network/smbnfs.pm | 45 | ||||
| -rw-r--r-- | perl-install/network/tools.pm | 211 |
15 files changed, 0 insertions, 5188 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm deleted file mode 100644 index 9e1e4fecb..000000000 --- a/perl-install/network/adsl.pm +++ /dev/null @@ -1,327 +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, $o_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/ppp0 /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); - if (!$netc->{vpi} && !$netc->{vpi} && member($o_adsl_modem, qw(eci speedtouch))) { - ($netc->{vpi}, $netc->{vci}) = - (map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, map { sprintf("%x", $_) } $1, $2) } cat_("$::prefix/etc/ppp/peers/ppp0")); - } - $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->{bewan}) = detect_devices::getBewan(); - ($adsl->{speedtouch}) = detect_devices::getSpeedtouch(); - ($adsl->{sagem}) = detect_devices::getSagem(); - ($adsl->{eci}) = detect_devices::getECI(); - return $adsl; -} - -sub adsl_conf_backend { - my ($in, $modules_conf, $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"; - $adsl_type eq 'pptp' and $adsl_device = 'pptp_modem'; - my $bewan_module; - $bewan_module = $o_netcnx->{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $adsl_device eq "bewan"; - - # all supported modems came with their own pppoa module, so no need for "plugin pppoatm.so" - my %modems = ( - bewan => { - start => qq( -modprobe pppoatm -# ActivationMode=1 -modprobe $bewan_module -# wait for the modem to be set up: -sleep 10 -), - stop => qq(modprobe -r $bewan_module), - plugin => { - pppoa => "pppoatm.so $netc->{vpi}." . hex($netc->{vci}) - }, - ppp_options => qq( -lock -ipparam ppp0 -default-asyncmap -hide-password -noaccomp -nobsdcomp -nodeflate -novj novjccomp -lcp-echo-interval 20 -lcp-echo-failure 3 -mtu 1200 -mru 1200 -sync -), - }, - - speedtouch => - { - start => qq( -modprobe speedtch -/usr/bin/speedtouch-start -), - overide_script => 1, - server => { - pppoa => qq("/usr/sbin/pppoa3 -c") - }, - plugin => { - pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci})), - }, - ppp_options => qq( -sync -noaccomp), - aliases => [ - ['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 => qq( -modprobe eagle-usb -/usr/sbin/eaglectrl -d -), - stop => "/usr/bin/killall pppoa", - get_intf => "/usr/sbin/eaglectrl -i", - server => { - pppoa => qq("/usr/sbin/pppoa -I `/usr/sbin/fctStartAdsl -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) - }, - pptp_modem => - { - server => { - pptp => qq("/usr/sbin/pptp 10.0.0.138 --nolaunchpppd"), - }, - }, - ); - - - if ($adsl_type =~ /^pp/) { - mkdir_p("$::prefix/etc/ppp"); - $in->do_pkgs->install('ppp') if !$>; - my %packages = ( - pppoa => [ qw(ppp-pppoatm) ], - pppoe => [ qw(ppp-pppoe rp-pppoe) ], - pptp => [ qw(pptp-linux) ], - ); - $in->do_pkgs->install(@{$packages{$adsl_type}}) if !$>; - output("$::prefix/etc/ppp/options", - $adsl_device eq "bewan" ? - qq(lock -ipparam ppp0 -noipdefault -noauth -default-asyncmap -defaultroute -hide-password -noaccomp -noccp -nobsdcomp -nodeflate -nopcomp -novj novjccomp -lcp-echo-interval 20 -lcp-echo-failure 3 -mtu 1200 -mru 1200 -sync -persist -user $adsl->{login} -name $adsl->{login} -usepeerdns -) - : - qq(lock -noipdefault -persist -noauth -usepeerdns -defaultroute) - ); - - my $pty_option = $modems{$adsl_device}{server}{$adsl_type} && "pty $modems{$adsl_device}{server}{$adsl_type}"; - my $plugin = $modems{$adsl_device}{plugin}{$adsl_type} && "plugin $modems{$adsl_device}{plugin}{$adsl_type}"; - output("$::prefix/etc/ppp/peers/ppp0", -qq(noauth -noipdefault -$modems{$adsl_device}{ppp_options} -kdebug 1 -nopcomp -noccp -novj -holdoff 4 -maxfail 25 -persist -usepeerdns -defaultroute -$pty_option -$plugin -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"; - } - -# 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", -# disconnect => qq(/usr/sbin/adsl-stop -# /usr/bin/killall pppoe pppd\n), -# }, - - } - - #- FIXME: - #- ppp0 and ippp0 are hardcoded - my $kind = $adsl_type eq 'pppoe' ? 'xDSL' : 'ADSL'; - output_with_perm("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0", 0705, qq(DEVICE=ppp0 -ONBOOT=no -TYPE=$kind -)); - - # 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 - foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) { - substInFile { - s/VCI=.*\n/VCI=$l{vci}\n/; - s/VPI=.*\n/VPI=$l{vpi}\n/; - s/Encapsulation=.*\n/Encapsulation=$l{Encapsulation}\n/; - } "$::prefix$cfg_file"; - } - } - - # set aliases: - if (exists $modems{$adsl_device}{aliases}) { - $modules_conf->set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}}; - $::isStandalone and $modules_conf->write; - } - - $netc->{NET_INTERFACE} = 'ppp0'; - write_cnx_script($netc); - - $::isInstall && $modems{$adsl_device}{start} and run_program::rooted($::prefix, $modems{$adsl_device}{start}); -} - -1; diff --git a/perl-install/network/adsl_consts.pm b/perl-install/network/adsl_consts.pm deleted file mode 100644 index ee81efbf4..000000000 --- a/perl-install/network/adsl_consts.pm +++ /dev/null @@ -1,400 +0,0 @@ -package network::adsl_consts; # $Id$ - -# This should probably be splitted out into ldetect-lst as some provider db - -use vars qw(@ISA @EXPORT); -use common; - -@ISA = qw(Exporter); -@EXPORT = qw(@adsl_data); - -# From: -# http://www.eagle-usb.org/article.php3?id_article=23 -# 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, ... } - # Encapsulation: - # 1=PPPoE LLC, 2=PPPoE VCmux (never used ?) - # 3=RFC1483/2684 Routed IP LLC, - # 4=RFC1483/2684 Routed IP (IPoA VCmux) - # 5 RFC2364 PPPoA LLC, - # 6 RFC2364 PPPoA VCmux - # dns are provided for when !usepeerdns in peers config file - # method : pppoa, pppoe or static - # please forward updates to http://forum.eagle-usb.org - # order alphabetically by country (in English) / ISP (local language) - N("Austria") . "|Any" => - { - vpi => 8, - vci => 30, - Encapsulation => 6, - method => 'pppoa', - }, - - N("Austria") . "|Telstra" => - { - vpi => 8, - vci => 23, - Encapsulation => 1, - }, - - N("Belgium") . "|ADSL Office" => - { - vpi => 8, - vci => 23, - Encapsulation => 3, - }, - - N("Belgium") . "|Tiscali BE" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - method => 'pppoa', - dnsServer2 => '212.35.2.1', - dnsServer3 => '212.35.2.2', - DOMAINNAME2 => 'tiscali.be', - }, - - N("Belgium") . "|Belgacom" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - method => 'pppoa', - }, - - N("Belgium") . "|Turboline" => - { - vpi => 8, - vci => 23, - Encapsulation => 5, - }, - - N("Brazil") . "|Speedy/Telefonica" => - { - vpi => 8, - vci => 23, - Encapsulation => 1, - method => 'pppoe', - dnsServer2 => '200.204.0.10', - dnsServer3 => '200.204.0.138', - }, - - N("Brazil") . "|Velox/Telemar" => - { - vpi => 0, - vci => 33, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Brazil") . "|Turbo/Brasil Telecom" => - { - vpi => 0, - vci => 23, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Brazil") . "|Rio Grande do Sul (RS)" => - { - vpi => 1, - vci => 20, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Bulgaria") . "|BTK ISDN" => - { - vpi => 1, - vci => 20, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Bulgaria") . "|BTK POTS" => - { - vpi => 0, - vci => 23, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Denmark") . "|Any" => - { - vpi => 0, - vci => 65, - Encapsulation => 3, - }, - - N("France") . "|Free non dégroupé 512/128 & 1024/128" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '213.228.0.23', - dnsServer3 => '212.27.32.176', - method => 'pppoa', - DOMAINNAME2 => 'free.fr', - }, - - N("France") . "|Free dégroupé 1024/256 (mini)" => - { - vpi => 8, - vci => 24, - Encapsulation => 4, - dnsServer2 => '213.228.0.23', - dnsServer3 => '212.27.32.176', - DOMAINNAME2 => 'free.fr', - }, - - N("France") . "|n9uf tel9com 512 & dégroupé 1024" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '212.30.93.108', - dnsServer3 => '212.203.124.146', - method => 'pppoa', - }, - - N("France") . "|Cegetel non dégroupé 512 IP/ADSL et dégroupé" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '212.94.174.85', - dnsServer3 => '212.94.174.86', - 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 => '80.10.246.2', - dnsServer3 => '80.10.246.129', - 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, - Encapsulation => 6, - dnsServer2 => '213.36.80.1', - dnsServer3 => '213.36.80.2', - method => 'pppoa', - }, - - N("Finland") . "|Sonera" => - { - vpi => 0, - vci => 64, - Encapsulation => 3, - method => 'pppoe', - }, - - 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("Greece") . "|Any" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - method => 'pppoa', - }, - - N("Hungary") . "|Matav" => - { - vpi => 1, - vci => 20, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Ireland") . "|Any" => - { - vpi => 8, - vci => 23, - Encapsulation => 1, - method => 'pppoe', - }, - - N("Italy") . "|Telecom Italia" => - { - vpi => 8, - vci => 23, - Encapsulation => 6, - dnsServer2 => '195.20.224.234', - dnsServer3 => '194.25.2.129', - method => 'pppoa', - }, - - N("Italy") . "|Telecom Italia/Office Users (ADSL Smart X)" => - { - vpi => 8, - vci => 23, - Encapsulation => 3, - }, - - 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, - method => 'pppoa', - }, - - 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, - Encapsulation => 1, - }, - - 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") . "|Telefónica 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 Retevision" => - { - 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 => 3, - }, - - N("Switzerland") . "|Any" => - { - vpi => 8, - vci => 23, - Encapsulation => 3, - }, - - N("Switzerland") . "|BlueWin / Swisscom" => - { - vpi => 8, - vci => 23, - Encapsulation => 5, - dnsServer2 => '195.186.4.108', - dnsServer3 => '195.186.4.109', - method => 'pppoa', - }, - - N("United Kingdom") . "|Tiscali UK " => - { - vpi => 0, - vci => 26, - Encapsulation => 6, - method => 'pppoa', - }, - - N("United Kingdom") . "|British Telecom " => - { - vpi => 0, - vci => 26, - Encapsulation => 6, - method => 'pppoa', - }, - ); - - -1; diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm deleted file mode 100644 index 6fe4a629c..000000000 --- a/perl-install/network/drakfirewall.pm +++ /dev/null @@ -1,208 +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 1024-1100/tcp 1024-1100/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, - }, - { - name => N_("BitTorrent"), - ports => '6881:6999/tcp', - hide => 1, - pkg => 'bittorrent bittorrent-shadowsclient', - }, -); - -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_binary_is_installed('shorewall', '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 Mandrakelinux 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 600:610/tcp 600:610/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 a93d66c77..000000000 --- a/perl-install/network/ethernet.pm +++ /dev/null @@ -1,142 +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); - -sub write_ether_conf { - my ($in, $modules_conf, $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_conf->write; - 1; -} - - -sub mapIntfToDevice { - my ($interface) = @_; - my $hw_addr = c::getHwIDs($interface); - my ($bus, $slot, $func) = map { hex($_) } ($hw_addr =~ /([0-9a-f]+):([0-9a-f]+)\.([0-9a-f]+)/); - $hw_addr && (every { defined $_ } $bus, $slot, $func) ? - grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot && $_->{pci_function} == $func } 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 ($modules_conf) = @_; - my @all_cards = detect_devices::getNet(); - - my @devs = detect_devices::pcmcia_probe(); - my $saved_driver; - return map { - my $interface = $_; - my $description; - my $a = c::getNetDriver($interface) || $modules_conf->get_alias($interface); - if (my $b = find { $_->{device} eq $interface } @devs) { # PCMCIA case - $a = $b->{driver}; - $description = $b->{description}; - } else { - ($description) = (mapIntfToDevice($interface))[0]->{description}; - } - if (!$description) { - my $drv = readlink("/sys/class/net/$interface/driver"); - if ($drv && $drv =~ s!.*/!!) { - $a = $drv; - my %l; - my %sysfs_fields = (id => "device", subid => "subsystem_device", vendor => "vendor", subvendor => "subsystem_vendor"); - $l{$_} = hex(chomp_(cat_("/sys/class/net/$interface/device/" . $sysfs_fields{$_}))) foreach keys %sysfs_fields; - my @cards = grep { my $dev = $_; every { $dev->{$_} eq $l{$_} } keys %l } detect_devices::probeall(); - $description = $cards[0]{description} if @cards == 1; - } - } - if (!$description) { - my @cards = grep { $_->{driver} eq ($a || $saved_driver) } detect_devices::probeall(); - $description = $cards[0]{description} if @cards == 1; - } - $a and $saved_driver = $a; # handle multiple cards managed by the same driver - [ $interface, $saved_driver, if_($description, $description) ] - } @all_cards; -} - -sub get_eth_cards_names { - my ($modules_conf, @all_cards) = @_; - - foreach my $card (@all_cards) { - $modules_conf->remove_alias($card->[1]); - $modules_conf->set_alias($card->[0], $card->[1]); - } - - { map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards }; -} - - -#- conf_network_card_backend : configure the specified network 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. -#- input -#- $netc -#- $intf -#- $type : type of interface, must be given if $interface is : string : "static" or "dhcp" -#- $interface : set this interface and return it in a proper form. -#- $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. -#- $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 : returned passed interface name -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 { - my ($modules_conf) = @_; - foreach (detect_devices::getNet()) { - my $driver = c::getNetDriver($_) or next; - $modules_conf->set_alias($_, $driver); - } -} - -1; diff --git a/perl-install/network/ipsec.pm b/perl-install/network/ipsec.pm deleted file mode 100644 index bc6706c50..000000000 --- a/perl-install/network/ipsec.pm +++ /dev/null @@ -1,801 +0,0 @@ -package network::ipsec; - - - -use detect_devices; -use network::netconnect; -use run_program; -use common; -use log; -use Data::Dumper; - -#- debugg functions ---------- -sub recreate_ipsec_conf { - my ($ipsec, $kernel_version) = @_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - print "$ipsec->{$key1}\n" if ! $ipsec->{$key1}{1}; - foreach my $key2 (ikeys %{$ipsec->{$key1}}) { - if ($ipsec->{$key1}{$key2}[0] =~ m/^#/) { - print "\t$ipsec->{$key1}{$key2}[0]\n"; - } elsif ($ipsec->{$key1}{$key2}[0] =~ m/(conn|config|version)/) { - print "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; - } else { - print "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; - } - } - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (! $ipsec->{$key1}{command}) { - print "$ipsec->{$key1}\n"; - } else { - print $ipsec->{$key1}{command} . " " . - $ipsec->{$key1}{src_range} . " " . - $ipsec->{$key1}{dst_range} . " " . - $ipsec->{$key1}{upperspec} . " " . - $ipsec->{$key1}{flag} . " " . - $ipsec->{$key1}{direction} . " " . - $ipsec->{$key1}{ipsec} . "\n\t" . - $ipsec->{$key1}{protocol} . "/" . - $ipsec->{$key1}{mode} . "/" . - $ipsec->{$key1}{src_dest} . "/" . - $ipsec->{$key1}{level} . ";\n" - }; - } - } -} - -sub recreate_racoon_conf { - my ($racoon) = @_; - my $in_a_section = "n"; - my $in_a_proposal_section = "n"; - foreach my $key1 (ikeys %$racoon) { - if ($in_a_proposal_section eq "y") { - print "\t}\n}\n$racoon->{$key1}\n" if ! $racoon->{$key1}{1}; - } elsif ($in_a_section eq "y") { - print "}\n$racoon->{$key1}\n" if ! $racoon->{$key1}{1}; - } else { - print "$racoon->{$key1}\n" if ! $racoon->{$key1}{1}; - }; - $in_a_section = "n"; - $in_a_proposal_section = "n"; - foreach my $key2 (ikeys %{$racoon->{$key1}}) { - if ($racoon->{$key1}{$key2}[0] =~ /^path/) { - print "$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1] $racoon->{$key1}{$key2}[2];\n"; - } elsif ($racoon->{$key1}{$key2}[0] =~ /^remote/) { - $in_a_section = "y"; - $in_a_proposal_section = "n"; - print "$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1] {\n"; - } elsif ($racoon->{$key1}{$key2}[0] =~ /^sainfo/) { - $in_a_section = "y"; - $in_a_proposal_section = "n"; - if ($racoon->{$key1}{$key2}[2] && $racoon->{$key1}{$key2}[5]) { - print "$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1] $racoon->{$key1}{$key2}[2] $racoon->{$key1}{$key2}[3] $racoon->{$key1}{$key2}[4] $racoon->{$key1}{$key2}[5] $racoon->{$key1}{$key2}[6] {\n"; - } else { - print "$racoon->{$key1}{$key2}[0] anonymous {\n"; - } - } elsif ($racoon->{$key1}{$key2}[0] =~ /^proposal /) { - $in_a_proposal_section = "y"; - print "\t$racoon->{$key1}{$key2}[0] {\n"; - } elsif ($in_a_section eq "y" && $racoon->{$key1}{$key2}[0] =~ /^certificate_type/) { - print "\t$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1] $racoon->{$key1}{$key2}[2] $racoon->{$key1}{$key2}[3];\n"; - } elsif ($in_a_section eq "y" && $racoon->{$key1}{$key2}[0] =~ /^#/) { - print "\t$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1]\n"; - } elsif ($in_a_section eq "y") { - print "\t$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1];\n"; - } elsif ($in_a_proposal_section eq "y" && $racoon->{$key1}{$key2}[0] =~ /^#/) { - print "\t\t$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1]\n"; - } elsif ($in_a_proposal_section eq "y") { - print "\t\t$racoon->{$key1}{$key2}[0] $racoon->{$key1}{$key2}[1];\n"; - } - } - } - -print "}\n"; -} - -sub recreate_ipsec_conf1_k24 { - my ($ipsec) = @_; - foreach my $key1 (ikeys %$ipsec) { - print "$key1-->$ipsec->{$key1}\n" if ! $ipsec->{$key1}{1}; - foreach my $key2 (ikeys %{$ipsec->{$key1}}) { - if ($ipsec->{$key1}{$key2}[0] =~ m/^#/) { - print "\t$key2-->$ipsec->{$key1}{$key2}[0]\n"; - } elsif ($ipsec->{$key1}{$key2}[0] =~ m/(conn|config|version)/) { - print "$key1-->$key2-->$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; - } else { - print "\t$key2-->$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; - } - } -} -#- end of debug functions -------- - -sub sys { system(@_) == 0 or log::l("[drakvpn] Warning, sys failed for $_[0]") } - -sub start_daemons () { - return if $::testing; - log::explanations("Starting daemons"); - if (-e "/etc/rc.d/init.d/ipsec") { - system("/etc/rc.d/init.d/ipsec status >/dev/null") == 0 and sys("/etc/rc.d/init.d/ipsec stop"); - sys("/etc/rc.d/init.d/$_ start >/dev/null"), sys("/sbin/chkconfig --level 345 $_ on") foreach 'ipsec'; - } else { - - }; - sys("/etc/rc.d/init.d/$_ start >/dev/null"), sys("/sbin/chkconfig --level 345 $_ on") foreach 'shorewall'; -} - -sub stop_daemons () { - return if $::testing; - log::explanations("Stopping daemons"); - if (-e "/etc/rc.d/init.d/ipsec") { - foreach (qw(ipsec)) { - system("/etc/rc.d/init.d/$_ status >/dev/null 2>/dev/null") == 0 and sys("/etc/rc.d/init.d/$_ stop"); - }; - sys("/sbin/chkconfig --level 345 $_ off") && -e "/etc/rc.d/init.d/$_" foreach 'ipsec'; - }; - system("/etc/rc.d/init.d/shorewall status >/dev/null 2>/dev/null") == 0 and sys("/etc/rc.d/init.d/shorewall stop >/dev/null"); - -} - -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/$file"; -} - -sub get_config_file { - my ($file) = @_; - map { [ split ' ' ] } grep { !/^#/ } cat_("$::prefix/$file"); -} - - -#------------------------------------------------------------------- -#---------------------- configure racoon_conf ----------------------- -#------------------------------------------------------------------- - -sub read_racoon_conf { - my ($racoon_conf) = @_; - my %conf; - my $nb = 0; #total number - my $i = 0; #nb within a section - my $in_a_section = "n"; - my @line1; - my $line = ""; - local $_; - open(my $LIST, "< $racoon_conf"); - while (<$LIST>) { - chomp($_); - $line = $_; - $in_a_section = "n" if $line =~ /}/ && $line !~ /^#/; - $line =~ s/^\s+|\s*;|\s*{//g if $line !~ /^#/; - $line =~ /(.*)#(.*)/ if $line !~ /^#/; #- define before and after comment -# print "--line-->$line\n"; - my $data_part = $1; - my $comment_part = "#".$2; - if ($data_part) { - $data_part =~ s/,//g; -# print "@@".$data_part."->".$comment_part."\n"; - @line1 = split /\s+/,$data_part; - @line1 = (@line1, $comment_part) if $comment_part; - } else { - @line1 = split /\s+/,$line; - } - if (!$line && $in_a_section eq "n") { - $nb++; - put_in_hash(\%conf, { $nb => $line }); - $in_a_section = "n"; - } elsif (!$line && $in_a_section eq "y") { - put_in_hash($conf{$nb} ||= {}, { $i => [ '' ] }); - $i++; - } elsif ($line =~ /^path/) { - $i=1; - $nb++; - put_in_hash($conf{$nb} ||= {}, { $i => [@line1] }); - $in_a_section = "n"; - $i++; - } elsif ($line =~ /^#|^{|^}/) { - if ($in_a_section eq "y") { - put_in_hash($conf{$nb} ||= {}, { $i => [$line] }); - $i++; - } else { - $nb++; - put_in_hash(\%conf, { $nb => $line }); - $in_a_section = "n"; - }; - } elsif ($line =~ /^sainfo|^remote|^listen|^timer|^padding/ && $in_a_section eq "n") { - $i=1; - $nb++; - put_in_hash($conf{$nb} ||= {}, { $i => [@line1] }); - $in_a_section = "y"; - $i++; - } elsif ($line eq "proposal" && $in_a_section eq "y") { - $i=1; - $nb++; - put_in_hash($conf{$nb} ||= {}, { $i => [@line1] }); - $in_a_section = "y"; - $i++; - } else { - put_in_hash($conf{$nb} ||= {}, { $i => [@line1] }); - $i++; - }; - }; - -\%conf; -} - -sub display_racoon_conf { - my ($racoon) = @_; - my $display = ""; - my $prefix_to_simple_line = ""; - my $pt; - foreach my $key1 (ikeys %$racoon) { - if (!$racoon->{$key1}{1}) { - $display .= $prefix_to_simple_line . $racoon->{$key1} . "\n"; - $prefix_to_simple_line = ""; - } else { - foreach my $key2 (ikeys %{$racoon->{$key1}}) { - if ($key2 > 1) { - $pt = $racoon->{$key1}{$key2-1}[0]; - } else { - $pt = $racoon->{$key1}{1}[0]; - }; - my $t = $racoon->{$key1}{1}[0]; - my $f = $racoon->{$key1}{$key2}[0]; - my $list_length = scalar @{$racoon->{$key1}{$key2}}; - my $already_read = 0; - my $line = ""; - - if ($racoon->{$key1}{$key2}[0] eq "sainfo" && !$racoon->{$key1}{$key2}[2]) { - $line = "sainfo anonymous"; - } else { - for (my $i = 0; $i <= $list_length-1; $i++) { - - my $c = $racoon->{$key1}{$key2}[$i]; - my $n = $racoon->{$key1}{$key2}[$i+1]; - - if ($c =~ /^path|^log|^timer|^listen|^padding|^remote|^proposal|^sainfo/) { - $line .= "$c "; - } elsif ($i == $list_length-2 && $n =~ /^#/) { - $line .= "$c; "; - } elsif ($i == $list_length-1) { - if ($f =~ /^#|^$|^timer|^listen|^padding|^remote|^proposal\s+|^sainfo/) { - $line .= $c; - } elsif ($c =~ /^#/) { - $line .= "\t$c"; - } else { - $line .= "$c;"; - } - } else { - $line .= "$c "; - } - - $already_read = 1; - } - } - - if ($f =~ /^timer|^listen|^padding|^remote|^sainfo/) { - $line .= " {"; - $prefix_to_simple_line = ""; - } elsif ($f eq "proposal") { - $line = "\t" . $line . " {"; - } elsif ($t eq "proposal") { - $line = "\t\t" . $line if $line ne "proposal"; - $prefix_to_simple_line = "\t"; - } else { - $line = "\t" . $line if $t !~ /^path|^log/; - $prefix_to_simple_line = ""; - } - $display .= "$line\n"; - } - } - } - -$display; - -} - -sub write_racoon_conf { - my ($racoon_conf, $racoon) = @_; - my $display = ""; - my $prefix_to_simple_line = ""; - my $pt; - foreach my $key1 (ikeys %$racoon) { - if (!$racoon->{$key1}{1}) { - $display .= $prefix_to_simple_line . $racoon->{$key1} . "\n"; - $prefix_to_simple_line = ""; - } else { - foreach my $key2 (ikeys %{$racoon->{$key1}}) { - if ($key2 > 1) { - $pt = $racoon->{$key1}{$key2-1}[0]; - } else { - $pt = $racoon->{$key1}{1}[0]; - }; - my $t = $racoon->{$key1}{1}[0]; - my $f = $racoon->{$key1}{$key2}[0]; - my $list_length = scalar @{$racoon->{$key1}{$key2}}; - my $already_read = 0; - my $line = ""; - - if ($racoon->{$key1}{$key2}[0] eq "sainfo" && !$racoon->{$key1}{$key2}[2]) { - $line = "sainfo anonymous"; - } else { - for (my $i = 0; $i <= $list_length-1; $i++) { - - my $c = $racoon->{$key1}{$key2}[$i]; - my $n = $racoon->{$key1}{$key2}[$i+1]; - - if ($c =~ /^path|^log|^timer|^listen|^padding|^remote|^proposal|^sainfo/) { - $line .= "$c "; - } elsif ($i == $list_length-2 && $n =~ /^#/) { - $line .= "$c; "; - } elsif ($i == $list_length-1) { - if ($f =~ /^#|^$|^timer|^listen|^padding|^remote|^proposal\s+|^sainfo/) { - $line .= $c; - } elsif ($c =~ /^#/) { - $line .= "\t$c"; - } else { - $line .= "$c;"; - } - } else { - $line .= "$c "; - } - - $already_read = 1; - } - } - - if ($f =~ /^timer|^listen|^padding|^remote|^sainfo/) { - $line .= " {"; - $prefix_to_simple_line = ""; - } elsif ($f eq "proposal") { - $line = "\t" . $line . " {"; - } elsif ($t eq "proposal") { - $line = "\t\t" . $line if $line ne "proposal"; - $prefix_to_simple_line = "\t"; - } else { - $line = "\t" . $line if $t !~ /^path|^log/; - $prefix_to_simple_line = ""; - } - $display .= "$line\n"; - } - } - } - -open(my $ADD, "> $racoon_conf") or die "Can't open the $racoon_conf file for writing"; - print $ADD "$display\n"; - -} - -sub get_section_names_racoon_conf { - my ($racoon) = @_; - my @section_names; - - foreach my $key1 (ikeys %$racoon) { - if (!$racoon->{$key1}{1}) { - next; - } else { - my $list_length = scalar @{$racoon->{$key1}{1}}; - my $section_title = ""; - my $separator = ""; - for (my $i = 0; $i <= $list_length-1; $i++) { - my $s = $racoon->{$key1}{1}[$i]; - if ($s !~ /^#|^proposal/) { - $section_title .= $separator . $s; - $separator = " "; - }; - } - push(@section_names, $section_title) if $section_title ne ""; - } - } - - @section_names; - -} - -sub add_section_racoon_conf { - my ($new_section, $racoon) = @_; - put_in_hash($racoon, { max(keys %$racoon) + 1 => '' }); - put_in_hash($racoon, { max(keys %$racoon) + 1 => $new_section }); - put_in_hash($racoon, { max(keys %$racoon) + 1 => '}' }) if $new_section->{1}[0] !~ /^path|^remote/; - put_in_hash($racoon, { max(keys %$racoon) + 1 => '' }) if $new_section->{1}[0] =~ /^proposal/; - put_in_hash($racoon, { max(keys %$racoon) + 1 => '}' }) if $new_section->{1}[0] =~ /^proposal/; -} - -sub matched_section_key_number_racoon_conf { - my ($section_name, $racoon) = @_; - foreach my $key1 (ikeys %$racoon) { - if (!$racoon->{$key1}{1}) { - next; - } else { - my $list_length = scalar @{$racoon->{$key1}{1}}; - my $section_title = ""; - my $separator = ""; - for (my $i = 0; $i <= $list_length-1; $i++) { - my $s = $racoon->{$key1}{1}[$i]; - if ($s !~ /^#|^proposal/) { - $section_title .= $separator . $s; - $separator = " "; - }; - }; - if ($section_title eq $section_name) { - return $key1; - }; - } - } - -} - -sub already_existing_section_racoon_conf { - my ($section_name, $racoon, $racoon_conf) = @_; - if (-e $racoon_conf) { - foreach my $key1 (ikeys %$racoon) { - if (!$racoon->{$key1}{1}) { - next; - } elsif (find { - my $list_length = scalar @{$racoon->{$key1}{1}}; - my $section_title = ""; - my $separator = ""; - for (my $i = 0; $i <= $list_length-1; $i++) { - my $s = $racoon->{$key1}{1}[$i]; - if ($s !~ /^#|^proposal/) { - $section_title .= $separator . $s; - $separator = " "; - }; - } - - $section_title eq $section_name; - - } ikeys %{$racoon->{$key1}}) { - - return "already existing"; - } - } - } - -} - -sub remove_section_racoon_conf { - my ($section_name, $racoon, $k) = @_; - if ($section_name =~ /^remote/) { - - delete $racoon->{$k} if $k > 1 && !$racoon->{$k-1}; - my $closing_curly_bracket = 0; - while ($closing_curly_bracket < 2) { - print "-->$k\n"; - $closing_curly_bracket++ if $racoon->{$k} eq "}"; - delete $racoon->{$k}; - $k++; - } - - } elsif ($section_name =~ /^path/) { - - delete $racoon->{$k}; - delete $racoon->{$k+1} if $racoon->{$k+1}{1} eq ""; - - } else { - - delete $racoon->{$k}; - delete $racoon->{$k+1} if $racoon->{$k+1}{1} eq ""; - delete $racoon->{$k+2} if $racoon->{$k+2}{1} eq ""; #- remove assoc } - - } - -} - -#------------------------------------------------------------------- -#---------------------- configure ipsec_conf ----------------------- -#------------------------------------------------------------------- - -sub read_ipsec_conf { - my ($ipsec_conf, $kernel_version) = @_; - my %conf; - my $nb = 0; #total number - my $i = 0; #nb within a connexion - my $in_a_conn = "n"; - my $line = ""; - my @line1; - local $_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - open(my $LIST, "< $ipsec_conf"); #or die "Can't open the $ipsec_conf file for reading"; - while (<$LIST>) { - chomp($_); - $line = $_; - $line =~ s/^\s+//; - if (!$line) { - $nb++; - put_in_hash(\%conf, { $nb => $line }); - $in_a_conn = "n"; - } elsif ($line =~ /^#/) { - if ($in_a_conn eq "y") { - put_in_hash($conf{$nb} ||= {}, { $i => [$line] }); - $i++; - } else { - $nb++; - put_in_hash(\%conf, { $nb => $line }); - $in_a_conn = "n"; - }; - } elsif ($line =~ /^conn|^config|^version/ && $in_a_conn eq "n") { - @line1 = split /\s+/,$line; - $i=1; - $nb++; - put_in_hash($conf{$nb} ||= {}, { $i => [$line1[0], $line1[1]] }); - $in_a_conn = "y" if $line !~ /^version/; - $i++; - } elsif ($line =~ /^conn|^config|^version/ && $in_a_conn eq "y") { - @line1 = split /\s+/,$line; - $i=1; - $nb++; - put_in_hash($conf{$nb} ||= {}, { $i => [$line1[0], $line1[1]] }); - $i++; - } else { - @line1 = split /=/,$line; - put_in_hash($conf{$nb} ||= {}, { $i => [$line1[0], $line1[1]] }); - $i++; - }; - }; - - } else { - #- kernel 2.6 part ------------------------------- - my @mylist; - my $myline = ""; - open(my $LIST, "< $ipsec_conf"); #or die "Can't open the $ipsec_conf file for reading"; - while (<$LIST>) { - chomp($_); - $myline = $_; - $myline =~ s/^\s+//; - $myline =~ s/;$//; - if ($myline =~ /^spdadd/) { - @mylist = split /\s+/,$myline; - $in_a_conn = "y"; - $nb++; - next; - } elsif ($in_a_conn eq "y") { - @mylist = (@mylist, split '\s+|/',$myline); - put_in_hash(\%conf, { $nb => { command => $mylist[0], - src_range => $mylist[1], - dst_range => $mylist[2], - upperspec => $mylist[3], - flag => $mylist[4], - direction => $mylist[5], - ipsec => $mylist[6], - protocol => $mylist[7], - mode => $mylist[8], - src_dest => $mylist[9], - level => $mylist[10] } }); - $in_a_conn = "n"; - } else { - $nb++; - put_in_hash(\%conf, { $nb => $myline }); - }; - }; - - }; - - \%conf; -} - -sub write_ipsec_conf { - my ($ipsec_conf, $ipsec, $kernel_version) = @_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - open(my $ADD, "> $ipsec_conf") or die "Can't open the $ipsec_conf file for writing"; - foreach my $key1 (ikeys %$ipsec) { - print $ADD "$ipsec->{$key1}\n" if ! $ipsec->{$key1}{1}; - foreach my $key2 (ikeys %{$ipsec->{$key1}}) { - if ($ipsec->{$key1}{$key2}[0] =~ m/^#/) { - print $ADD "\t$ipsec->{$key1}{$key2}[0]\n"; - } elsif ($ipsec->{$key1}{$key2}[0] =~ m/(^conn|^config|^version)/) { - print $ADD "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; - } else { - print $ADD "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n" if $ipsec->{$key1}{$key2}[0] && $ipsec->{$key1}{$key2}[1]; - }; - } - } - } else { - #- kernel 2.6 part ------------------------------- - my $display = ""; - foreach my $key1 (ikeys %$ipsec) { - if (! $ipsec->{$key1}{command}) { - $display .= "$ipsec->{$key1}\n"; - } else { - $display .= $ipsec->{$key1}{command} . " " . - $ipsec->{$key1}{src_range} . " " . - $ipsec->{$key1}{dst_range} . " " . - $ipsec->{$key1}{upperspec} . " " . - $ipsec->{$key1}{flag} . " " . - $ipsec->{$key1}{direction} . " " . - $ipsec->{$key1}{ipsec} . "\n\t" . - $ipsec->{$key1}{protocol} . "/" . - $ipsec->{$key1}{mode} . "/" . - $ipsec->{$key1}{src_dest} . "/" . - $ipsec->{$key1}{level} . ";\n" - }; - } - open(my $ADD, "> $ipsec_conf") or die "Can't open the $ipsec_conf file for writing"; - print $ADD $display; - } -} - -sub display_ipsec_conf { - my ($ipsec, $kernel_version) = @_; - my $display = ""; - - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - $display .= "$ipsec->{$key1}\n" if ! $ipsec->{$key1}{1}; - foreach my $key2 (ikeys %{$ipsec->{$key1}}) { - if ($ipsec->{$key1}{$key2}[0] =~ m/^#/) { - $display .= "\t$ipsec->{$key1}{$key2}[0]\n"; - } elsif ($ipsec->{$key1}{$key2}[0] =~ m/(^conn|^config|^version)/) { - $display .= "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; - } else { - $display .= "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; - } - } - - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (! $ipsec->{$key1}{command}) { - $display .= "$ipsec->{$key1}\n"; - } else { - $display .= $ipsec->{$key1}{command} . " " . - $ipsec->{$key1}{src_range} . " " . - $ipsec->{$key1}{dst_range} . " " . - $ipsec->{$key1}{upperspec} . " " . - $ipsec->{$key1}{flag} . " " . - $ipsec->{$key1}{direction} . " " . - $ipsec->{$key1}{ipsec} . "\n\t" . - $ipsec->{$key1}{protocol} . "/" . - $ipsec->{$key1}{mode} . "/" . - $ipsec->{$key1}{src_dest} . "/" . - $ipsec->{$key1}{level} . ";\n"; - } - } - - } - - $display; - -} - -sub get_section_names_ipsec_conf { - my ($ipsec, $kernel_version) = @_; - my @section_names; - - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - foreach my $key2 (ikeys %{$ipsec->{$key1}}) { - if ($ipsec->{$key1}{$key2}[0] =~ m/(^conn|^config|^version)/) { - push(@section_names, "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]"); - }; - } - } - - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if ($ipsec->{$key1}{command} =~ m/(^spdadd)/) { - push(@section_names, "$ipsec->{$key1}{src_range} $ipsec->{$key1}{dst_range}"); - }; - } - } - - @section_names; - -} - -sub remove_section_ipsec_conf { - my ($section_name, $ipsec, $kernel_version) = @_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = $ipsec->{$key1}{$_}[0]; - $s !~ /^#/ && $s =~ m/(^conn|^config|^version)/ && - $section_name eq "$s $ipsec->{$key1}{$_}[1]"; - } ikeys %{$ipsec->{$key1}}) { - delete $ipsec->{$key1}; - } - } - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = "$ipsec->{$key1}{src_range} $ipsec->{$key1}{dst_range}"; - $s !~ /^#/ && $ipsec->{$key1}{src_range} && $section_name eq $s; - } ikeys %{$ipsec->{$key1}}) { - delete $ipsec->{$key1-1}; - delete $ipsec->{$key1}; - } - } - } -} - -sub add_section_ipsec_conf { - my ($new_section, $ipsec) = @_; - put_in_hash($ipsec, { max(keys %$ipsec) + 1 => '' }); - put_in_hash($ipsec, { max(keys %$ipsec) + 1 => $new_section }); -} - -sub already_existing_section_ipsec_conf { - my ($section_name, $ipsec, $kernel_version) = @_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = $ipsec->{$key1}{$_}[0]; - $s !~ /^#/ && $s =~ m/(^conn|^config|^version)/ && - $section_name eq "$s $ipsec->{$key1}{$_}[1]"; - } ikeys %{$ipsec->{$key1}}) { - return "already existing"; - } - } - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = "$ipsec->{$key1}{src_range} $ipsec->{$key1}{dst_range}"; - $s !~ /^#/ && $ipsec->{$key1}{src_range} && - $section_name eq $s; - } ikeys %{$ipsec->{$key1}}) { - return "already existing"; - } - } - }; - return "no"; -} - -#- returns the reference to the dynamical list for editing -sub dynamic_list { - my ($number, $ipsec) = @_; - my @list = map { { label => $ipsec->{$number}{$_}[0] . "=", - val => \$ipsec->{$number}{$_}[1] } } ikeys %{$ipsec->{$number}}; - - @list; -} - -#- returns the hash key number of $section_name -sub matched_section_key_number_ipsec_conf { - my ($section_name, $ipsec, $kernel_version) = @_; - if ($kernel_version < 2.5) { - #- kernel 2.4 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = $ipsec->{$key1}{$_}[0]; - $s !~ /^#/ && $s =~ m/(^conn|^config|^version)/ && - $section_name eq "$s $ipsec->{$key1}{$_}[1]"; - } ikeys %{$ipsec->{$key1}}) { - return $key1; - } - } - } else { - #- kernel 2.6 part ------------------------------- - foreach my $key1 (ikeys %$ipsec) { - if (find { - my $s = "$ipsec->{$key1}{src_range} $ipsec->{$key1}{dst_range}"; - $s !~ /^#/ && $ipsec->{$key1}{src_range} && - $section_name eq $s; - } ikeys %{$ipsec->{$key1}}) { - return $key1; - } - } - } -} -1 diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm deleted file mode 100644 index a42d54257..000000000 --- a/perl-install/network/isdn.pm +++ /dev/null @@ -1,158 +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 MDK::Common::Globals "network", qw($in); -use MDK::Common::File; - - -sub write_config { - my ($isdn, $netc) = @_; - $in->do_pkgs->install('isdn4net', if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils'); - write_config_backend($isdn, $netc); - 1; -} - -sub 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}" -I4L_PROTOCOL="$isdn->{protocol}" -); - - output "$::prefix/etc/ppp/ioptions", - "lock -usepeerdns -defaultroute -"; - system "$::prefix/etc/rc.d/init.d/isdn4linux restart"; - - write_secret_backend($isdn->{login}, $isdn->{passwd}); - - set_cnx_script($netc, "isdn", join('', -"/sbin/route del default -modprobe $isdn->{driver}", if_($isdn->{type}, " type=$isdn->{type}"), -" -/usr/sbin/isdnctrl dial ippp0 -", if_($isdn->{speed} =~ /128/, "service ibod restart -")), -"/usr/sbin/isdnctrl hangup ippp0 -" . if_($isdn->{speed} =~ /128/, "service ibod stop -"), $netc->{isdntype}); - 1; -} - -sub 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{$_} && $conf{$_}; - } - } - - $isdn->{passwd} = network::tools::passwd_by_login($isdn->{login}); - #$isdn->{description} = ''; - #$isdn->{vendor} = ''; - #$isdn->{passwd2} = ''; -} - -my $file = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db"; -$file = "$::prefix$file" if !-e $file; - -sub get_info_providers_backend { - my ($isdn, $_netc, $name) = @_; - $name eq N("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 read_providers_backend() { map { /(.*?)=>/ } catMaybeCompressed($file) } - - -sub detect_backend { - my ($modules_conf) = @_; - my @isdn; - require detect_devices; - each_index { - my $c = $_; - my $isdn = { map { $_ => $c->{$_} } qw(description vendor id driver card_type type) }; - $isdn->{intf_id} = $::i; - $isdn->{$_} = sprintf("%0x", $isdn->{$_}) foreach 'vendor', 'id'; - $isdn->{card_type} = $c->{bus} eq 'USB' ? 'usb' : 'pci'; - $isdn->{description} =~ s/.*\|//; -# $c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax"; - if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) { - $modules_conf->set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol}); - } - $c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1; - push @isdn, $isdn; - } modules::probe_category('network/isdn'); - \@isdn; -} - -sub get_cards_by_type { - my ($isdn_type) = @_; - grep { $_->{card} eq $isdn_type } @isdndata; -} - - -sub get_cards() { - my %buses = ( - isa => N("ISA / PCMCIA") . "/" . N("I don't know"), - pci => N("PCI"), - usb => N("USB"), - ); - # pmcia alias (we should really split up pcmcia from isa in isdn db): - $buses{pcmcia} = $buses{isa}; - - map { $buses{$_->{card}} . "|" . $_->{description} => $_ } @isdndata; -} - - -1; diff --git a/perl-install/network/isdn_consts.pm b/perl-install/network/isdn_consts.pm deleted file mode 100644 index 6c97f6f8f..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", #1 irq, mem, io - driver => 'hisax', - type => '1', - irq => '5', - mem => '0xd000', - io => '0xd80', - card => 'isa', - }, - { description => "Teles|8.0", #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|Generic (ISA PnP)", #4 irq, io0 (ISAC), io1 (HSCX) - driver => 'hisax', - type => '4', - irq => '5', - io0 => '0x0000', - io1 => '0x0000', - card => 'isa', - }, - { description => "Teles|generic", #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", #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", #7 irq, io (from isapnp setup) - driver => 'hisax', - type => '7', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "ELSA|Quickstep 1000", #18 no parameter - driver => 'hisax', - type => '18', - card => 'pci', - }, - { description => "ELSA|Quickstep 3000", #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", #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", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl|Diva 20PRO", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl|Diva 20_U", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "Eicon.Diehl|Diva 20PRO_U", #11 no parameter - driver => 'hisax', - type => '11', - card => 'pci', - }, - { description => "ASUS|COM ISDNLink", #12 irq, io (from isapnp setup) - driver => 'hisax', - type => '12', - irq => '5', - io => '0x200', - card => 'isa', - }, - { description => "ASUS|COM ISDNLink", - driver => 'hisax', - type => '35', - card => 'pci', - }, - { description => "DynaLink|Any", - driver => 'hisax', - type => '12', - card => 'pci', - }, - { description => "DynaLink|IS64PH, ASUSCOM", #36 - driver => 'hisax', - type => '36', - card => 'pci', - }, - { description => "HFC|2BS0 based cards", #13 irq, io - driver => 'hisax', - type => '13', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "HFC|2BDS0", #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", #15 irq, io - driver => 'hisax', - type => '15', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Sedlbauer|PC/104", #15 irq, io - driver => 'hisax', - type => '15', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Sedlbauer|Speed Card", #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+", #28 no parameter - driver => 'hisax', - type => '28', - card => 'pci', - firmware => '/usr/lib/isdn/ISAR.BIN', - }, - { description => "USR|Sportster internal", #16 irq, io - driver => 'hisax', - type => '16', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Generic|MIC card", #17 irq, io - driver => 'hisax', - type => '17', - irq => '9', - io => '0xd80', - card => 'isa', - }, - { description => "Compaq|ISDN S0 card", #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 => "Generic|NETjet card", #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", ##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 generic", #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!)", #27 no parameter - driver => 'hisax', - type => '27', - card => 'pci', - }, - { description => "AVM|B1", - 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", #32 none - driver => 'hisax', - type => '32', - card => 'pci', - }, - { description => "Scitel|Quadro", #33 subcontroller (4*S0, subctrl 1...4) - driver => 'hisax', - type => '33', - card => 'pci', - }, - { description => "Gazel|ISDN cards", #34 irq,io - driver => 'hisax', - type => '34', - irq => '5', - io => '0x300', - card => 'isa', - }, - { description => "Gazel|Gazel ISDN cards", #34 none - driver => 'hisax', - type => '34', - card => 'pci', - }, - { description => "Winbond|W6692 and Winbond based cards", #36 none - driver => 'hisax', - type => '36', - card => 'pci', - }, - { description => "BeWAN|R834", - driver => 'hisax_st5481', - type => '99', - card => 'usb', - }, - { description => "Gazel|128", - 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 e790cf83c..000000000 --- a/perl-install/network/modem.pm +++ /dev/null @@ -1,213 +0,0 @@ -package network::modem; # $Id$ - -use strict; -use common; -use any; -use modules; -use detect_devices; -use mouse; -use network::tools; - -sub first_modem { - my ($netc) = @_; - first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}}); -} - - -sub ppp_read_conf { - my ($netcnx, $netc) = @_; - my $modem = $netcnx->{$netcnx->{type}} ||= {}; - $modem->{device} ||= first_modem($netc)->{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} ||= defined $modem->{Gateway} && $modem->{Gateway} ne '0.0.0.0' ? N("Manual") : N("Automatic"); - $modem->{auto_ip} ||= defined $modem->{IPAddr} && $modem->{IPAddr} ne '0.0.0.0' ? N("Manual") : N("Automatic"); - $modem->{auto_dns} ||= $modem->{dns1} || $modem->{dns2} ? N("Manual") : N("Automatic"); -} - -#-----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"); - - $toreplace{$_->[0]} = $modem->{$_->[0]} || $_->[1] foreach [ 'Timeout', 60 ], [ 'UseLockFile', 1 ], [ 'Enter', 'CR' ], [ 'Volume', 0 ], - [ 'BusyWait', 0 ], [ 'FlowControl', 'CRTSCTS' ], [ 'Speed', 115200 ]; - output($modem->{kppprc} || "$::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=$toreplace{BusyWait} -Enter=$toreplace{Enter} -FlowControl=$toreplace{FlowControl} -Volume=$toreplace{Volume} -Timeout=$toreplace{Timeout} -UseCDLine=0 -UseLockFile=$toreplace{UseLockFile} -Device=/dev/modem -Speed=$toreplace{Speed} - -[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 e08914a7e..000000000 --- a/perl-install/network/netconnect.pm +++ /dev/null @@ -1,1464 +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 ($modules_conf, $auto_detect, $o_class) = @_; - my %l = ( - isdn => sub { - require network::isdn; - $auto_detect->{isdn} = network::isdn::detect_backend($modules_conf); - }, - lan => sub { # ethernet - modules::load_category($modules_conf, 'network/main|gigabit|usb'); - require network::ethernet; - $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) }; - }, - adsl => sub { - require network::adsl; - $auto_detect->{adsl} = network::adsl::adsl_detect(); - }, - modem => sub { - $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) }; - }, - ); - $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("$::prefix/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 real_main { - my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; - my $netc = $o_netc ||= {}; - my $mouse = $o_mouse ||= {}; - my $intf = $o_intf ||= {}; - my $first_time = $o_first_time || 0; - my ($network_configured, $direct_net_install, $cnx_type, $type, $interface, @all_cards, %eth_intf); - my (%connections, @connection_list, $is_wireless); - my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip); - my ($adsl_type, @adsl_devices, $adsl_failed, $adsl_answer, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider); - my ($ntf_name, $ipadr, $netadr, $gateway_ex, $up, $need_restart_network); - my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods); - my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")"); - my ($module, $auto_ip, $protocol, $onboot, $needhostname, $hotplug, $track_network_id, @fields); # lan config - my $success = 1; - my $ethntf = {}; - my $db_path = "$::prefix/usr/share/apps/kppp/Provider"; - my (%countries, @isp, $country, $provider, $old_provider); - my $config = {}; - eval(cat_("$::prefix/etc/sysconfig/drakconnect")); - - 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)"), - ) - ); - my $_w = N("Protocol for the rest of the world"); - my %isdn_protocols = ( - 2 => N("European protocol (EDSS1)"), - 3 => N("Protocol for the rest of the world\nNo D-Channel (leased lines)"), - ); - - network::tools::remove_initscript(); - - init_globals($in); - - read_net_conf($netcnx, $netc, $intf); - - $netc->{autodetect} = {}; - - my $lan_detect = sub { - detect($modules_conf, $netc->{autodetect}, 'lan'); - modules::interactive::load_category($in, $modules_conf, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 0); - @all_cards = network::ethernet::get_eth_cards($modules_conf); - %eth_intf = network::ethernet::get_eth_cards_names($modules_conf, @all_cards); - require list_modules; - %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) } - grep { to_bool($is_wireless) == c::isNetDeviceWirelessAware($_->[0]) } @all_cards; - }; - - my $find_lan_module = sub { - if (my $dev = find { $_->{device} eq $ethntf->{DEVICE} } detect_devices::pcmcia_probe()) { # PCMCIA case - $module = $dev->{driver}; - } elsif ($dev = find { $_->[0] eq $ethntf->{DEVICE} } @all_cards) { - $module = $dev->[1]; - } else { $module = "" } - }; - - my $is_hotplug_blacklisted = sub { - bool2yesno($is_wireless || - member($module, qw(b44 forcedeth madwifi_pci)) || - find { $_->{device} eq $ntf_name } detect_devices::pcmcia_probe()); - }; - - my %adsl_devices = ( - speedtouch => N("Alcatel speedtouch USB modem"), - sagem => N("Sagem USB modem"), - bewan => N("Bewan 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"), - ); - - my $offer_to_connect = sub { - return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && $adsl_devices{$ntf_name}; - return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn)); - return "end"; - }; - - my $after_start_on_boot_step = sub { - if ($netc->{internet_cnx_choice}) { - write_cnx_script($netc); - $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type} if $netc->{internet_cnx_choice}; - } else { - undef $netc->{NET_DEVICE}; - } - network::network::configureNetwork2($in, $::prefix, $netc, $intf); - $network_configured = 1; - return "restart" if $need_restart_network && $::isStandalone && !$::expert; - return $offer_to_connect->(); - }; - - my $goto_start_on_boot_ifneeded = sub { - return $after_start_on_boot_step->() if $netcnx->{type} =~ /lan|cable/; - return "isdn_dial_on_boot" if $netcnx->{type} =~ /isdn/; - return "network_on_boot"; - }; - - my $save_cnx = sub { - if (keys %$config) { - require Data::Dumper; - output("$::prefix/etc/sysconfig/drakconnect", Data::Dumper->Dump([ $config ], [ '$p' ])); - } - return $goto_start_on_boot_ifneeded->(); - }; - - my $handle_multiple_cnx = sub { - $need_restart_network = member($netcnx->{type}, qw(cable lan)) || $netcnx->{type} eq 'adsl' && $adsl_devices{$ntf_name}; - my $nb = keys %{$netc->{internet_cnx}}; - if (1 < $nb) { - return "multiple_internet_cnx"; - } else { - $netc->{internet_cnx_choice} = (keys %{$netc->{internet_cnx}})[0] if $nb == 1; - $save_cnx->(); - return $goto_start_on_boot_ifneeded->() - } - }; - - - # main wizard: - my $wiz; - $wiz = - { - defaultimage => "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 ], }; - }, - if_(!$::isInstall, 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"); - #- why read again the net_conf here ? - read_net_conf($netcnx, $netc, $intf) if $::isInstall; # :-( - $type = $netcnx->{type} = $connections{$cnx_type}; - if ($type eq 'cable') { - $auto_ip = 1; - 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 => sub { - [ - (map { - my ($dstruct, $field, $item) = @$_; - $item->{val} = \$dstruct->{$field}; - if__(exists $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") } ], - [ $isdn, "phone_in", { label => N("Your personal phone number") } ], - [ $netc, "DOMAINNAME2", { label => N("Provider name (ex provider.net)") } ], - [ $isdn, "phone_out", { label => N("Provider phone number") } ], - [ $netc, "dnsServer2", { label => N("Provider DNS 1 (optional)") } ], - [ $netc, "dnsServer3", { label => N("Provider DNS 2 (optional)") } ], - [ $isdn, "dialing_mode", { label => N("Dialing mode"), list => ["auto", "manual"] } ], - [ $isdn, "speed", { label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"] } ], - [ $netcnx, "huptimeout", { label => N("Connection timeout (in sec)") } ], #unused? - ) - ), - ({ label => N("Account Login (user name)"), val => \$isdn->{login} }, - { label => N("Account Password"), val => \$isdn->{passwd}, hidden => 1 }, - ) - ], - }, - post => sub { - network::isdn::write_config($isdn, $netc); # or return 'isdn_protocol'; - $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE'; - # return "static_hostname"; - $handle_multiple_cnx->(); - }, - }, - - - # KILLME?: no longer called and deprecated fonction calls :-( - #go_ethernet => - #{ - # pre => sub { - # conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return; - # $netc->{NET_INTERFACE} = $netc->{NET_DEVICE}; - # configureNetwork($netc, $intf, $first_time) or return; - # }, - #}, - - - isdn => - { - pre=> sub { - detect($modules_conf, $netc->{autodetect}, 'isdn'); - %isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}}; - }, - name => N("Select the network interface to configure:"), - data => sub { - [ { label => N("Net Device"), type => "list", val => \$isdn_name, allow_empty_list => 1, - list => [ $my_isdn, N("External ISDN modem"), keys %isdn_cards ] } ] - }, - post => sub { - # !intern_pci: - # data => [ { val => \$isdn_type, type => "list", list => [ , ], } ], - # post => sub { - if ($isdn_name eq $my_isdn) { - return "isdn_ask"; - } elsif ($isdn_name eq N("External ISDN modem")) { - detect($modules_conf, $netc->{autodetect}, 'modem'); - $netc->{isdntype} = 'isdn_external'; - $netcnx->{isdn_external}{device} = network::modem::first_modem($netc); - network::isdn::read_config($netcnx->{isdn_external}); - $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40'; - require network::modem; - $modem = $netcnx->{isdn_external}; - return "modem"; - } - - $netc->{isdntype} = 'isdn_internal'; - # FIXME: some of these should be taken from isdn db - $netcnx->{isdn_internal} = $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) }; - - if ($isdn->{id}) { - log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n"); - $isdn->{description} =~ s/\|/ -- /; - - } - network::isdn::read_config($netcnx->{isdn_internal}); - return "isdn_protocol"; - }, - }, - - - isdn_ask => - { - pre => sub { - %isdn_cards = network::isdn::get_cards(); - }, - name => N("Select a device!"), - data => sub { [ { label => N("Net Device"), val => \$isdn_name, type => 'list', separator => '|', list => [ keys %isdn_cards ], allow_empty_list => 1 } ] }, - pre2 => sub { - my ($label) = @_; - - #- ISDN card already detected - 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} }, - [ network::isdn::get_cards_by_type($isdn->{card_type}) ]) 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); - - }, - post => sub { - $netcnx->{isdn_internal} = $isdn = $isdn_cards{$isdn_name}; - return "isdn_protocol"; - } - }, - - - isdn_protocol => - { - name => N("ISDN Configuration") . "\n\n" . N("Which protocol do you want to use?"), - data => [ - { label => N("Protocol"), type => "list", val => \$isdn_type, - list => [ keys %isdn_protocols ], format => sub { $isdn_protocols{$_[0]} } } - ], - post => sub { - $isdn->{protocol} = $isdn_type; - return "isdn_db", - } - }, - - - isdn_db => - { - name => N("ISDN Configuration") . "\n\n" . N("Select your provider.\nIf it isn't listed, choose Unlisted."), - data => sub { - [ { label => N("Provider:"), type => "list", val => \$provider, separator => '|', - list => [ N("Unlisted - edit manually"), network::isdn::read_providers_backend() ] } ]; - }, - post => sub { - network::isdn::get_info_providers_backend($isdn, $netc, $provider); - $isdn->{huptimeout} = 180; - $isdn->{$_} ||= '' foreach qw(phone_in phone_out dialing_mode login passwd passwd2 idl speed); - add2hash($netc, { dnsServer2 => '', dnsServer3 => '', DOMAINNAME2 => '' }); - return "hw_account"; - }, - }, - - - 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 { - require network::modem; - detect($modules_conf, $netc->{autodetect}, 'modem'); - }, - name => N("Select the modem to configure:"), - data => sub { - [ { label => N("Modem"), type => "list", val => \$modem_name, allow_empty_list => 1, - list => [ keys %{$netc->{autodetect}{modem}}, N("Manual choice") ], } ], - }, - complete => sub { - if ($netc->{autodetect}{modem}{$modem_name}{driver} =~ /^(LT|H[cs]f):/ && c::kernel_version() !~ /^\Q2.4/) { - $in->ask_warn(N("Warning"), N("Sorry, we support only 2.4 and above kernels.")); - } - return 0; - }, - post => sub { - $modem ||= $netcnx->{modem} ||= {};; - return 'choose_serial_port' if $modem_name eq N("Manual choice"); - $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 $type; - - my %pkgs2path = ( - hcfpcimodem => "$::prefix/usr/sbin/hcfpciconfig", - hsflinmodem => "$::prefix/usr/sbin/hsfconfig", - ltmodem => "$::prefix/etc/devfs/conf.d/ltmodem.conf", - ); - - my %devices = (ltmodem => '/dev/ttyS14', - hsflinmodem => '/dev/ttySHSF0' - ); - - - if (my $driver = $netc->{autodetect}{modem}{$modem_name}{driver}) { - $driver =~ /^Hcf:/ and $type = "hcfpcimodem"; - $driver =~ /^Hsf:/ and $type = "hsflinmodem"; - $driver =~ /^LT:/ and $type = "ltmodem"; - $type = undef if !($type && (-f $pkgs2path{$type} || $in->do_pkgs->ensure_is_installed_if_available($type, $pkgs2path{$type}))); - $modem->{device} = $devices{$type} || '/dev/modem' if $type; # automatically linked by /etc/devfs/conf entry - } - - #- fallback to modem configuration (beware to never allow test it). - return $type ? "ppp_provider" : "no_supported_winmodem"; - }, - }, - - - choose_serial_port => - { - name => N("Please choose which serial port your modem is connected to."), - interactive_help_id => 'selectSerialPort', - data => sub { - [ { val => \$modem->{device}, format => \&mouse::serial_port2text, type => "list", - list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0') ] } ], - }, - post => sub { - $ntf_name = $modem->{device}; - return 'ppp_provider'; - }, - }, - - - ppp_provider => - { - pre => sub { - network::modem::ppp_read_conf($netcnx, $netc) if !$modem_conf_read; - $modem_conf_read = 1; - @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 (defined $old_provider && $old_provider ne $provider) { - $modem->{connection} = $l{Name}; - $modem->{phone} = $l{Phonenumber}; - $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask); - ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS}); - } - return "ppp_account"; - }, - }, - - - 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}); - }, - 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->ensure_binary_is_installed('kdenetwork-kppp', 'kppp'); - $handle_multiple_cnx->(); - }, - }, - - - adsl => - { - pre => sub { - get_subwizard($wiz, 'adsl'); - $lan_detect->(); - detect($modules_conf, $netc->{autodetect}, 'adsl'); - @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-usb', "$::prefix/usr/sbin/eaglectrl" ], - 'speedtouch' => [ 'speedtouch', "$::prefix/usr/sbin/modem_run" ], - ); - return 'adsl_unsupported_eci' if $ntf_name eq 'eci'; - # FIXME: check that the package installation succeeds, else retry or abort - $in->do_pkgs->install($packages{$ntf_name}[0]) if $packages{$ntf_name} && !-e $packages{$ntf_name}->[1]; - if ($ntf_name eq 'speedtouch') { - $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "$::prefix/usr/share/speedtouch/mgmt.o"); - return 'adsl_speedtouch_firmware' if ! -e "$::prefix/usr/share/speedtouch/mgmt.o"; - } - $netcnx->{bus} = $netc->{autodetect}{adsl}{bewan}{bus} if $ntf_name eq 'bewan'; - if ($ntf_name eq 'bewan' && !$::testing) { - $in->do_pkgs->ensure_is_installed_if_available('unicorn', "$::prefix/usr/bin/bewan_adsl_status"); - } - 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 ] } ]; - }, - post => sub { - $adsl_data = $adsl_data{$adsl_provider}; - $adsl_type = 'pppoa' if member($ntf_name, qw(bewan speedtouch)); - if ($adsl_provider ne $adsl_old_provider) { - $netc->{$_} = $adsl_data->{$_} foreach qw(DOMAINNAME2 Encapsulation vpi vci); - $adsl_type ||= $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")) { - ($source, $adsl_failed) = network::tools::use_windows($file = 'alcaudsl.sys'); - } - 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_provider", - }, - - - adsl_protocol => - { - pre => sub { - # preselect right protocol for ethernet though connections: - if (!exists $adsl_devices{$ntf_name}) { - $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; - $adsl_type = $ethntf->{BOOTPROTO} || "dhcp"; - } - }, - 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_type, type => "list", - list => [ sort { $adsl_types{$a} cmp $adsl_types{$b} } keys %adsl_types ], - format => sub { $adsl_types{$_[0]} }, - }, - ], - post => sub { - $netcnx->{type} = 'adsl'; - # blacklist bogus driver, enable ifplugd support else: - $find_lan_module->(); - $ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->(); - # process static/dhcp ethernet devices: - if (!exists $adsl_devices{$ntf_name} && member($adsl_type, qw(manual dhcp))) { - $auto_ip = $adsl_type eq 'dhcp'; - return 'lan_intf'; - } - network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name); - $netc->{NET_DEVICE} = $ntf_name if $adsl_type eq 'pppoe'; - return 'adsl_account'; - }, - }, - - - adsl_account => - { - name => N("Connection Configuration") . "\n\n" . - N("Please fill or check the field below"), - data => sub { - [ - if_(0, { 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 }, - if_($ntf_name eq "sagem", - { label => N("Encapsulation :"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ], - format => sub { $encapsulations{$_[0]} }, advanced => 1, - }, - ), - ], - }, - post => sub { - $netc->{internet_cnx_choice} = 'adsl'; - network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $ntf_name, $adsl_type, $netcnx); #FIXME - $config->{adsl} = { kind => $ntf_name, protocol => $adsl_type }; - $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 => [ (sort keys %eth_intf), N_("Manually load a driver") ], - allow_empty_list => 1, format => sub { translate($eth_intf{$_[0]} || $_[0]) } } ]; - }, - post => sub { - $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name }; - if ($ntf_name eq "Manually load a driver") { - modules::interactive::load_category__prompt($in, $modules_conf, 'network/main|gigabit|pcmcia|usb|wireless'); - return 'lan'; - } - $::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) = @_; - return $res ? "lan_protocol" : "alrd_end"; - } - }, - - - alrd_end => - { - name => N("Congratulations, the network and Internet configuration is finished. - -"), - end => 1, - }, - - - lan_protocol => - { - pre => sub { - $find_lan_module->(); - $protocol = $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 => \$protocol, type => "list", list => [ sort values %l10n_lan_protocols ] } ]; - }, - post => sub { - $auto_ip = $protocol 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/; - # blacklist bogus driver, enable ifplugd support else: - $ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->(); - $hotplug = !text2bool($ethntf->{MII_NOT_SUPPORTED}); - $track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop(); - delete $ethntf->{NETWORK}; - delete $ethntf->{BROADCAST}; - @fields = qw(IPADDR NETMASK); - $netc->{dhcp_client} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)) || "dhcp-client"; - $netc->{dhcp_client} = "dhcp-client" if $netc->{dhcp_client} eq "dhclient"; - }, - 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} }, - ) - : - ( - { 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 => [ qw(dhcp-client dhcpcd pump 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 => sub { - [ - { 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}, advanced => 1 }, - { label => N("Operating frequency"), val => \$ethntf->{WIRELESS_FREQ}, advanced => 1 }, - { label => N("Sensitivity threshold"), val => \$ethntf->{WIRELESS_SENS}, advanced => 1 }, - { label => N("Bitrate (in b/s)"), val => \$ethntf->{WIRELESS_RATE}, advanced => 1 }, - { label => N("Encryption key"), val => \$ethntf->{WIRELESS_ENC_KEY} }, - ], - }, - complete => sub { - if ($ethntf->{WIRELESS_FREQ} && $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} && $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; - } - }, - next => "wireless2", - }, - - - wireless2 => - { - name => N("Please enter the wireless parameters for this card:"), - data => sub { - [ - { 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 => - #-PO: split the "xyz command extra argument" translated string into two lines if it's bigger than the english one - 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."), - } - ] - }, - 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, $modules_conf, 'network/main|gigabit|usb', !$::expert, 1); - @all_cards = network::ethernet::get_eth_cards($modules_conf) or - # FIXME: fix this - $in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system. -I cannot set up this connection type.")), return; - - }, - name => N("Choose the network interface") . "\n\n" . - N("Please choose which network adapter you want to use to connect to Internet."), - data => [ { val => \$interface, type => "list", list => \@all_cards, } ], - format => sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") }, - - post => sub { - network::ethernet::write_ether_conf(); - $modules_conf->write if $::isStandalone; - my $_device = network::ethernet::conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr); - return "lan"; - }, - }, - - static_hostname => - { - pre => sub { - if ($ethntf->{IPADDR}) { - $netc->{dnsServer} ||= dns($ethntf->{IPADDR}); - $gateway_ex = gateway($ethntf->{IPADDR}); - # $netc->{GATEWAY} ||= gateway($ethntf->{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.") . -N("Last but not least you can also type in your DNS server IP addresses."), - data => sub { - [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$netc->{HOSTNAME} }, - if_(!$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") }, - { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} }, - if_(@all_cards > 1, - { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ sort keys %eth_intf ], - format => sub { $eth_intf{$_[0]} } }, - ), - ), - ], - }, - 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("If desired, enter a Zeroconf hostname. -This is the name your machine will use to advertise any of -its shared resources that are not managed by the network. -It is not necessary on most networks."), - 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 => sub { - [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice}, - list => [ keys %{$netc->{internet_cnx}} ] } ]; - }, - post => $save_cnx, - }, - - apply_settings => - { - name => N("Configuration is complete, do you want to apply settings ?"), - type => "yesorno", - }, - - 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", - default => sub { ($type eq 'modem' ? 'no' : 'yes') }, - post => sub { - my ($res) = @_; - $netc->{at_boot} = $res; - $res = bool2yesno($res); - substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } - $netc->{internet_cnx_choice} eq 'adsl' ? - "$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0" : - "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0"; - return $after_start_on_boot_step->(); - }, - }, - - isdn_dial_on_boot => - { - pre => sub { - $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written - @isdn_dial_methods = ({ name => N("Automatically at boot"), - ONBOOT => 1, DIAL_ON_IFUP => 1 }, - { name => N("By using Net Applet in the system tray"), - ONBOOT => 0, DIAL_ON_IFUP => 1 }, - { name => N("Manually (the interface would still be activated at boot)"), - ONBOOT => 1, DIAL_ON_IFUP => 0 }); - my $method = find { - $_->{ONBOOT} eq text2bool($intf->{ippp0}{ONBOOT}) && - $_->{DIAL_ON_IFUP} eq text2bool($intf->{ippp0}{DIAL_ON_IFUP}) - } @isdn_dial_methods; - #- use net_applet by default - $isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name}; - }, - name => N("How do you to dial this connection ?"), - data => sub { - [ { type => "list", val => \$isdn->{dial_method}, list => [ map { $_->{name} } @isdn_dial_methods ] } ] - }, - post => sub { - my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods; - $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP); - return $after_start_on_boot_step->(); - }, - }, - - restart => - { - name => N("The network needs to be restarted. Do you want to restart it ?"), - type => "yesorno", - post => sub { - my ($a) = @_; - network::ethernet::write_ether_conf($in, $modules_conf, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan'; - if ($a && !$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) { - $success = 0; - $in->ask_okcancel(N("Network Configuration"), - N("A problem occured while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0); - } - return $offer_to_connect->(); - }, - }, - - 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)$/) { - local $::isWizard; - !$::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 run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null"); - - if ($::isInstall && $::o->{security} >= 3) { - require network::drakfirewall; - network::drakfirewall::main($in, $::o->{security} <= 3); - } -} - -sub main { - my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_; - eval { real_main('', , $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) }; - my $err = $@; - if ($err) { # && $in->isa('interactive::gtk') - local $::isEmbedded = 0; # to prevent sub window embedding - local $::isWizard = 0 if !$::isInstall; # to prevent sub window embedding - #err_dialog(N("Error"), N("An unexpected error has happened:\n%s", $err)); - $in->ask_warn(N("Error"), N("An unexpected error has happened:\n%s", $err)); - } -} - -sub set_profile { - my ($netcnx) = @_; - system('/sbin/set-netprofile', $netcnx->{PROFILE}); - log::explanations(qq(Switching to "$netcnx->{PROFILE}" profile)); -} - -sub save_profile { - my ($netcnx) = @_; - system('/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('/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 get_net_device() { - my $connect_file = $network::tools::connect_file; - my $network_file = "$::prefix/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 ($netcnx, $netc, $intf) = @_; - my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") }; - - $netcnx->{PROFILE} = $current->{PROFILE} || 'default'; - network::network::read_all_conf($::prefix, $netc, $intf, $netcnx); - - foreach ('NET_DEVICE', 'NET_INTERFACE') { - $netc->{$_} = $netcnx->{$_} if $netcnx->{$_} - } - $netcnx->{$netcnx->{type}} ||= {} if $netcnx->{type}; -} - -sub start_internet { - my ($o) = @_; - init_globals($o); - #- give a chance for module to be loaded using kernel-BOOT modules... - $::isStandalone or modules::load_category($o->{modules_conf}, '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($modules_conf, \%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 06e86155c..000000000 --- a/perl-install/network/network.pm +++ /dev/null @@ -1,430 +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 = "$::prefix/etc/tmdns.conf"; - cat_($file) =~ /^\s*hostname\s*=\s*(\w+)/m && { ZEROCONF_HOSTNAME => $1 }; -} - -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 if -l $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/; - - if (local $intf->{WIRELESS_ENC_KEY} = $intf->{WIRELESS_ENC_KEY}) { - network::tools::convert_wep_key_for_iwconfig($intf->{WIRELESS_ENC_KEY}); - } - - 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)), - if_($intf->{DEVICE} =~ /^ippp\d+$/, qw(DIAL_ON_IFUP)) - ); - 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()); - foreach (all("$::prefix/etc/sysconfig/network-scripts")) { - if (/^ifcfg-([A-Za-z0-9.:]+)$/ && $1 ne 'lo') { - my $intf = findIntf($intf, $1); - add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") }); - $intf->{WIRELESS_ENC_KEY} = network::tools::get_wep_key_from_iwconfig($intf->{WIRELESS_ENC_KEY}); - } - } - $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 ($modules_conf, $netc, $intf) = @_; - - return if text2bool($netc->{NETWORKING}); - - require modules; - require network::ethernet; - modules::load_category($modules_conf, 'network/main|gigabit|usb'); - my @all_cards = network::ethernet::get_eth_cards($modules_conf); - - #- 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_binary_is_installed('wireless-tools', '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_binary_is_installed('tmdns', 'tmdns', 'auto') if !$in->do_pkgs->is_installed('bind'); - $in->do_pkgs->ensure_binary_is_installed('zcip', '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 37dd954e5..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_binary_is_installed('nfs-utils-clients', '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 1bd15fead..000000000 --- a/perl-install/network/shorewall.pm +++ /dev/null @@ -1,164 +0,0 @@ -package network::shorewall; # $Id$ - - - - -use detect_devices; -use network::netconnect; -use network::ethernet; -use network::network; -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; - - my $modules_conf = modules::any_conf->read; -my @all_cards = network::ethernet::get_eth_cards($modules_conf); -my %net_devices = network::ethernet::get_eth_cards_names($modules_conf, @all_cards); -put_in_hash(\%net_devices, { 'ppp+' => 'ppp+', 'ippp+' => 'ippp+' }); - - $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 => [ sort keys %net_devices ], format => sub { $net_devices{$_[0]} || $_[0] }, not_edit => 0 } ]); - - $conf{net_interface} = $card_netconnect; - $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)); - }; - $conf{net_interface} && \%conf; -} - -sub write { - my ($conf) = @_; - my $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up"; - my $squid_port = network::network::read_squid_conf()->{http_port}[0]; - - my %ports_by_proto; - foreach (split ' ', $conf->{ports}) { - m!^(\d+(:\d+)?)/(udp|tcp|icmp)$! or die "bad port $_\n"; - push @{$ports_by_proto{$3}}, $1; - } - - set_config_file("zones", - [ 'net', 'Net', 'Internet zone' ], - if_($conf->{loc_interface}[0], [ 'loc', 'Local', 'Local' ]), - ); - set_config_file('interfaces', - [ 'net', $conf->{net_interface}, 'detect' ], - (map { [ 'loc', $_, 'detect' ] } @{$conf->{loc_interface} || []}), - ); - set_config_file('policy', - if_($conf->{loc_interface}[0], [ 'loc', 'net', 'ACCEPT' ]), - [ 'fw', 'net', 'ACCEPT' ], - [ 'fw', 'loc', '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->{loc_interface}[0], 'loc'))), - ); - if (cat_("/etc/shorewall/rules") !~ /^\s*REDIRECT\s*loc\s*$squid_port\s+(\S+)/mg && $squid_port && -f "/var/run/squid.pid" && grep { /Loc/i } cat_("/etc/shorewall/zones")) { - substInFile { - s/#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/REDIRECT\tloc\t$squid_port\ttcp\twww\t-\nACCEPT\tfw\tnet\ttcp\twww\n#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/; - } "/etc/shorewall/rules" -}; - set_config_file('masq', - $conf->{masquerade} ? [ $conf->{net_interface}, $conf->{masquerade}{subnet} ] : (), - ); - - if ($conf->{disabled}) { - run_program::rooted($::prefix, 'chkconfig', '--del', 'shorewall'); - run_program::run('service', '>', '/dev/null', 'shorewall', 'stop') 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 26b61c518..000000000 --- a/perl-install/network/smb.pm +++ /dev/null @@ -1,217 +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_binary_is_installed('samba-client', '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'}) : '%'; - my %h; - foreach (`smbclient -g -U $U -L $name $ip$group 2>/dev/null`) { - if (my ($type, $v1, $v2) = /(.*)\|(.*)\|(.*)/) { - push @{$h{$type}}, [ $v1, $v2 ]; - } elsif (/^Error returning browse list/) { - push @{$h{Error}}, $_; - } - } - \%h; -} - -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; - my $workgroups = smbclient($browse)->{Workgroup} || []; - foreach (@$workgroups) { - my ($group, $name) = map { 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; - - my $browse = smbclient($server); - if (my $err = find { /NT_STATUS_/ } @{$browse->{Error} || []}) { - die $err; - } - foreach (@{$browse->{Disk} || []}) { - my ($name, $comment) = @$_; - push @l, { name => $name, type => 'Disk', comment => $comment, server => $server } - if $name !~ /\$$/ && $name !~ /netlogon|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 -"); -} - -sub write_smb_ads_conf { - my ($domain, $realm) = @_; - - #- 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 - realm = $realm - server string = Samba Member %v - security = ads - 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 - 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 9e587a10f..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, $fs_type) = @_; - my $fs_entry = { device => $class->to_dev($e), fs_type => $fs_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 0e5439594..000000000 --- a/perl-install/network/tools.pm +++ /dev/null @@ -1,211 +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_secret_backend set_cnx_script test_connected write_cnx_script remove_initscript write_secret_backend); - -our $connect_prog = "/etc/sysconfig/network-scripts/net_cnx_pg"; -our $connect_file = "/etc/sysconfig/network-scripts/net_cnx_up"; -our $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 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; - my $p; - if ($>) { - $p = Net::Ping->new("tcp"); - # Try connecting to the www port instead of the echo port - $p->{port_num} = getservbyname("http", "tcp"); - } else { - $p = Net::Ping->new("icmp"); - } - print $p->ping("www.mandrakesoft.com") ? 1 : 0; - }); -} - -sub remove_initscript() { - $::testing and return; - if (-e "$::prefix/etc/rc.d/init.d/internet") { - run_program::rooted($::prefix, "/sbin/chkconfig", "--del", "internet"); - rm_rf("$::prefix/etc/rc.d/init.d/internet"); - log::explanations("Removed internet service"); - } -} - -sub use_windows { - my ($file) = @_; - 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 = find { -d $_ && -r "$_/$file" } map { "$part->{mntpoint}/$_" } qw(windows/system winnt/system windows/system32/drivers winnt/system32/drivers); - 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; -} - -sub reread_net_conf { - my ($modules_conf, $netcnx, $netc, $intf) = @_; - network::netconnect::read_net_conf($netcnx, $netc, $intf); - modules::load_category($modules_conf, 'net'); -} - -sub convert_wep_key_for_iwconfig { - #- 5 or 13 characters, consider the key as ASCII and prepend "s:" - #- else consider the key as hexadecimal, do not strip dashes - #- always quote the key as string - my ($key) = @_; - member(length($key), (5, 13)) ? "s:$key" : $key; -} - -sub get_wep_key_from_iwconfig { - #- strip "s:" if the key is 5 or 13 characters (ASCII) - #- else the key as hexadecimal, do not modify - my ($key) = @_; - $key =~ s/^s:// if member(length($key), (7,15)); - $key; -} - -1; |
