summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/adsl.pm396
-rw-r--r--perl-install/network/adsl_consts.pm613
-rw-r--r--perl-install/network/drakfirewall.pm208
-rw-r--r--perl-install/network/ethernet.pm142
-rw-r--r--perl-install/network/ipsec.pm801
-rw-r--r--perl-install/network/isdn.pm201
-rw-r--r--perl-install/network/isdn_consts.pm452
-rw-r--r--perl-install/network/modem.pm241
-rw-r--r--perl-install/network/netconnect.pm1491
-rw-r--r--perl-install/network/network.pm474
-rw-r--r--perl-install/network/nfs.pm69
-rw-r--r--perl-install/network/shorewall.pm163
-rw-r--r--perl-install/network/smb.pm217
-rw-r--r--perl-install/network/smbnfs.pm45
-rw-r--r--perl-install/network/test.pm158
-rw-r--r--perl-install/network/tools.pm293
16 files changed, 0 insertions, 5964 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
deleted file mode 100644
index 5066f61ad..000000000
--- a/perl-install/network/adsl.pm
+++ /dev/null
@@ -1,396 +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 %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/$_";
- }
- my $passwd = passwd_by_login($login);
- if (!$netc->{vpi} && !$netc->{vci} && 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 sagem_set_parameters {
- my ($netc) = @_;
- my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
- 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/;
- s/STATIC_IP=.*\n//;
- s!</eaglectrl>!STATIC_IP=$netc->{static_ip}\n</eaglectrl>! if $netc->{static_ip};
- } "$::prefix$cfg_file";
- }
-}
-
-sub adsl_conf_backend {
- my ($in, $modules_conf, $adsl, $netc, $intf, $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';
- $adsl_type eq 'capi' and $adsl_device = 'capi_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 =>
- {
- modules => [ qw(speedtch) ],
- #- won't call pppd since we've just written ONBOOT=no, only runs modem_run
- start => '/usr/bin/speedtouch-start --boot',
- 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 =>
- {
- modules => [ qw(eagle-usb) ],
- start => '/usr/sbin/eaglectrl -d',
- stop => "/usr/bin/killall pppoa",
- get_intf => "/usr/sbin/eaglectrl -i",
- server => {
- pppoa => q("/usr/sbin/fctStartAdsl -t 1 -i"),
- },
- ppp_options => qq(
-mru 1492
-mtu 1492
-nobsdcomp
-nodeflate
-noaccomp -am
-novjccomp),
- aliases => [
- ['char-major-108', 'ppp_generic'],
- ['tty-ldisc-3', 'ppp_async'],
- ['tty-ldisc-13', 'n_hdlc'],
- ['tty-ldisc-14', 'ppp_synctty']
- ],
- },
- 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"),
- },
- },
- capi_modem =>
- {
- ppp_options => qq(
-connect /bin/true
-ipcp-accept-remote
-ipcp-accept-local
-
-sync
-noauth
-lcp-echo-interval 5
-lcp-echo-failure 3
-lcp-max-configure 50
-lcp-max-terminate 2
-
-noccp
-noipx
-mru 1492
-mtu 1492),
- plugin => {
- capi => qq(capiplugin.so
-avmadsl)
- },
- },
- );
-
-
- if ($adsl_type =~ /^pp|^capi$/) {
- 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) ],
- capi => [ qw(isdn4k-utils) ], #- capi4linux service
- );
- $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}";
- my $noipdefault = $adsl_type eq 'pptp' ? '' : 'noipdefault';
- 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 ($netc->{NET_DEVICE} =~ /^eth/) {
- my $net_device = $netc->{NET_DEVICE};
- $intf->{$net_device} = {
- DEVICE => $net_device,
- BOOTPROTO => 'none',
- NETMASK => '255.255.255.0',
- NETWORK => '10.0.0.0',
- BROADCAST => '10.0.0.255',
- ONBOOT => 'yes',
- };
- }
-
- if ($adsl_type eq 'pppoe') {
- if (-f "$::prefix/etc/ppp/pppoe.conf") {
- my $net_device = $modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $netc->{NET_DEVICE};
- substInFile {
- s/ETH=.*\n/ETH=$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";
- } else {
- log::l("can't find pppoe.conf, make sure the rp-pppoe package is installed");
- }
- }
-
-# 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';
- my $metric = network::tools::get_default_metric("adsl"); #- FIXME, do not override if already set
- output_with_perm("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0", 0705, qq(DEVICE=ppp0
-ONBOOT=no
-TYPE=$kind
-METRIC=$metric
-)) unless member($adsl_type, qw(manual dhcp));
-
- #- remove file used with sagem for dhcp/static connections
- unlink("$::prefix/etc/sysconfig/network-scripts/ifcfg-sagem");
-
- #- set vpi, vci and encapsulation parameters for sagem
- if ($adsl_device eq 'sagem') {
- $netc->{static_ip} = $intf->{sagem}{IPADDR} if $adsl_type eq 'manual';
- sagem_set_parameters($netc);
- }
-
- #- set aliases
- if (exists $modems{$adsl_device}{aliases}) {
- $modules_conf->set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}};
- $::isStandalone and $modules_conf->write;
- }
- #- remove the "speedtch off" alias that was written by Mandrakelinux 10.0
- $adsl_device eq 'speedtouch' and $modules_conf->remove_alias('speedtch');
-
- if ($adsl_type eq "capi") {
- require network::isdn;
- network::isdn::setup_capi_conf($adsl->{capi});
- services::stop("isdn4linux");
- services::do_not_start_service_on_boot("isdn4linux");
- services::start_service_on_boot("capi4linux");
- services::start("capi4linux");
-
- #- install and run drdsl for dsl connections, once capi driver is loaded
- $in->do_pkgs->ensure_is_installed_if_available("drdsl", "/usr/sbin/drdsl");
- run_program::rooted($::prefix, "/usr/sbin/drdsl");
- }
-
- #- load modules and run modem-specific start programs
- #- useful during install, or in case the packages have been installed after the device has been plugged
- my @modules = (@{$modems{$adsl_device}{modules}}, map { $_->[1] } @{$modems{$adsl_device}{aliases}});
- @modules or @modules = qw(ppp_synctty ppp_async ppp_generic n_hdlc); #- required for pppoe/pptp connections
- @modules && eval { modules::load(@modules) }
- or log::l("failed to load " . join(',', @modules), " modules: $@");
- $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 5c79409e3..000000000
--- a/perl-install/network/adsl_consts.pm
+++ /dev/null
@@ -1,613 +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;
-use utf8;
-use encoding "utf8";
-
-@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("Argentina") . "|Speedy" =>
- {
- vpi => 1,
- vci => 23,
- Encapsulation => 1,
- method => 'pppoe',
- },
-
- N("Austria") . "|Any" =>
- {
- vpi => 8,
- vci => 30,
- Encapsulation => 6,
- method => 'pppoa',
- },
-
- N("Austria") . "|AON" =>
- {
- vpi => 1,
- vci => 20,
- 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 => 21,
- 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("China") . "|China Netcom|Beijing" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Changchun" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Harbin" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Jilin" =>
- {
- vpi => 0,
- vci => 27,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Lanzhou" =>
- {
- vpi => 0,
- vci => 20,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Tianjin" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Xi'an" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Chongqing" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Fujian" =>
- {
- vpi => 0,
- vci => 0xc8,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Guangxi" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Guangzhou" =>
- {
- vpi => 8,
- vci => 20,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Hangzhou" =>
- {
- vpi => 0,
- vci => 20,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Netcom|Hunan" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Nanjing" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Shanghai" =>
- {
- vpi => 8,
- vci => 51,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Shenzhen" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Urumqi" =>
- {
- vpi => 0,
- vci => 20,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Wuhan" =>
- {
- vpi => 0,
- vci => 20,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Yunnan" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- method => 'pppoe',
- },
-
- N("China") . "|China Telecom|Zhuhai" =>
- {
- vpi => 0,
- vci => 23,
- Encapsulation => 3,
- 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" =>
- {
- 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("Lithuania") . "|Lietuvos Telekomas" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 1,
- method => 'pppoe',
- },
-
- N("Morocco") . "|Maroc Telecom" =>
- {
- vpi => 8,
- vci => 23,
- Encapsulation => 6,
- 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("Slovenia") . "|SiOL" =>
- {
- dnsServer2 => '193.189.160.11',
- dnsServer3 => '193.189.160.12',
- vpi => 1,
- vci => 20,
- method => 'pppoe',
- DOMAINNAME2 => 'siol.net',
- 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("Thailand") . "|Asianet" =>
- {
- vpi => 0,
- vci => 64,
- Encapsulation => 1,
- method => 'pppoe',
- },
-
- 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 0a7a3d19f..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(get_eth_categories);
-
-sub write_ether_conf {
- my ($in, $modules_conf, $netcnx, $netc, $intf) = @_;
- configureNetwork2($in, $modules_conf, $::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};
- }
- $::isStandalone and $modules_conf->write;
- 1;
-}
-
-
-sub mapIntfToDevice {
- my ($interface) = @_;
- my $hw_addr = c::getHwIDs($interface);
- return {} if $hw_addr =~ /^usb/;
- 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() : {};
-}
-
-
-sub get_eth_categories() {
- 'network/main|gigabit|pcmcia|usb|wireless|firewire';
-}
-
-# return list of [ intf_name, module, device_description ] tuples such as:
-# [ "eth0", "3c59x", "3Com Corporation|3c905C-TX [Fast Etherlink]" ]
-#
-# this function try several method in order to get interface's driver and description in order to support both:
-# - hotplug managed devices (USB, firewire)
-# - special interfaces (IP aliasing, VLAN)
-sub get_eth_cards {
- my ($modules_conf) = @_;
- my @all_cards = detect_devices::getNet();
-
- my @devs = detect_devices::pcmcia_probe();
- my $saved_driver;
- # compute device description and return (interface, driver, description) tuples:
- return map {
- my $interface = $_;
- my $description;
- # 0) get interface's driver through ETHTOOL ioctl or module aliases:
- my $a = c::getNetDriver($interface) || $modules_conf->get_alias($interface);
-
- # workaround buggy drivers that returns a bogus driver name for the GDRVINFO command of the ETHTOOL ioctl:
- my %fixes = (
- "p80211_prism2_cs" => 'prism2_cs',
- "p80211_prism2_pci" => 'prism2_pci',
- "p80211_prism2_usb" => 'prism2_usb',
- "ip1394" => "eth1394",
- );
- $a = $fixes{$a} if $fixes{$a};
-
- # 1) try to match a PCMCIA device for device description:
- if (my $b = find { $_->{device} eq $interface } @devs) { # PCMCIA case
- $a = $b->{driver};
- $description = $b->{description};
- } else {
- # 2) try to lookup a device by hardware address for device description:
- # maybe should have we try sysfs first for robustness?
- ($description) = (mapIntfToDevice($interface))[0]->{description};
- }
- # 3) try to match a device through sysfs for driver & device description:
- # (eg: ipw2100 driver for intel centrino do not support ETHTOOL)
- 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;
- }
- }
- # 4) try to match a device by driver for device description:
- # (eg: madwifi, ndiswrapper, ...)
- 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 (@all_cards) = @_;
- { map { $_->[0] => join(': ', $_->[0], $_->[2]) } @all_cards };
-}
-
-#- returns (link_type, mac_address)
-sub get_eth_card_mac_address {
- my ($intf) = @_;
- `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf 2>/dev/null` =~ m|.*link/(\S+)\s([0-9a-z:]+)\s|;
-}
-
-#- write interfaces MAC address in iftab
-sub update_iftab() {
- foreach my $intf (detect_devices::getNet()) {
- my ($link_type, $mac_address) = get_eth_card_mac_address($intf) or next;
- my $descriptor = ${{ ether => 'mac', ieee1394 => 'mac_ieee1394' }}{$link_type} or next;
- substInFile {
- s/^$intf\s+.*\n//;
- $_ .= qq($intf\t$descriptor $mac_address\n) if eof
- } "$::prefix/etc/iftab";
- }
-}
-
-# automatic net aliases configuration
-sub configure_eth_aliases {
- my ($modules_conf) = @_;
- my @pcmcia = detect_devices::pcmcia_probe();
- foreach my $card (get_eth_cards($modules_conf)) {
- if (any { $_->{device} eq $card->[0] } @pcmcia) {
- #- don't write aliases for pcmcia cards, or cardmgr won't be loaded
- $modules_conf->remove_alias($card->[0]);
- } else {
- $modules_conf->set_alias($card->[0], $card->[1]);
- }
- }
-}
-
-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 e91810aba..000000000
--- a/perl-install/network/isdn.pm
+++ /dev/null
@@ -1,201 +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;
-use services;
-use list_modules;
-
-
-sub write_config {
- my ($isdn) = @_;
- $in->do_pkgs->install('isdn4net', if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils');
-
- 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
-";
-
- services::stop("isdn4linux"); #- to be stopped before capi is loaded
- if ($isdn->{driver} eq "capidrv") {
- setup_capi_conf(get_capi_card($isdn));
- services::start_service_on_boot("capi4linux");
- services::start("capi4linux");
- } else {
- services::stop("capi4linux");
- services::do_not_start_service_on_boot("capi4linux");
- }
- services::start_service_on_boot("isdn4linux");
- services::start("isdn4linux");
-
- write_secret_backend($isdn->{login}, $isdn->{passwd});
-
- 1;
-}
-
-
-sub setup_capi_conf {
- my ($capi_card) = @_;
-
- $in->do_pkgs->ensure_is_installed('isdn4k-utils', "/etc/rc.d/init.d/capi4linux"); #- capi4linux service
- is_module_installed($capi_card->{driver}) or $in->do_pkgs->install($capi_card->{packages});
- if ($capi_card->{firmware} && ! -f "$::prefix/usr/lib/isdn/$capi_card->{firmware}") {
- $in->do_pkgs->install("$capi_card->{driver}-firmware");
- }
-
- #- stop capi4linux before new config is written so that it can unload the driver
- services::stop("capi4linux");
-
- my $capi_conf;
- my $firmware = $capi_card->{firmware} || '-';
- if ($capi_card->{driver} eq "fcclassic") {
- $capi_conf = "fcclassic - - 0x300 5 - -\n# adjust IRQ and IO !! ^^^^^ ^^^\n";
- } elsif ($capi_card->{driver} eq "fcpnp") {
- $capi_conf = "fcpnp - - 0x300 5 - -\n# adjust IRQ and IO !! ^^^^^ ^^^\n";
- } else {
- $capi_conf = "$capi_card->{driver} $firmware - - - - -\n";
- }
- output("$::prefix/etc/capi.conf", $capi_conf);
-}
-
-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;
-}
-
-
-sub is_module_installed {
- my ($driver) = @_;
- find { m!/\Q$driver\E\.k?o! } cat_($::prefix . '/lib/modules/' . c::kernel_version() . '/modules.dep');
-}
-
-
-sub get_capi_card {
- my ($isdn) = @_;
-
- my $capi_card = find {
- hex($isdn->{vendor}) == $_->{vendor} && hex($isdn->{id}) == $_->{id}
- } @isdn_capi or return;
-
- #- check if the capi driver is available
- unless (is_module_installed($capi_card->{driver}) || ($capi_card->{packages} = $in->do_pkgs->check_kernel_module_packages("$capi_card->{driver}-kernel"))) {
- log::explanations("a capi driver ($capi_card->{driver}) exists to replace $isdn->{driver}, but it isn't installed and no packages provide it");
- return;
- }
-
- $capi_card;
-}
-
-1;
diff --git a/perl-install/network/isdn_consts.pm b/perl-install/network/isdn_consts.pm
deleted file mode 100644
index a828a9385..000000000
--- a/perl-install/network/isdn_consts.pm
+++ /dev/null
@@ -1,452 +0,0 @@
-package network::isdn_consts; # $Id$
-use vars qw(@ISA @EXPORT);
-@ISA = qw(Exporter);
-@EXPORT = qw(@isdndata @isdn_capi);
-
-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',
- },
- );
-
-#- cards than can be used with capi drivers
-our @isdn_capi =
- (
- {
- vendor => 0x1131,
- id => 0x5402,
- description => 'AVM Audiovisuelles|Fritz DSL ISDN/DSL Adapter',
- bus => 'PCI',
- driver => 'fcdsl',
- firmware => 'fdslbase.bin'
- },
- {
- vendor => 0x1244,
- id => 0x0a00,
- description => 'AVM Audiovisuelles|A1 ISDN Adapter [Fritz] CAPI',
- bus => 'PCI',
- driver => 'fcpci'
- },
- {
- vendor => 0x1244,
- id => 0x0e00,
- description => 'AVM Audiovisuelles|A1 ISDN Adapter [Fritz] CAPI',
- bus => 'PCI',
- driver => 'fcpci'
- },
- {
- vendor => 0x1244,
- id => 0x0f00,
- description => 'AVM Audiovisuelles|Fritz DSL ISDN/DSL Adapter',
- bus => 'PCI',
- driver => 'fcdsl',
- firmware => 'fdslbase.bin'
- },
- {
- vendor => 0x1244,
- id => 0x2700,
- description => 'AVM Audiovisuelles|Fritz!Card DSL SL',
- bus => 'PCI',
- driver => 'fcdslsl',
- firmware => 'fdssbase.bin'
- },
- {
- vendor => 0x1244,
- id => 0x2900,
- description => 'AVM Audiovisuelles|Fritz DSL Ver. 2.0',
- bus => 'PCI',
- driver => 'fcdsl2',
- firmware => 'fds2base.bin'
- },
- {
- vendor => 0x057c,
- id => 0x0c00,
- description => 'AVM GmbH|FritzCard USB ISDN TA',
- bus => 'USB',
- driver => 'fcusb'
- },
- {
- vendor => 0x057c,
- id => 0x1000,
- description => 'AVM GmbH|FritzCard USB 2 Ver. 2.0 ISDN TA',
- bus => 'USB',
- driver => 'fcusb2',
- firmware => 'fus2base.frm'
- },
- {
- vendor => 0x057c,
- id => 0x1900,
- description => 'AVM GmbH|FritzCard USB 2 Ver. 3.0 ISDN TA',
- bus => 'USB',
- driver => 'fcusb2',
- firmware => 'fus3base.frm'
- },
- {
- vendor => 0x057c,
- id => 0x2000,
- description => 'AVM GmbH|Fritz X USB ISDN TA',
- bus => 'USB',
- driver => 'fxusb'
- },
- {
- vendor => 0x057c,
- id => 0x2300,
- description => 'AVM GmbH|FtitzCard USB DSL ISDN TA/ DSL Modem',
- bus => 'USB',
- driver => 'fcdslusb',
- firmware => 'fdsubase.frm'
- },
- {
- vendor => 0x057c,
- id => 0x2800,
- description => 'AVM GmbH|Fritz X USB OEM ISDN TA',
- bus => 'USB',
- driver => 'fxusb_CZ'
- },
- {
- vendor => 0x057c,
- id => 0x3000,
- description => 'AVM GmbH|FtitzCard USB DSL SL USB',
- bus => 'USB',
- driver => 'fcdslusba',
- firmware => 'fdlabase.frm'
- },
- {
- vendor => 0x057c,
- id => 0x3500,
- description => 'AVM GmbH|FtitzCard USB DSL SL USB Analog',
- bus => 'USB',
- driver => 'fcdslslusb',
- firmware => 'fdlubase.frm',
- },
- );
-
-
-1;
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
deleted file mode 100644
index 18755d0cb..000000000
--- a/perl-install/network/modem.pm
+++ /dev/null
@@ -1,241 +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) = @_;
- return "/mnt/root" if $::isInstall;
- first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}});
-}
-
-sub get_user_home() {
- my $home;
- if ($ENV{USER} ne "root") {
- #- kdesu case
- $home = (find { $_->[0] eq $ENV{USER} } list_passwd())->[7];
- }
- $home ||= $ENV{HOME}; #- consolehelper case
- $home;
-}
-
-sub ppp_read_conf {
- my ($netcnx, $netc) = @_;
- my $modem = $netcnx->{$netcnx->{type}} ||= {};
- if (my $detected_modem = first_modem($netc)) {
- $modem->{device} ||= $detected_modem->{device};
- }
- $modem->{device} ||= '/dev/modem';
- my %l = getVarsFromSh(get_user_home() . "/.kde/share/config/kppprc");
- add2hash(\%l, getVarsFromSh("$::prefix/usr/share/config/kppprc"));
- $l{Authentication} = 4 if $l{Authentication} !~ /\d/;
- $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;
- /^METRIC=(.*)/ and $modem->{METRIC} = $1;
- }
- $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;
-}
-
-#-----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');
-
- if ($modem->{device} ne "/dev/modem") {
- my $dev = $modem->{device};
- $dev =~ s!^/dev/!!;
- any::devfssymlinkf({ device => $dev }, 'modem');
- #- add a specific udev script in addition to the udev rules file
- #- (ttySL0 is a symlink, udev won't be called when it's created)
- my $udev_conf = "$::prefix/etc/udev/conf.d/modem.conf";
- output_p($udev_conf, "ln -sf $dev /dev/modem\n");
- chmod 0755, $udev_conf;
- }
-
- 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};
-
- $toreplace{METRIC} = defined($modem->{METRIC}) ? $modem->{METRIC} : network::tools::get_default_metric("modem");
-
- #- 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}"
-METRIC=$toreplace{METRIC}
-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 57dd82c88..000000000
--- a/perl-install/network/netconnect.pm
+++ /dev/null
@@ -1,1491 +0,0 @@
-package network::netconnect; # $Id$
-
-use strict;
-use common;
-use log;
-use detect_devices;
-use run_program;
-use modules;
-use any;
-use fs;
-use mouse;
-use network::network;
-use network::tools;
-use MDK::Common::Globals "network", qw($in);
-
-sub detect {
- my ($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
- require network::ethernet;
- modules::load_category($modules_conf, network::ethernet::get_eth_categories());
- $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) };
- },
- adsl => sub {
- require network::adsl;
- $auto_detect->{adsl} = network::adsl::adsl_detect();
- },
- modem => sub {
- $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($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, $cnx_type, $type, @all_cards, %eth_intf, %all_eth_intf);
- my (%connections, @connection_list, $is_wireless);
- my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip);
- my ($adsl_type, @adsl_devices, $adsl_failed, $adsl_answer, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider);
- my ($ntf_name, $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 = "/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');
- require network::ethernet;
- modules::interactive::load_category($in, $modules_conf, network::ethernet::get_eth_categories(), !$::expert, 0);
- @all_cards = network::ethernet::get_eth_cards($modules_conf);
- %all_eth_intf = network::ethernet::get_eth_cards_names(@all_cards); #- needed not to loose GATEWAYDEV
- require list_modules; #- FIXME: check if useful
- %eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) }
- grep { 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(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)"),
- capi => N("DSL over CAPI"),
- );
-
- 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' && !member($adsl_type, qw(manual dhcp));
- return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn isdn_external));
- return "end";
- };
-
- my $after_start_on_boot_step = sub {
- if ($netc->{internet_cnx_choice} && exists $netc->{internet_cnx}{$netc->{internet_cnx_choice}}) {
- $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
- } else {
- undef $netc->{NET_DEVICE};
- }
- if ($netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)) && member($ntf_name, qw(sagem))) {
- #- we need to write sagem specific parameters and load corresponding modules/programs
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx);
- }
- network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
- $network_configured = 1;
- return "restart" if $need_restart_network && $::isStandalone && !$::expert;
- return $offer_to_connect->();
- };
-
- my $goto_start_on_boot_ifneeded = sub {
- return $after_start_on_boot_step->() if $netcnx->{type} eq "lan";
- 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' && member($adsl_type, qw(manual dhcp));
- my $nb = keys %{$netc->{internet_cnx}};
- if (1 < $nb) {
- return "multiple_internet_cnx";
- } else {
- $netc->{internet_cnx_choice} = $nb == 1 ? (keys %{$netc->{internet_cnx}})[0] : $netcnx->{type};
- return $save_cnx->();
- }
- };
-
-
- # 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->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $handle_multiple_cnx->();
- },
- },
-
- 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');
- $netcnx->{type} = $netc->{isdntype} = 'isdn_external';
- $netcnx->{isdn_external}{device} = network::modem::first_modem($netc);
- network::isdn::read_config($netcnx->{isdn_external});
- #- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i
- #- it doesn't even work with TA 128 modems
- #- http://bugs.mandrakelinux.com/query.php?bug=1033
- $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40';
- require network::modem;
- $modem = $netcnx->{isdn_external};
- 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($isdn);
- $isdn->{driver} = $isdn_cards{$isdn_name}{driver}; #- do not let config overwrite default driver
-
- #- let the user choose hisax or capidrv if both are available
- $isdn->{driver} ne "capidrv" && network::isdn::get_capi_card($isdn) and return "isdn_driver";
- return "isdn_protocol";
- },
- },
-
-
- isdn_ask =>
- {
- 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_driver =>
- {
- pre => sub {
- $isdn_name = "capidrv";
- },
- name => N("A CAPI driver is available for this modem. This CAPI driver can offer more capabilities than the free driver (like sending faxes). Which driver do you want to use?"),
- data => sub { [
- { label => N("Driver"), type => "list", val => \$isdn_name,
- list => [ $isdn->{driver}, "capidrv" ] }
- ] },
- post => sub {
- $isdn->{driver} = $isdn_name;
- return "isdn_protocol";
- }
- },
-
-
- isdn_protocol =>
- {
- name => N("ISDN Configuration") . "\n\n" . N("Which protocol do you want to use?"),
- 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") ], } ],
- },
- 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 => "/usr/sbin/hcfpciconfig",
- hsflinmodem => "/usr/sbin/hsfconfig",
- ltmodem => "/etc/devfs/conf.d/ltmodem.conf",
- slmodem => "/usr/sbin/slmodemd",
- );
-
- my %devices = (ltmodem => '/dev/ttyS14',
- hsflinmodem => '/dev/ttySHSF0',
- slmodem => '/dev/ttySL0'
- );
-
-
- if (my $driver = $netc->{autodetect}{modem}{$modem_name}{driver}) {
- $driver =~ /^Hcf:/ and $type = "hcfmodem";
- $driver =~ /^Hsf:/ and $type = "hsfmodem";
- $driver =~ /^LT:/ and $type = "ltmodem";
- #- we need a better agreement to use list_modules::category2modules('network/slmodem')
- member($driver, qw(slamr slusb)) and $type = "slmodem";
- if ($type && (my $packages = $in->do_pkgs->check_kernel_module_packages("$type-kernel", if_(! -f $pkgs2path{$type}, $type)))) {
- if ($in->do_pkgs->install(@$packages)) {
- # start slmodemd when installing it (thus preventing the average user to have to restart
- # his machine in order to get a working connection):
- system("service slmodemd start") if $::isStandalone && $type eq 'slmodem';
- }
- $modem->{device} = $devices{$type} || '/dev/modem';
- return "ppp_provider";
- }
- }
-
- return "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', '/dev/ttyS14',) ] } ],
- },
- 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;
- $in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path);
- my $p_db_path = "$::prefix$db_path";
- @isp = map {
- my $country = $_;
- map {
- s!$p_db_path/$country!!;
- s/%([0-9]{3})/chr(int($1))/eg;
- $countries{$country} ||= translate($country);
- join('', $countries{$country}, $_);
- } grep { !/.directory$/ } glob_("$p_db_path/$country/*")
- } map { s!$p_db_path/!!o; s!_! !g; $_ } glob_("$p_db_path/*");
- $old_provider = $provider;
- },
- name => N("Select your provider:"),
- data => sub {
- [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/',
- list => [ N("Unlisted - edit manually"), @isp ] } ]
- },
- post => sub {
- if ($provider ne N("Unlisted - edit manually")) {
- ($country, $provider) = split('/', $provider);
- $country = { reverse %countries }->{$country};
- my %l = getVarsFromSh("$::prefix$db_path/$country/$provider");
- if (defined $old_provider && $old_provider ne $provider) {
- $modem->{connection} = $l{Name};
- $modem->{phone} = $l{Phonenumber};
- $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask);
- ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
- }
- }
- return "ppp_account";
- },
- },
-
-
- ppp_account =>
- {
- pre => sub {
- $mouse ||= {};
- $mouse->{device} ||= readlink "$::prefix/dev/mouse";
- },
- 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';
- $handle_multiple_cnx->();
- },
- },
-
-
- adsl =>
- {
- pre => sub {
- get_subwizard($wiz, 'adsl');
- $lan_detect->();
- @adsl_devices = keys %eth_intf;
-
- detect($modules_conf, $netc->{autodetect}, 'adsl');
- foreach my $modem (keys %adsl_devices) {
- push @adsl_devices, $modem if $netc->{autodetect}{adsl}{$modem};
- }
-
- detect($modules_conf, $netc->{autodetect}, 'isdn');
- if (my @isdn_modems = @{$netc->{autodetect}{isdn}}) {
- require network::isdn;
- %isdn_cards = map { $_->{description} => $_ } grep { $_->{driver} =~ /dsl/i } map { network::isdn::get_capi_card($_) } @isdn_modems;
- push @adsl_devices, keys %isdn_cards;
- }
- },
- name => N("ADSL configuration") . "\n\n" . N("Select the network interface to configure:"),
- data => [ { label => N("Net Device"), type => "list", val => \$ntf_name, allow_empty_list => 1,
- list => \@adsl_devices, format => sub { $eth_intf{$_[0]} || $adsl_devices{$_[0]} || $_[0] } } ],
- post => sub {
- my %packages = (
- 'eci' => [ 'eciadsl', 'missing' ],
- 'sagem' => [ 'eagle-usb', "/usr/sbin/eaglectrl" ],
- 'speedtouch' => [ 'speedtouch', "/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->ensure_is_installed(@{$packages{$ntf_name}}) if $packages{$ntf_name};
- if ($ntf_name eq 'speedtouch') {
- $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "/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) {
- if (my @unicorn_packages = $in->do_pkgs->check_kernel_module_packages('unicorn-kernel', 'unicorn')) {
- $in->do_pkgs->install(@unicorn_packages);
- }
- }
- if (exists($isdn_cards{$ntf_name})) {
- require network::isdn;
- $netcnx->{capi} = $isdn_cards{$ntf_name};
- $adsl_type = "capi";
- return 'adsl_account';
- }
- return 'adsl_provider';
- },
- },
-
-
- 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 = $mounted && before_leaving { fs::umount('/mnt') };
- 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";
- #- pppoa shouldn't be selected by default for ethernet devices, fallback on pppoe
- $adsl_type = "pppoe" if $adsl_type eq "pppoa";
- }
- },
- name => N("Connect to the Internet") . "\n\n" .
- N("The most common way to connect with adsl is pppoe.
-Some connections use PPTP, a few use DHCP.
-If you don't know, choose 'use PPPoE'"),
- 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->();
- if ($ntf_name eq "sagem" && member($adsl_type, qw(manual dhcp))) {
- #- "fctStartAdsl -i" builds ifcfg-ethX from ifcfg-sagem and echoes ethX
- #- it auto-detects dhcp/static modes thanks to encapsulation setting
- $ethntf = $intf->{sagem} ||= {};
- $ethntf->{DEVICE} = "`/usr/sbin/fctStartAdsl -i`";
- $ethntf->{MII_NOT_SUPPORTED} = "yes";
- }
- # process static/dhcp ethernet devices:
- if (exists($intf->{$ntf_name}) && member($adsl_type, qw(manual dhcp))) {
- $ethntf->{TYPE} = "ADSL";
- $auto_ip = $adsl_type eq 'dhcp';
- return 'lan_intf';
- }
- return 'adsl_account';
- },
- },
-
-
- adsl_account =>
- {
- pre => sub {
- network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name);
- $netc->{NET_DEVICE} = member($adsl_type, 'pppoe', 'pptp') ? $ntf_name : 'ppp0';
- $netc->{NET_INTERFACE} = 'ppp0';
- },
- name => N("Connection Configuration") . "\n\n" .
- N("Please fill or check the field below"),
- data => sub {
- [
- 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 },
- if_($adsl_type ne "capi",
- { label => N("Virtual Path ID (VPI):"), val => \$netc->{vpi}, advanced => 1 },
- { label => N("Virtual Circuit ID (VCI):"), val => \$netc->{vci}, advanced => 1 }
- ),
- if_($ntf_name eq "sagem",
- { label => N("Encapsulation:"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ],
- format => sub { $encapsulations{$_[0]} }, advanced => 1,
- },
- ),
- ],
- },
- post => sub {
- $netc->{internet_cnx_choice} = 'adsl';
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); #FIXME
- $config->{adsl} = { kind => $ntf_name, protocol => $adsl_type };
- $handle_multiple_cnx->();
- },
- },
-
-
- 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 {
- if ($ntf_name eq "Manually load a driver") {
- require network::ethernet;
- modules::interactive::load_category__prompt($in, $modules_conf, network::ethernet::get_eth_categories());
- return 'lan';
- }
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
- $::isInstall && $netc->{NET_DEVICE} eq $ethntf->{DEVICE} ? 'lan_alrd_cfg' : 'lan_protocol';
- },
- },
-
- lan_alrd_cfg =>
- {
- name => N("WARNING: this device has been previously configured to connect to the Internet.
-Modifying the fields below will override this configuration.
-Do you really want to reconfigure this device?"),
- type => "yesorno",
- default => "no",
- post => sub {
- my ($res) = @_;
- return $res ? "lan_protocol" : "alrd_end";
- }
- },
-
-
- alrd_end =>
- {
- name => N("Congratulations, the network and Internet configuration is finished.
-
-"),
- end => 1,
- },
-
-
- lan_protocol =>
- {
- pre => sub {
- $find_lan_module->();
- my $intf_type = member($module, list_modules::category2modules('network/gigabit')) ? "ethernet_gigabit" : "ethernet";
- defined($ethntf->{METRIC}) or $ethntf->{METRIC} = network::tools::get_default_metric($intf_type);
-
- $protocol = $l10n_lan_protocols{defined $auto_ip ? ($auto_ip ? 'dhcp' : 'static') : $ethntf->{BOOTPROTO}} || 0;
- },
- name => sub {
- 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};
- delete $ethntf->{TYPE} if $netcnx->{type} ne 'adsl' || !member($adsl_type, qw(manual dhcp));
- @fields = qw(IPADDR NETMASK);
- $netc->{dhcp_client} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)) || "dhcp-client";
- $netc->{dhcp_client} = "dhcp-client" if $netc->{dhcp_client} eq "dhclient";
- },
- 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" },
- if_($netcnx->{type} eq "lan",
- { text => N("Start at boot"), val => \$onboot, type => "bool" },
- ),
- if_($auto_ip,
- { label => N("DHCP client"), val => \$netc->{dhcp_client},
- list => [ qw(dhcp-client dhcpcd pump dhcpxd) ], advanced => 1 },
- ),
- ],
- },
- 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];
- }
- if (is_ip_forbidden($ethntf->{IPADDR})) {
- $in->ask_warn(N("Error"), N("Warning: IP address %s is usually reserved!", $ethntf->{IPADDR}));
- return 1;
- }
- #- test if IP address is already used (do not test for sagem DSL devices since it may use many ifcfg files)
- if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %$intf) {
- $in->ask_warn(N("Error"), N("%s already in use\n", $ethntf->{IPADDR}));
- return 1;
- }
- },
- focus_out => sub {
- $ethntf->{NETMASK} ||= netmask($ethntf->{IPADDR}) unless $_[0]
- },
- 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};
- $netc->{$_} = $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE);
- $in->do_pkgs->install($netc->{dhcp_client}) if $auto_ip;
- 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 iwconfig(8) man page for further information."),
- },
- { label =>
- #-PO: split the "xyz command extra argument" translated string into two lines if it's bigger than the english one
- 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}};
- if ($module =~ /^prism2_/) {
- $in->do_pkgs->install('prism2-utils');
- if ($ethntf->{WIRELESS_ESSID}) {
- my $update_vars_in_wlan = sub { #- FIXME: to be improved (quotes, comments) and moved in common files
- my ($file, $vars) = @_;
- substInFile {
- while (my ($key, $value) = each(%$vars)) {
- s/^#?\Q$key\E=(?:"[^#]*"|[^#\s]*)(\s*#.*)?/$key=$value$1/ and delete $vars->{$key};
- }
- $_ .= join('', map { "$_=$vars->{$_}\n" } keys %$vars) if eof;
- } $file;
- };
- my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf";
- my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]);
- push @wlan_devices, $ethntf->{DEVICE} unless member($ethntf->{DEVICE}, @wlan_devices);
- #- enable device and make it use the choosen ESSID
- $update_vars_in_wlan->($wlan_conf_file,
- {
- WLAN_DEVICES => qq("@wlan_devices"),
- "SSID_$ethntf->{DEVICE}" => qq("$ethntf->{WIRELESS_ESSID}"),
- "ENABLE_$ethntf->{DEVICE}" => "y"
- });
- my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$ethntf->{WIRELESS_ESSID}";
- #- copy default settings for this ESSID if config file doesn't exist
- -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file);
- #- enable/disable encryption
- $update_vars_in_wlan->($wlan_ssid_file,
- {
- (map { $_ => $ethntf->{WIRELESS_ENC_KEY} ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)),
- AuthType => $ethntf->{WIRELESS_ENC_KEY} ? qq("sharedkey") : qq("opensystem"),
- if_($ethntf->{WIRELESS_ENC_KEY},
- dot11WEPDefaultKeyID => 0,
- dot11WEPDefaultKey0 => qq("$ethntf->{WIRELESS_ENC_KEY}")
- )
- });
- #- apply settings on wlan interface
- require services;
- services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan');
- }
- }
- return "static_hostname";
- },
- },
-
- static_hostname =>
- {
- pre => sub {
- if ($ethntf->{IPADDR}) {
- $netc->{dnsServer} ||= dns($ethntf->{IPADDR});
- $gateway_ex = gateway($ethntf->{IPADDR});
- # $netc->{GATEWAY} ||= gateway($ethntf->{IPADDR});
- if ($ntf_name eq "sagem") {
- my @sagem_ip = split(/\./, $ethntf->{IPADDR});
- @sagem_ip[3] = 254;
- $netc->{GATEWAY} = join(".", @sagem_ip);
- }
- }
- },
- name => N("Please enter your host name.
-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 %all_eth_intf ],
- format => sub { $all_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);
- $ethntf->{ONBOOT} = $res if $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
- my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
- -f $ifcfg_file and substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } $ifcfg_file;
- return $after_start_on_boot_step->();
- },
- },
-
- isdn_dial_on_boot =>
- {
- pre => sub {
- $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written
- @isdn_dial_methods = ({ name => N("Automatically at boot"),
- ONBOOT => 1, DIAL_ON_IFUP => 1 },
- { name => N("By using Net Applet in the system tray"),
- ONBOOT => 0, DIAL_ON_IFUP => 1 },
- { name => N("Manually (the interface would still be activated at boot)"),
- ONBOOT => 1, DIAL_ON_IFUP => 0 });
- my $method = find {
- $_->{ONBOOT} eq text2bool($intf->{ippp0}{ONBOOT}) &&
- $_->{DIAL_ON_IFUP} eq text2bool($intf->{ippp0}{DIAL_ON_IFUP})
- } @isdn_dial_methods;
- #- use net_applet by default
- $isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name};
- },
- name => N("How do you want to dial this connection?"),
- data => sub {
- [ { type => "list", val => \$isdn->{dial_method}, list => [ map { $_->{name} } @isdn_dial_methods ] } ]
- },
- post => sub {
- my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods;
- $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
- return $after_start_on_boot_step->();
- },
- },
-
- restart =>
- {
- name => N("The network needs to be restarted. Do you want to restart it?"),
- 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 occurred 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($netc);
- 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($netc);
- 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 occurred during configuration.
-Test your connection via net_monitor or mcc. If your connection doesn't work, you might want to relaunch the configuration.");
- },
- end => 1,
- },
- },
- };
-
- 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';
- $netc->{$_} = 'eth0' foreach qw(NET_DEVICE NET_INTERFACE);
- $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, $modules_conf, $::prefix, $netc, $intf);
-
- $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
- $netcnx->{type} =~ /adsl/ or run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null");
-}
-
-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/*');
- connect_backend($o->{netc});
-}
-
-sub stop_internet {
- my ($o) = @_;
- init_globals($o);
- disconnect_backend($o->{netc});
-}
-
-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 3a99c2f96..000000000
--- a/perl-install/network/network.pm
+++ /dev/null
@@ -1,474 +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 ($o_file) = @_;
- my $s = cat_($o_file || "$::prefix/etc/resolv.conf");
- { nameserver => [ $s =~ /^\s*nameserver\s+(\S+)/mg ],
- search => [ if_($s =~ /^\s*search\s+(.*)/m, split(' ', $1)) ] };
-}
-
-sub read_resolv_conf {
- my ($o_file) = @_;
- my $resolv_conf = read_resolv_conf_raw($o_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 ($o_file) = @_;
- my $s = cat_($o_file || "$::prefix/etc/dhcpd.conf");
- { option_routers => [ $s =~ /^\s*option routers\s+(\S+);/mg ],
- subnet_mask => [ if_($s =~ /^\s*option subnet-mask\s+(.*);/mg, split(' ', $1)) ],
- domain_name => [ if_($s =~ /^\s*option domain-name\s+"(.*)";/mg, split(' ', $1)) ],
- domain_name_servers => [ if_($s =~ /^\s*option domain-name-servers\s+(.*);/m, split(' ', $1)) ],
- dynamic_bootp => [ if_($s =~ /^\s*range dynamic-bootp\s+\S+\.(\d+)\s+\S+\.(\d+)\s*;/m, split(' ', $1)) ],
- default_lease_time => [ if_($s =~ /^\s*default-lease-time\s+(.*);/m, split(' ', $1)) ],
- max_lease_time => [ if_($s =~ /^\s*max-lease-time\s+(.*);/m, split(' ', $1)) ] };
-}
-
-sub read_squid_conf {
- my ($o_file) = @_;
- my $s = cat_($o_file || "$::prefix/etc/squid/squid.conf");
- { http_port => [ $s =~ /^\s*http_port\s+(.*)/mg ],
- cache_size => [ if_($s =~ /^\s*cache_dir diskd\s+(.*)/mg, split(' ', $1)) ],
- admin_mail => [ if_($s =~ /^\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) = @_;
-
- require network::ethernet;
- my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
- $intf->{HWADDR} &&= $mac_address; #- set HWADDR to MAC address if required
-
- 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())),
- });
-
- defined($intf->{METRIC}) or $intf->{METRIC} = network::tools::get_default_metric(network::tools::get_interface_type($intf)),
- $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 METRIC MII_NOT_SUPPORTED TYPE),
- 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))
- );
- substInFile { s/^DEVICE='(`.*`)'/DEVICE=$1/g } $file; #- remove quotes if DEVICE is the result of a command
-
- chmod $intf->{WIRELESS_ENC_KEY} ? 0700 : 0755, $file; #- hide WEP key for non-root users
- log::explanations("written $intf->{DEVICE} interface configuration in $file");
-}
-
-sub add2hosts {
- my ($file, $hostname, @ips) = @_;
- my ($sub_hostname) = $hostname =~ /(.*?)\./;
-
- my %l;
- foreach (cat_($file)) {
- my ($ip, $aliases) = /^\s*(\S+)\s+(\S+.*)$/ or next;
- push @{$l{$ip}}, difference2([ split /\s+/, $aliases ], [ $hostname, $sub_hostname ]);
- } cat_($file);
-
- push @{$l{$_}}, $hostname, if_($sub_hostname, $sub_hostname) foreach grep { $_ } @ips;
-
- log::explanations("writing host information to $file");
- output($file, map { "$_\t\t" . join(" ", @{$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);
-
- if (!$::isInstall) {
- run_program::run("/usr/bin/run-parts", "--arg", $netc->{HOSTNAME}, "/etc/sysconfig/network-scripts/hostname.d");
- }
-}
-
-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} = undef;
- $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")) {
- my ($device) = /^ifcfg-([A-Za-z0-9.:]+)$/;
- next if $device =~ /.rpmnew$|.rpmsave$/;
- if ($device && $device ne 'lo') {
- my $intf = findIntf($intf, $device);
- add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") });
- $intf->{DEVICE} ||= $device;
- $intf->{WIRELESS_ENC_KEY} = network::tools::get_wep_key_from_iwconfig($intf->{WIRELESS_ENC_KEY});
- }
- }
- if (my $default_intf = network::tools::get_default_gateway_interface($netc, $intf)) {
- $netcnx->{type} ||= network::tools::get_interface_type($intf->{$default_intf});
- }
-}
-
-#- FIXME: this is buggy, use network::tools::get_default_gateway_interface
-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::ethernet::get_eth_categories());
- my @all_dev = sort map { $_->[0] } network::ethernet::get_eth_cards($modules_conf);
-
- #- only for a single ethernet network card
- my @ether_dev = grep { /^eth[0-9]+$/ && `LC_ALL= LANG= $::prefix/sbin/ip -o link show $_ 2>/dev/null` =~ m|\slink/ether\s| } @all_dev;
- @ether_dev == 1 or return;
-
- my $dhcp_intf = $ether_dev[0];
- log::explanations("easy_dhcp: found $dhcp_intf");
-
- put_in_hash($netc, {
- NETWORKING => "yes",
- DHCP => "yes",
- NET_DEVICE => $dhcp_intf,
- NET_INTERFACE => $dhcp_intf,
- });
- $intf->{$dhcp_intf} ||= {};
- put_in_hash($intf->{$dhcp_intf}, {
- DEVICE => $dhcp_intf,
- BOOTPROTO => 'dhcp',
- NETMASK => '255.255.255.0',
- ONBOOT => '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, $modules_conf, $_prefix, $netc, $intf) = @_;
- my $etc = "$::prefix/etc";
- if (!$::testing) {
- require network::ethernet;
- network::ethernet::update_iftab();
- network::ethernet::configure_eth_aliases($modules_conf);
-
- $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) unless $netc->{DHCP};
- if ($::isInstall && ! -e "/etc/resolv.conf") {
- #- symlink resolv.conf in install root too so that updates and suppl media can be added
- symlink "$etc/resolv.conf", "/etc/resolv.conf";
- }
- foreach (grep { !/^ppp\d+/ } keys %$intf) {
- unlink("$etc/sysconfig/network-scripts/$_");
- write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_", $intf->{$_}, $netc, $::prefix);
- }
- add2hosts("$etc/hosts", $netc->{HOSTNAME}, "127.0.0.1") if $netc->{HOSTNAME};
- 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});
- services::start_service_on_boot("tmdns");
- services::restart("tmdns");
- } else {
- #- disable zeroconf
- require services;
- #- write blank hostname so that drakconnect doesn't assume zeroconf is enabled
- -f "$etc/tmdns.conf" and write_zeroconf("$etc/tmdns.conf", '');
- if (-f "$etc/rc.d/init.d/tmdns") {
- services::stop("tmdns");
- services::do_not_start_service_on_boot("tmdns");
- }
- }
- 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 94ce0abb1..000000000
--- a/perl-install/network/shorewall.pm
+++ /dev/null
@@ -1,163 +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(@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', 'loc', 'ACCEPT' ]),
- [ 'fw', 'net', 'ACCEPT' ],
- [ 'net', 'all', 'DROP', 'info' ],
- [ 'all', 'all', 'REJECT', 'info' ],
- );
- set_config_file('rules',
- if_(cat_("$::prefix$connect_file") =~ /pptp/, [ 'ACCEPT', 'fw', 'loc:10.0.0.138', 'tcp', '1723' ]),
- if_(cat_("$::prefix$connect_file") =~ /pptp/, [ 'ACCEPT', 'fw', 'loc:10.0.0.138', 'gre' ]),
- (map {
- map_each { [ 'ACCEPT', $_, 'fw', $::a, join(',', @$::b), '-' ] } %ports_by_proto
- } ('net', if_($conf->{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 57eba8234..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
- unix charset = ISO8859-15
- os level = 18
- local master = No
- dns proxy = No
- idmap uid = 10000-20000
- idmap 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 c38903028..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::mount_options::set_default($fs_entry);
- $fs_entry;
-}
-
-1;
-
diff --git a/perl-install/network/test.pm b/perl-install/network/test.pm
deleted file mode 100644
index 7c25fce05..000000000
--- a/perl-install/network/test.pm
+++ /dev/null
@@ -1,158 +0,0 @@
-package network::test; # $Id$
-
-use strict;
-use MDK::Common;
-use run_program;
-use Socket;
-
-sub new {
- my ($class, $o_hostname) = @_;
- bless {
- hostname => $o_hostname || "mandrakesoft.com"
- }, $class;
-}
-
-#- launch synchronous test, will hang until the test finishes
-sub test_synchronous {
- my ($o) = @_;
- ($o->{address}, $o->{ping}) = resolve_and_ping($o->{hostname});
- $o->{done} = 1;
-}
-
-#- launch asynchronous test, won't hang
-sub start {
- my ($o) = @_;
- $o->{done} = 0;
- $o->{kid} = bg_command->new(sub {
- my ($address, $ping) = resolve_and_ping($o->{hostname});
- print "$address|$ping\n";
- });
-}
-
-#- abort asynchronous test
-sub abort {
- my ($o) = @_;
- if ($o->{kid}) {
- kill -9, $o->{kid}{pid};
- undef $o->{kid};
- }
-}
-
-#- returns a true value if the test is finished, usefull for asynchronous tests
-sub is_done {
- my ($o) = @_;
- $o->update_status;
- to_bool($o->{done});
-}
-
-#- return a true value if the connection works (hostname resolution and ping)
-sub is_connected {
- my ($o) = @_;
- to_bool(defined($o->{hostname}) && defined($o->{ping}));
-}
-
-#- get hostname used in test for resolution and ping
-sub get_hostname {
- my ($o) = @_;
- $o->{hostname};
-}
-
-#- get resolved address (if any) of given hostname
-sub get_address {
- my ($o) = @_;
- $o->{address};
-}
-
-#- get ping (if any) to given hostname
-sub get_ping {
- my ($o) = @_;
- $o->{ping};
-}
-
-sub resolve_and_ping {
- my ($hostname) = @_;
- require Net::Ping;
- require Time::HiRes;
- 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');
- }
- $p->hires; #- get ping as float
- #- default timeout is 5 seconds
- my ($ret, $ping, $address) = $p->ping($hostname, 5);
- if ($ret) {
- return $address, $ping;
- } elsif (defined($ret)) {
- return $address;
- }
-}
-
-sub update_status {
- my ($o) = @_;
- if ($o->{kid}) {
- my $fd = $o->{kid}{fd};
- fcntl($fd, c::F_SETFL(), c::O_NONBLOCK()) or die "can't fcntl F_SETFL: $!";
- local $| = 1;
- if (defined(my $output = <$fd>)) {
- ($o->{address}, $o->{ping}) = $output =~ /^([\d\.]+)\|([\d\.,]+)*$/;
- $o->{done} = 1;
- undef $o->{kid};
- }
- }
-}
-
-1;
-
-=head1 network::test
-
-=head2 Test synchronously
-
-#- resolve and get ping to hostname from command line if given, else to Mandrakesoft
-use lib qw(/usr/lib/libDrakX);
-use network::test;
-
-my $net_test = network::test->new($ARGV[0]);
-$net_test->test_synchronous;
-
-my $is_connected = $net_test->is_connected;
-my $hostname = $net_test->get_hostname;
-my $address = $net_test->get_address;
-my $ping = $net_test->get_ping;
-
-print "connected: $is_connected
-host: $hostname
-resolved host: $address
-ping to host: $ping
-";
-
-=head2 Test asynchronously
-
-#- resolve and get ping to hostname from command line if given, else to Mandrakesoft
-#- prints a "." every 10 miliseconds during connection test
-use lib qw(/usr/lib/libDrakX);
-use network::test;
-
-my $net_test = network::test->new($ARGV[0]);
-$net_test->start;
-
-do {
- print ".\n";
- select(undef, undef, undef, 0.01);
-} while !$net_test->is_done;
-
-my $is_connected = $net_test->is_connected;
-my $hostname = $net_test->get_hostname;
-my $address = $net_test->get_address;
-my $ping = $net_test->get_ping;
-
-print "connected: $is_connected
-host: $hostname
-resolved host: $address
-ping to host: $ping
-";
-
-=cut
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
deleted file mode 100644
index d573e41d8..000000000
--- a/perl-install/network/tools.pm
+++ /dev/null
@@ -1,293 +0,0 @@
-package network::tools; # $Id$
-
-use strict;
-use common;
-use run_program;
-use fsedit;
-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 start_interface stop_interface);
-
-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 {
- my ($netc) = @_;
- run_program::rooted($::prefix, "ifup $netc->{NET_INTERFACE} &");
-}
-
-sub disconnect_backend {
- my ($netc) = @_;
- run_program::rooted($::prefix, "ifdown $netc->{NET_INTERFACE} &");
-}
-
-sub bg_command_as_root {
- my ($name, @args) = @_;
- #- FIXME: duplicate code from common::require_root_capability
- if (check_for_xserver() && fuzzy_pidofs(qr/\bkwin\b/) > 0) {
- run_program::raw({ detach => 1 }, "kdesu", "--ignorebutton", "-c", "$name @args");
- } else {
- run_program::raw({ detach => 1 }, [ 'consolehelper', $name ], @args);
- }
-}
-
-sub start_interface {
- my ($intf) = @_;
- bg_command_as_root('/sbin/ifup', $intf);
-}
-
-sub stop_interface {
- my ($intf) = @_;
- bg_command_as_root('/sbin/ifdown', $intf);
-}
-
-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();
- fs::get_info_from_fstab($all_hds);
- if (my $part = find { $_->{device_windobe} eq 'C' } fs::get::fstab($all_hds)) {
- my $source = find { -d $_ && -r "$_/$file" } map { "$part->{mntpoint}/$_" } qw(windows/system winnt/system windows/system32/drivers winnt/system32/drivers);
- log::explanations("Seek in $source to find firmware");
- $source;
- } else {
- my $failed = N("No partition available");
- log::explanations($failed);
- undef, $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;
- if (eval { fs::mount(devices::make($floppy), '/mnt', 'vfat', 'readonly'); 1 }) {
- log::explanations("Mounting floppy device $floppy in /mnt");
- '/mnt';
- } else {
- my $failed = N("Floppy access error, unable to mount device %s", $floppy);
- log::explanations($failed);
- undef, $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 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;
-}
-
-
-#- returns interface whose IP address matchs given IP address, according to its network mask
-sub find_matching_interface {
- my ($intf, $address) = @_;
- my @ip = split '\.', $address;
- find {
- my @intf_ip = split '\.', $intf->{$_}{IPADDR} or return;
- my @mask = split '\.', $intf->{$_}{NETMASK} or return;
- every { $_ } mapn { ($_[0] & $_[2]) == ($_[1] & $_[2]) } \@intf_ip, \@ip, \@mask;
- } sort keys %$intf;
-}
-
-#- returns gateway interface if found
-sub get_default_gateway_interface {
- my ($netc, $intf) = @_;
- my @intfs = sort keys %$intf;
- `$::prefix/sbin/ip route show` =~ /^default.*\s+dev\s+(\S+)/m && $1 ||
- $netc->{GATEWAYDEV} ||
- $netc->{GATEWAY} && find_matching_interface($intf, $netc->{GATEWAY}) ||
- (find { get_interface_type($intf->{$_}) eq 'adsl' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'isdn' && text2bool($intf->{$_}{DIAL_ON_IFUP}) } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'modem' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'ethernet' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
-}
-
-#- returns (gateway_interface, interface is up, gateway address, dns server address)
-sub get_internet_connection {
- my ($netc, $intf, $o_gw_intf) = @_;
- my @routes = `$::prefix/sbin/ip route show`;
- my ($gw_intf, $is_up, $gw_address);
- $gw_intf = $o_gw_intf || get_default_gateway_interface($netc, $intf) or return;
- $is_up = to_bool(grep { /\s+dev\s+$gw_intf(?:\s+|$)/ } @routes);
- ($gw_address) = join('', @routes) =~ /^default\s+via\s+(\S+).*\s+dev\s+$gw_intf(?:\s+|$)/m;
- return $gw_intf, $is_up, $gw_address, $netc->{dnsServer};
-}
-
-sub get_interface_type {
- my ($interface) = @_;
- member($interface->{TYPE}, "xDSL", "ADSL") && "adsl" ||
- $interface->{DEVICE} =~ /^(eth|ath|wlan)/ && "ethernet" ||
- $interface->{DEVICE} =~ /^ippp/ && "isdn" ||
- $interface->{DEVICE} =~ /^ppp/ && "modem" ||
- "unknown";
-}
-
-sub get_default_metric {
- my ($type) = @_;
- my @known_types = ("ethernet_gigabit", "ethernet", "adsl", "isdn", "modem", "unknown");
- my $idx;
- eval { $idx = find_index { $type eq $_ } @known_types };
- $idx = @known_types if $@;
- $idx * 10;
-}
-
-1;