summaryrefslogtreecommitdiffstats
path: root/perl-install/network
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network')
-rw-r--r--perl-install/network/adsl.pm184
-rw-r--r--perl-install/network/adsl_consts.pm284
-rw-r--r--perl-install/network/drakfirewall.pm4
-rw-r--r--perl-install/network/ethernet.pm127
-rw-r--r--perl-install/network/isdn.pm89
-rw-r--r--perl-install/network/isdn_consts.pm115
-rw-r--r--perl-install/network/modem.pm36
-rw-r--r--perl-install/network/netconnect.pm534
-rw-r--r--perl-install/network/network.pm189
-rw-r--r--perl-install/network/nfs.pm2
-rw-r--r--perl-install/network/shorewall.pm6
-rw-r--r--perl-install/network/smb.pm52
-rw-r--r--perl-install/network/smbnfs.pm6
-rw-r--r--perl-install/network/test.pm158
-rw-r--r--perl-install/network/tools.pm112
15 files changed, 1376 insertions, 522 deletions
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index 2089dd229..7b1566b92 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -16,11 +16,11 @@ sub get_wizard {
my $netc = $wiz->{var}{netc};
my %l = (
- 'pppoe' => N("use pppoe"),
- 'pptp' => N("use pptp"),
- 'dhcp' => N("use dhcp"),
+ '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' => 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
);
@@ -34,11 +34,11 @@ sub get_wizard {
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'"),
+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 ] },
+ label => N("ADSL connection type:"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
],
pre => sub {
$wiz->{var}{adsl}{type} = $l{sagem}; # debug
@@ -67,15 +67,13 @@ If you don't know, choose 'use pppoe'"),
sub adsl_probe_info {
my ($adsl, $netc, $adsl_type, $o_adsl_modem) = @_;
my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf";
- my $pptp_file = "$::prefix/etc/sysconfig/network-scripts/net_cnx_up";
my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type eq 'pppoe') && -f $pppoe_file;
my $login = $pppoe_conf{USER};
foreach (qw(/etc/ppp/peers/ppp0 /etc/ppp/options /etc/ppp/options.adsl)) {
($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$::prefix/$_") if !$login && -r "$::prefix/$_";
}
- ($login) = map { if_(/\sname\s+([^ \n]+)/, $1) } cat_($pptp_file) if (! defined $adsl_type || $adsl_type eq 'pptp') && -r $pptp_file;
my $passwd = passwd_by_login($login);
- if (!$netc->{vpi} && !$netc->{vpi} && member($o_adsl_modem, qw(eci speedtouch))) {
+ 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"));
}
@@ -95,12 +93,27 @@ sub adsl_detect() {
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, $adsl, $netc, $adsl_device, $adsl_type, $o_netcnx) = @_;
+ 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";
@@ -115,7 +128,9 @@ modprobe $bewan_module
sleep 10
),
stop => qq(modprobe -r $bewan_module),
- pppd_options => "plugin pppoatm.so $netc->{vpi}." . hex($netc->{vci}),
+ plugin => {
+ pppoa => "pppoatm.so $netc->{vpi}." . hex($netc->{vci})
+ },
ppp_options => qq(
lock
ipparam ppp0
@@ -135,12 +150,15 @@ sync
speedtouch =>
{
- start => '/usr/sbin/modem_run -k -n 2 -f /usr/share/speedtouch/mgmt.o',
+ 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 => '"/usr/sbin/pppoa3 -e 1 -c"
-plugin pppoatm.so
-' . join('.', hex($netc->{vpi}), hex($netc->{vci})),
+ pppoa => qq("/usr/sbin/pppoa3 -c")
+ },
+ plugin => {
+ pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci})),
},
ppp_options => qq(
sync
@@ -157,11 +175,12 @@ noaccomp),
},
sagem =>
{
- start => "/usr/sbin/eaglectrl -w",
+ modules => [ qw(eagle-usb) ],
+ start => '/usr/sbin/eaglectrl -d',
stop => "/usr/bin/killall pppoa",
get_intf => "/usr/sbin/eaglectrl -i",
server => {
- pppoa => qq("/usr/sbin/pppoa -I `/usr/sbin/eaglectrl -s; /usr/sbin/eaglectrl -i`"),
+ pppoa => q("/usr/sbin/fctStartAdsl -t 1 -i"),
},
ppp_options => qq(
mru 1492
@@ -172,8 +191,9 @@ noaccomp -am
novjccomp),
aliases => [
['char-major-108', 'ppp_generic'],
- ['tty-ldisc-14', 'ppp_synctty'],
- ['tty-ldisc-13', 'n_hdlc']
+ ['tty-ldisc-3', 'ppp_async'],
+ ['tty-ldisc-13', 'n_hdlc'],
+ ['tty-ldisc-14', 'ppp_synctty']
],
},
eci =>
@@ -196,16 +216,40 @@ lcp-echo-interval 0)
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/) {
+ 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",
@@ -242,9 +286,12 @@ 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 = 'noipdefault' unless $adsl_type eq 'pptp';
output("$::prefix/etc/ppp/peers/ppp0",
qq(noauth
-noipdefault
+$noipdefault
$modems{$adsl_device}{ppp_options}
kdebug 1
nopcomp
@@ -255,25 +302,39 @@ maxfail 25
persist
usepeerdns
defaultroute
-pty $modems{$adsl_device}{server}{$adsl_type}
+$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') {
- substInFile {
- s/ETH=.*\n/ETH=$netc->{NET_DEVICE}\n/;
- s/USER=.*\n/USER=$adsl->{login}\n/;
- s/DNS1=.*\n/DNS1=$netc->{dnsServer2}\n/;
- s/DNS2=.*\n/DNS2=$netc->{dnsServer3}\n/;
- } "$::prefix/etc/ppp/pppoe.conf";
+ 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");
+ }
}
-# pptp => {
-# connect => "/usr/bin/pptp 10.0.0.138 name $adsl->{login}",
-# disconnect => "/usr/bin/killall pptp pppd\n",
-# },
# pppoe => {
# # we do not call directly pppd, rp-pppoe take care of "plugin rp-pppoe.so" peers option and the like
# connect => "LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /usr/sbin/adsl-start",
@@ -282,37 +343,54 @@ user "$adsl->{login}"
# },
}
-
+
#- FIXME:
#- ppp0 and ippp0 are hardcoded
- #- pptp has to be done within pppd (no more use of /usr/bin/pptp)
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));
- # sagem specific stuff
+ #- 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') {
- my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
- # set vpi and vci parameters for sagem
- foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) {
- substInFile {
- s/VCI=.*\n/VCI=$l{vci}\n/;
- s/VPI=.*\n/VPI=$l{vpi}\n/;
- s/Encapsulation=.*\n/Encapsulation=$l{Encapsulation}\n/;
- } "$::prefix$cfg_file";
- }
+ $netc->{static_ip} = $intf->{sagem}{IPADDR} if $adsl_type eq 'manual';
+ sagem_set_parameters($netc);
}
-
- # set aliases:
+
+ #- set aliases
if (exists $modems{$adsl_device}{aliases}) {
- modules::set_alias($_->[0], $_->[1]) foreach @{$modems{$adsl_device}{aliases}};
- $::isStandalone and modules::write_conf();
+ $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");
}
- $netc->{NET_INTERFACE} = 'ppp0';
- write_cnx_script($netc);
+ #- 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
index ee81efbf4..0f0449b40 100644
--- a/perl-install/network/adsl_consts.pm
+++ b/perl-install/network/adsl_consts.pm
@@ -4,6 +4,8 @@ package network::adsl_consts; # $Id$
use vars qw(@ISA @EXPORT);
use common;
+use utf8;
+use encoding "utf8";
@ISA = qw(Exporter);
@EXPORT = qw(@adsl_data);
@@ -22,9 +24,18 @@ our %adsl_data = (
# 5 RFC2364 PPPoA LLC,
# 6 RFC2364 PPPoA VCmux
# dns are provided for when !usepeerdns in peers config file
- # method : pppoa, pppoe or static
+ # method : PPPoA, pppoe, static or dhcp
# 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,
@@ -33,6 +44,14 @@ our %adsl_data = (
method => 'pppoa',
},
+ N("Austria") . "|AON" =>
+ {
+ vpi => 1,
+ vci => 20,
+ Encapsulation => 6,
+ method => 'pppoa',
+ },
+
N("Austria") . "|Telstra" =>
{
vpi => 8,
@@ -86,7 +105,7 @@ our %adsl_data = (
N("Brazil") . "|Velox/Telemar" =>
{
vpi => 0,
- vci => 33,
+ vci => 21,
Encapsulation => 1,
method => 'pppoe',
},
@@ -123,6 +142,166 @@ our %adsl_data = (
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,
@@ -130,7 +309,7 @@ our %adsl_data = (
Encapsulation => 3,
},
- N("France") . "|Free non dégroupé 512/128 & 1024/128" =>
+ N("France") . "|Free non dégroupé 512/128 & 1024/128" =>
{
vpi => 8,
vci => 23,
@@ -141,7 +320,7 @@ our %adsl_data = (
DOMAINNAME2 => 'free.fr',
},
- N("France") . "|Free dégroupé 1024/256 (mini)" =>
+ N("France") . "|Free dégroupé 1024/256 (mini)" =>
{
vpi => 8,
vci => 24,
@@ -151,7 +330,7 @@ our %adsl_data = (
DOMAINNAME2 => 'free.fr',
},
- N("France") . "|n9uf tel9com 512 & dégroupé 1024" =>
+ N("France") . "|n9uf tel9com 512 & dégroupé 1024" =>
{
vpi => 8,
vci => 23,
@@ -161,7 +340,7 @@ our %adsl_data = (
method => 'pppoa',
},
- N("France") . "|Cegetel non dégroupé 512 IP/ADSL et dégroupé" =>
+ N("France") . "|Cegetel non dégroupé 512 IP/ADSL et dégroupé" =>
{
vpi => 8,
vci => 23,
@@ -193,7 +372,7 @@ our %adsl_data = (
DOMAINNAME2 => 'wanadoo.fr',
},
- N("France") . "|Télé2 128k " =>
+ N("France") . "|Télé2" =>
{
vpi => 8,
vci => 23,
@@ -273,6 +452,14 @@ our %adsl_data = (
method => 'pppoe',
},
+ N("Israel") . "|Bezeq" =>
+ {
+ vpi => 8,
+ vci => 30,
+ Encapsulation => 6,
+ method => 'pppoa',
+ },
+
N("Italy") . "|Telecom Italia" =>
{
vpi => 8,
@@ -290,7 +477,7 @@ our %adsl_data = (
Encapsulation => 3,
},
- N("Italy") . "|Tiscali.it" =>
+ N("Italy") . "|Tiscali.it, Alice" =>
{
vpi => 8,
vci => 23,
@@ -300,6 +487,22 @@ our %adsl_data = (
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,
@@ -308,6 +511,30 @@ our %adsl_data = (
method => 'pppoa',
},
+ N("Netherlands") . "|Eager Telecom" =>
+ {
+ vpi => 0,
+ vci => 21,
+ Encapsulation => 3,
+ method => 'dhcp',
+ },
+
+ N("Netherlands") . "|Tiscali" =>
+ {
+ vpi => 0,
+ vci => 22,
+ Encapsulation => 3,
+ method => 'dhcp',
+ },
+
+ N("Netherlands") . "|Versatel" =>
+ {
+ vpi => 0,
+ vci => 20,
+ Encapsulation => 3,
+ method => 'dhcp',
+ },
+
N("Poland") . "|Telekomunikacja Polska (TPSA/neostrada)" =>
{
vpi => 0,
@@ -318,14 +545,33 @@ our %adsl_data = (
method => 'pppoa',
},
+ N("Poland") . "|Netia neostrada" =>
+ {
+ vpi => 8,
+ vci => 23,
+ Encapsulation => 1,
+ method => 'pppoe',
+ },
+
N("Portugal") . "|PT" =>
{
vpi => 0,
vci => 23,
Encapsulation => 1,
},
-
- N("Spain") . "|Telefónica IP dinámica" =>
+
+ 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,
@@ -334,7 +580,7 @@ our %adsl_data = (
dnsServer3 => '80.58.0.97',
method => 'pppoe',
},
- N("Spain") . "|Telefónica ip fija" =>
+ N("Spain") . "|Telefónica ip fija" =>
{
vpi => 8,
vci => 20,
@@ -379,6 +625,22 @@ our %adsl_data = (
method => 'pppoa',
},
+ N("Thailand") . "|Asianet" =>
+ {
+ vpi => 0,
+ vci => 64,
+ Encapsulation => 1,
+ method => 'pppoe',
+ },
+
+ N("United Arab Emirates") . "|Etisalat" =>
+ {
+ vpi => 0,
+ vci => 32,
+ Encapsulation => 5,
+ method => 'pppoe',
+ },
+
N("United Kingdom") . "|Tiscali UK " =>
{
vpi => 0,
diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm
index 5ade3db27..16699ba3d 100644
--- a/perl-install/network/drakfirewall.pm
+++ b/perl-install/network/drakfirewall.pm
@@ -47,7 +47,7 @@ my @all_servers =
{
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',
+ ports => '137/tcp 137/udp 138/tcp 138/udp 139/tcp 139/udp 1024:1100/tcp 1024:1100/udp',
hide => 1,
},
{
@@ -130,7 +130,7 @@ sub set_ports {
my ($in, $disabled, $ports) = @_;
my $shorewall = network::shorewall::read($in, 'not_silent') || network::shorewall::default_interfaces($in) or die N("No network card");
if (!$disabled || -x "$::prefix/sbin/shorewall") {
- $in->do_pkgs->ensure_is_installed('shorewall', '/sbin/shorewall', $::isInstall) or return;
+ $in->do_pkgs->ensure_binary_is_installed('shorewall', 'shorewall', $::isInstall) or return;
$shorewall->{disabled} = $disabled;
$shorewall->{ports} = $$ports;
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 6f9cc8c85..8594f8708 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -11,26 +11,18 @@ use network::tools;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
-@EXPORT = qw(conf_network_card_backend);
+@EXPORT = qw(get_eth_categories);
sub write_ether_conf {
- my ($in, $netcnx, $netc, $intf) = @_;
- configureNetwork2($in, $::prefix, $netc, $intf);
+ 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};
- set_cnx_script($netc, "local network",
-qq(
-/etc/rc.d/init.d/network restart
-),
-qq(
-/etc/rc.d/init.d/network stop
-/sbin/ifup lo
-), $netcnx->{type});
}
- $::isStandalone and modules::write_conf();
+ $::isStandalone and $modules_conf->write;
1;
}
@@ -38,44 +30,74 @@ qq(
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]" ]
-sub get_eth_cards() {
+#
+# 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();
- modules::mergein_conf();
my $saved_driver;
+ # compute device description and return (interface, driver, description) tuples:
return map {
my $interface = $_;
my $description;
- my $a = c::getNetDriver($interface) || modules::get_alias($interface);
+ # 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",
+ "hostap" => undef, #- should be either "hostap_plx", "hostap_pci" or "hostap_cs"
+ "DL2K" => "dl2k",
+ );
+ $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 and $drv =~ s!.*/!!) {
+ 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 == 0;
+ $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 == 0;
+ $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) ]
@@ -84,57 +106,38 @@ sub get_eth_cards() {
sub get_eth_cards_names {
my (@all_cards) = @_;
-
- foreach my $card (@all_cards) {
- modules::remove_alias($card->[1]);
- modules::set_alias($card->[0], $card->[1]);
- }
-
{ 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|;
+}
-#- conf_network_card_backend : configure the specified network interface
-# WARNING: you have to setup the ethernet cards, by calling load_category($in, 'network/main|gigabit|usb', !$::expert, 1)
-# or load_category_backend before calling this function.
-#- input
-#- $netc
-#- $intf
-#- $type : type of interface, must be given if $interface is : string : "static" or "dhcp"
-#- $interface : set this interface and return it in a proper form.
-#- $ipadr : facultative, ip address of the interface : string
-#- $netadr : facultative, netaddress of the interface : string
-#- when $interface is given, informations are written in $intf and $netc.
-#- $intf output: $device is the result of
-#- $intf->{$device}->{DEVICE} : which device is concerned : $device is the result of $interface =~ /(eth[0-9]+)/; my $device = $1;;
-#- $intf->{$device}->{BOOTPROTO} : $type
-#- $intf->{$device}->{NETMASK} : '255.255.255.0'
-#- $intf->{$device}->{NETWORK} : $netadr
-#- $intf->{$device}->{ONBOOT} : "yes"
-#- $netc output:
-#- $netc->{NET_DEVICE} : this is used to indicate that this eth card is used to connect to internet : $device
-#- output:
-#- $device : returned passed interface name
-sub conf_network_card_backend {
- my ($netc, $intf, $type, $interface, $o_ipadr, $o_netadr) = @_;
- #-type =static or dhcp
-
- $interface =~ /eth[0-9]+/ or die("the interface is not an ethx");
-
- # FIXME: this is wrong regarding some wireless interfaces or/and if user play if ifname(1):
- $netc->{NET_DEVICE} = $interface; #- one consider that there is only ONE Internet connection device..
-
- @{$intf->{$interface}}{qw(DEVICE BOOTPROTO NETMASK NETWORK ONBOOT)} = ($interface, $type, '255.255.255.0', $o_netadr, 'yes');
-
- $intf->{$interface}{IPADDR} = $o_ipadr if $o_ipadr;
- $interface;
+#- 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() {
- foreach (detect_devices::getNet()) {
- my $driver = c::getNetDriver($_) or next;
- modules::set_alias($_, $driver);
+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]);
+ }
}
}
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index e4f0ac49a..8c50d400c 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -10,18 +10,13 @@ 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, $netc) = @_;
+ my ($isdn) = @_;
$in->do_pkgs->install('isdn4net', if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils');
- write_config_backend($isdn, $netc);
- 1;
-}
-
-sub write_config_backend {
- my ($isdn, $netc, $o_netcnx) = @_;
- defined $o_netcnx and $netc->{isdntype} = $o_netcnx->{type};
output_with_perm("$::prefix/etc/isdn/profile/link/myisp", 0600,
qq(
@@ -51,28 +46,49 @@ I4L_PROTOCOL="$isdn->{protocol}"
usepeerdns
defaultroute
";
- system "$::prefix/etc/rc.d/init.d/isdn4linux restart";
-
- substInFile { s/^FIRMWARE.*\n//; $_ .= qq(FIRMWARE="$isdn->{firmware}"\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";
- # we start the virtual interface at boot (we dial only on demand.
- substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=yes\n) if eof } "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp$isdn->{intf_id}";
+ 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});
- set_cnx_script($netc, "isdn", join('',
-"/sbin/route del default
-modprobe $isdn->{driver}", if_($isdn->{type}, " type=$isdn->{type}"),
-"
-/usr/sbin/isdnctrl dial ippp0
-", if_($isdn->{speed} =~ /128/, "service ibod restart
-")),
-"/usr/sbin/isdnctrl hangup ippp0
-" . if_($isdn->{speed} =~ /128/, "service ibod stop
-"), $netc->{isdntype});
1;
}
+
+sub 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) = @_;
@@ -120,7 +136,8 @@ sub get_info_providers_backend {
sub read_providers_backend() { map { /(.*?)=>/ } catMaybeCompressed($file) }
-sub detect_backend() {
+sub detect_backend {
+ my ($modules_conf) = @_;
my @isdn;
require detect_devices;
each_index {
@@ -132,7 +149,7 @@ sub detect_backend() {
$isdn->{description} =~ s/.*\|//;
# $c->{options} !~ /id=HiSax/ && $isdn->{driver} eq "hisax" and $c->{options} .= " id=HiSax";
if ($c->{options} !~ /protocol=/ && $isdn->{protocol} =~ /\d/) {
- modules::set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
+ $modules_conf->set_options($c->{driver}, $c->{options} . " protocol=" . $isdn->{protocol});
}
$c->{options} =~ /protocol=(\d)/ and $isdn->{protocol} = $1;
push @isdn, $isdn;
@@ -159,4 +176,26 @@ sub get_cards() {
}
+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
index 6c97f6f8f..a828a9385 100644
--- a/perl-install/network/isdn_consts.pm
+++ b/perl-install/network/isdn_consts.pm
@@ -1,7 +1,7 @@
package network::isdn_consts; # $Id$
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
-@EXPORT = qw(@isdndata);
+@EXPORT = qw(@isdndata @isdn_capi);
our @isdndata =
(
@@ -336,4 +336,117 @@ our @isdndata =
},
);
+#- 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
index e790cf83c..18755d0cb 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -10,16 +10,30 @@ 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}} ||= {};
- $modem->{device} ||= first_modem($netc)->{device};
- my %l = getVarsFromSh("$::prefix/usr/share/config/kppprc");
- $l{Authentication} = 4 if !exists $l{Authentication};
+ 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};
@@ -30,6 +44,7 @@ sub ppp_read_conf {
}
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();
@@ -42,6 +57,8 @@ sub ppp_read_conf {
$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
@@ -51,7 +68,16 @@ sub ppp_configure {
$in->do_pkgs->install('ppp') if !$::testing;
$in->do_pkgs->install('kdenetwork-kppp') if !$::testing && $in->do_pkgs->is_installed('kdebase');
- any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
+ 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;
@@ -76,6 +102,7 @@ sub ppp_configure {
}
$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;
@@ -102,6 +129,7 @@ DISCONNECTTIMEOUT="5"
RETRYTIMEOUT="60"
BOOTPROTO="none"
PEERDNS="$toreplace{peerdns}"
+METRIC=$toreplace{METRIC}
END
output("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0",
$various,
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index 91c5ec7e2..dda85ae1a 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -7,29 +7,30 @@ use detect_devices;
use run_program;
use modules;
use any;
+use fs;
use mouse;
use network::network;
use network::tools;
use MDK::Common::Globals "network", qw($in);
sub detect {
- my ($auto_detect, $o_class) = @_;
+ my ($modules_conf, $auto_detect, $o_class) = @_;
my %l = (
isdn => sub {
require network::isdn;
- $auto_detect->{isdn} = network::isdn::detect_backend();
+ $auto_detect->{isdn} = network::isdn::detect_backend($modules_conf);
},
lan => sub { # ethernet
- modules::load_category('network/main|gigabit|usb');
require network::ethernet;
- $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards() };
+ modules::load_category($modules_conf, network::ethernet::get_eth_categories());
+ $auto_detect->{lan} = { map { $_->[0] => $_->[1] } network::ethernet::get_eth_cards($modules_conf) };
},
adsl => sub {
require network::adsl;
$auto_detect->{adsl} = network::adsl::adsl_detect();
},
modem => sub {
- $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem() };
+ $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) };
},
);
$l{$_}->() foreach $o_class || keys %l;
@@ -74,22 +75,22 @@ sub get_subwizard {
# configuring all network devices
sub real_main {
- my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
+ my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
my $netc = $o_netc ||= {};
my $mouse = $o_mouse ||= {};
my $intf = $o_intf ||= {};
my $first_time = $o_first_time || 0;
- my ($network_configured, $direct_net_install, $cnx_type, $type, $interface, @all_cards, %eth_intf);
+ my ($network_configured, $cnx_type, $type, @all_cards, %eth_intf, %all_eth_intf);
my (%connections, @connection_list, $is_wireless);
my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip);
my ($adsl_type, @adsl_devices, $adsl_failed, $adsl_answer, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider);
- my ($ntf_name, $ipadr, $netadr, $gateway_ex, $up, $need_restart_network);
- my ($isdn, $isdn_name, $isdn_type, %isdn_cards);
+ my ($ntf_name, $gateway_ex, $up, $need_restart_network);
+ my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods);
my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")");
my ($module, $auto_ip, $protocol, $onboot, $needhostname, $hotplug, $track_network_id, @fields); # lan config
my $success = 1;
my $ethntf = {};
- my $db_path = "$::prefix/usr/share/apps/kppp/Provider";
+ my $db_path = "/usr/share/apps/kppp/Provider";
my (%countries, @isp, $country, $provider, $old_provider);
my $config = {};
eval(cat_("$::prefix/etc/sysconfig/drakconnect"));
@@ -117,22 +118,20 @@ sub real_main {
network::tools::remove_initscript();
init_globals($in);
- $netc->{NET_DEVICE} = $netcnx->{NET_DEVICE} if $netcnx->{NET_DEVICE}; # REDONDANCE with read_conf. FIXME
- $netc->{NET_INTERFACE} = $netcnx->{NET_INTERFACE} if $netcnx->{NET_INTERFACE}; # REDONDANCE with read_conf. FIXME
- network::network::read_all_conf($::prefix, $netc, $intf);
- modules::mergein_conf();
+ read_net_conf($netcnx, $netc, $intf);
$netc->{autodetect} = {};
my $lan_detect = sub {
- detect($netc->{autodetect}, 'lan');
- modules::interactive::load_category($in, 'network/main|gigabit|pcmcia|usb|wireless', !$::expert, 0);
- @all_cards = network::ethernet::get_eth_cards();
- %eth_intf = network::ethernet::get_eth_cards_names(@all_cards);
- require list_modules;
+ detect($modules_conf, $netc->{autodetect}, 'lan');
+ require network::ethernet;
+ modules::interactive::load_category($in, $modules_conf, network::ethernet::get_eth_categories(), !$::expert, 0);
+ @all_cards = network::ethernet::get_eth_cards($modules_conf);
+ %all_eth_intf = network::ethernet::get_eth_cards_names(@all_cards); #- needed not to loose GATEWAYDEV
+ require list_modules; #- FIXME: check if useful
%eth_intf = map { $_->[0] => join(': ', $_->[0], $_->[2]) }
- grep { $is_wireless ^ !c::isNetDeviceWirelessAware($_->[0]) } @all_cards;
+ grep { to_bool($is_wireless) == c::isNetDeviceWirelessAware($_->[0]) } @all_cards;
};
my $find_lan_module = sub {
@@ -144,8 +143,7 @@ sub real_main {
};
my $is_hotplug_blacklisted = sub {
- bool2yesno($is_wireless ||
- member($module, qw(b44 forcedeth madwifi_pci)) ||
+ bool2yesno(member($module, qw(b44 forcedeth madwifi_pci)) ||
find { $_->{device} eq $ntf_name } detect_devices::pcmcia_probe());
};
@@ -162,6 +160,7 @@ sub real_main {
pptp => N("Point to Point Tunneling Protocol (PPTP)"),
pppoe => N("PPP over Ethernet (PPPoE)"),
pppoa => N("PPP over ATM (PPPoA)"),
+ capi => N("DSL over CAPI"),
);
my %encapsulations = (
@@ -169,8 +168,8 @@ sub real_main {
2 => N("Bridged Ethernet VC"),
3 => N("Routed IP LLC"),
4 => N("Routed IP VC"),
- 5 => N("PPPOA LLC"),
- 6 => N("PPPOA VC"),
+ 5 => N("PPPoA LLC"),
+ 6 => N("PPPoA VC"),
);
my %ppp_auth_methods = (
@@ -182,26 +181,30 @@ sub real_main {
);
my $offer_to_connect = sub {
- return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && $adsl_devices{$ntf_name};
- return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn));
+ return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && !member($adsl_type, qw(manual dhcp));
+ return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn isdn_external));
return "end";
};
my $after_start_on_boot_step = sub {
- if ($netc->{internet_cnx_choice}) {
- write_cnx_script($netc);
- $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type} if $netc->{internet_cnx_choice};
+ if ($netc->{internet_cnx_choice} && exists $netc->{internet_cnx}{$netc->{internet_cnx_choice}}) {
+ $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
} else {
undef $netc->{NET_DEVICE};
}
- network::network::configureNetwork2($in, $::prefix, $netc, $intf);
+ if ($netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)) && member($ntf_name, qw(sagem))) {
+ #- we need to write sagem specific parameters and load corresponding modules/programs
+ network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx);
+ }
+ network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
$network_configured = 1;
- return "restart" if $need_restart_network && $::isStandalone && !$::expert;
+ return "restart" if $need_restart_network && !$::isInstall && !$::expert;
return $offer_to_connect->();
};
my $goto_start_on_boot_ifneeded = sub {
- return $after_start_on_boot_step->() if $netcnx->{type} =~ /lan|cable/;
+ return $after_start_on_boot_step->() if $netcnx->{type} eq "lan";
+ return "isdn_dial_on_boot" if $netcnx->{type} =~ /isdn/;
return "network_on_boot";
};
@@ -214,14 +217,13 @@ sub real_main {
};
my $handle_multiple_cnx = sub {
- $need_restart_network = 1 if $netcnx->{type} =~ /adsl|cable|lan/;
+ $need_restart_network = member($netcnx->{type}, qw(cable lan)) || $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
my $nb = keys %{$netc->{internet_cnx}};
if (1 < $nb) {
return "multiple_internet_cnx";
} else {
- $netc->{internet_cnx_choice} = (keys %{$netc->{internet_cnx}})[0] if $nb == 1;
- $save_cnx->();
- return $goto_start_on_boot_ifneeded->()
+ $netc->{internet_cnx_choice} = $nb == 1 ? (keys %{$netc->{internet_cnx}})[0] : $netcnx->{type};
+ return $save_cnx->();
}
};
@@ -261,7 +263,8 @@ sub real_main {
data => \@connection_list,
post => sub {
$is_wireless = $cnx_type eq N("Wireless connection");
- load_conf($netcnx, $netc, $intf) if $::isInstall; # :-(
+ #- why read again the net_conf here?
+ read_net_conf($netcnx, $netc, $intf) if $::isInstall; # :-(
$type = $netcnx->{type} = $connections{$cnx_type};
if ($type eq 'cable') {
$auto_ip = 1;
@@ -310,29 +313,16 @@ sub real_main {
],
},
post => sub {
- network::isdn::write_config($isdn, $netc); # or return 'isdn_protocol';
+ network::isdn::write_config($isdn);
$netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- # return "static_hostname";
$handle_multiple_cnx->();
},
},
-
-
- # KILLME?: no longer called and deprecated fonction calls :-(
- #go_ethernet =>
- #{
- # pre => sub {
- # conf_network_card($netc, $intf, $type, $ipadr, $netadr) or return;
- # $netc->{NET_INTERFACE} = $netc->{NET_DEVICE};
- # configureNetwork($netc, $intf, $first_time) or return;
- # },
- #},
-
isdn =>
{
pre=> sub {
- detect($netc->{autodetect}, 'isdn');
+ detect($modules_conf, $netc->{autodetect}, 'isdn');
%isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}};
},
name => N("Select the network interface to configure:"),
@@ -347,10 +337,13 @@ sub real_main {
if ($isdn_name eq $my_isdn) {
return "isdn_ask";
} elsif ($isdn_name eq N("External ISDN modem")) {
- detect($netc->{autodetect}, 'modem');
- $netc->{isdntype} = 'isdn_external';
+ detect($modules_conf, $netc->{autodetect}, 'modem');
+ $netcnx->{type} = $netc->{isdntype} = 'isdn_external';
$netcnx->{isdn_external}{device} = network::modem::first_modem($netc);
network::isdn::read_config($netcnx->{isdn_external});
+ #- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i
+ #- it doesn't even work with TA 128 modems
+ #- http://bugs.mandrakelinux.com/query.php?bug=1033
$netcnx->{isdn_external}{special_command} = 'AT&F&O2B40';
require network::modem;
$modem = $netcnx->{isdn_external};
@@ -364,13 +357,17 @@ sub real_main {
if ($isdn->{id}) {
log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
$isdn->{description} =~ s/\|/ -- /;
-
}
- network::isdn::read_config($netcnx->{isdn_internal});
+
+ network::isdn::read_config($isdn);
+ $isdn->{driver} = $isdn_cards{$isdn_name}{driver}; #- do not let config overwrite default driver
+
+ #- let the user choose hisax or capidrv if both are available
+ $isdn->{driver} ne "capidrv" && network::isdn::get_capi_card($isdn) and return "isdn_driver";
return "isdn_protocol";
},
},
-
+
isdn_ask =>
{
@@ -419,7 +416,24 @@ If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
}
},
-
+
+ isdn_driver =>
+ {
+ pre => sub {
+ $isdn_name = "capidrv";
+ },
+ name => N("A CAPI driver is available for this modem. This CAPI driver can offer more capabilities than the free driver (like sending faxes). Which driver do you want to use?"),
+ data => sub { [
+ { label => N("Driver"), type => "list", val => \$isdn_name,
+ list => [ $isdn->{driver}, "capidrv" ] }
+ ] },
+ post => sub {
+ $isdn->{driver} = $isdn_name;
+ return "isdn_protocol";
+ }
+ },
+
+
isdn_protocol =>
{
name => N("ISDN Configuration") . "\n\n" . N("Which protocol do you want to use?"),
@@ -463,19 +477,13 @@ Take a look at http://www.linmodems.org"),
{
pre => sub {
require network::modem;
- detect($netc->{autodetect}, 'modem');
+ detect($modules_conf, $netc->{autodetect}, 'modem');
},
name => N("Select the modem to configure:"),
data => sub {
[ { label => N("Modem"), type => "list", val => \$modem_name, allow_empty_list => 1,
list => [ keys %{$netc->{autodetect}{modem}}, N("Manual choice") ], } ],
},
- complete => sub {
- if ($netc->{autodetect}{modem}{$modem_name}{driver} =~ /^(LT|H[cs]f):/ && c::kernel_version() !~ /^\Q2.4/) {
- $in->ask_warn(N("Warning"), N("Sorry, we support only 2.4 and above kernels."));
- }
- return 0;
- },
post => sub {
$modem ||= $netcnx->{modem} ||= {};;
return 'choose_serial_port' if $modem_name eq N("Manual choice");
@@ -487,26 +495,36 @@ Take a look at http://www.linmodems.org"),
my $type;
my %pkgs2path = (
- hcfpcimodem => "$::prefix/usr/sbin/hcfpciconfig",
- hsflinmodem => "$::prefix/usr/sbin/hsfconfig",
- ltmodem => "$::prefix/etc/devfs/conf.d/ltmodem.conf",
+ hcfpcimodem => "/usr/sbin/hcfpciconfig",
+ hsflinmodem => "/usr/sbin/hsfconfig",
+ ltmodem => "/etc/devfs/conf.d/ltmodem.conf",
+ slmodem => "/usr/sbin/slmodemd",
);
my %devices = (ltmodem => '/dev/ttyS14',
- hsflinmodem => '/dev/ttySHSF0'
+ hsflinmodem => '/dev/ttySHSF0',
+ slmodem => '/dev/ttySL0'
);
if (my $driver = $netc->{autodetect}{modem}{$modem_name}{driver}) {
- $driver =~ /^Hcf:/ and $type = "hcfpcimodem";
- $driver =~ /^Hsf:/ and $type = "hsflinmodem";
+ $driver =~ /^Hcf:/ and $type = "hcfmodem";
+ $driver =~ /^Hsf:/ and $type = "hsfmodem";
$driver =~ /^LT:/ and $type = "ltmodem";
- $type = undef if !($type && (-f $pkgs2path{$type} || $in->do_pkgs->ensure_is_installed_if_available($type, $pkgs2path{$type})));
- $modem->{device} = $devices{$type} || '/dev/modem' if $type; # automatically linked by /etc/devfs/conf entry
+ #- we need a better agreement to use list_modules::category2modules('network/slmodem')
+ member($driver, qw(slamr slusb)) and $type = "slmodem";
+ if ($type && (my $packages = $in->do_pkgs->check_kernel_module_packages("$type-kernel", if_(! -f $pkgs2path{$type}, $type)))) {
+ if ($in->do_pkgs->install(@$packages)) {
+ # start slmodemd when installing it (thus preventing the average user to have to restart
+ # his machine in order to get a working connection):
+ system("service slmodemd start") if $::isStandalone && $type eq 'slmodem';
+ }
+ $modem->{device} = $devices{$type} || '/dev/modem';
+ return "ppp_provider";
+ }
}
-
- #- fallback to modem configuration (beware to never allow test it).
- return $type ? "ppp_provider" : "no_supported_winmodem";
+
+ return "no_supported_winmodem";
},
},
@@ -517,7 +535,7 @@ Take a look at http://www.linmodems.org"),
interactive_help_id => 'selectSerialPort',
data => sub {
[ { val => \$modem->{device}, format => \&mouse::serial_port2text, type => "list",
- list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0') ] } ],
+ list => [ grep { $_ ne $o_mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ],
},
post => sub {
$ntf_name = $modem->{device};
@@ -531,30 +549,35 @@ Take a look at http://www.linmodems.org"),
pre => sub {
network::modem::ppp_read_conf($netcnx, $netc) if !$modem_conf_read;
$modem_conf_read = 1;
+ $in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path);
+ my $p_db_path = "$::prefix$db_path";
@isp = map {
my $country = $_;
map {
- s!$db_path/$country!!;
+ s!$p_db_path/$country!!;
s/%([0-9]{3})/chr(int($1))/eg;
$countries{$country} ||= translate($country);
join('', $countries{$country}, $_);
- } grep { !/.directory$/ } glob_("$db_path/$country/*")
- } map { s!$db_path/!!o; s!_! !g; $_ } glob_("$db_path/*");
+ } grep { !/.directory$/ } glob_("$p_db_path/$country/*")
+ } map { s!$p_db_path/!!o; s!_! !g; $_ } glob_("$p_db_path/*");
$old_provider = $provider;
},
name => N("Select your provider:"),
data => sub {
- [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/', list => \@isp } ]
+ [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/',
+ list => [ N("Unlisted - edit manually"), @isp ] } ]
},
post => sub {
- ($country, $provider) = split('/', $provider);
- $country = { reverse %countries }->{$country};
- my %l = getVarsFromSh("$db_path/$country/$provider");
- if (defined $old_provider && $old_provider ne $provider) {
- $modem->{connection} = $l{Name};
- $modem->{phone} = $l{Phonenumber};
- $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask);
- ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
+ if ($provider ne N("Unlisted - edit manually")) {
+ ($country, $provider) = split('/', $provider);
+ $country = { reverse %countries }->{$country};
+ my %l = getVarsFromSh("$::prefix$db_path/$country/$provider");
+ if (defined $old_provider && $old_provider ne $provider) {
+ $modem->{connection} = $l{Name};
+ $modem->{phone} = $l{Phonenumber};
+ $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask);
+ ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
+ }
}
return "ppp_account";
},
@@ -566,10 +589,6 @@ Take a look at http://www.linmodems.org"),
pre => sub {
$mouse ||= {};
$mouse->{device} ||= readlink "$::prefix/dev/mouse";
- set_cnx_script($netc, "modem", join("\n", if_($::testing, "/sbin/route del default"), "ifup ppp0"),
- q(ifdown ppp0
-killall pppd
-), $netcnx->{type});
},
name => N("Dialup: account options"),
data => sub {
@@ -635,7 +654,6 @@ killall pppd
post => sub {
network::modem::ppp_configure($in, $modem);
$netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $in->do_pkgs->ensure_is_installed('kdenetwork-kppp', '/usr/bin/kppp');
$handle_multiple_cnx->();
},
},
@@ -646,33 +664,49 @@ killall pppd
pre => sub {
get_subwizard($wiz, 'adsl');
$lan_detect->();
- detect($netc->{autodetect}, 'adsl');
@adsl_devices = keys %eth_intf;
+
+ detect($modules_conf, $netc->{autodetect}, 'adsl');
foreach my $modem (keys %adsl_devices) {
push @adsl_devices, $modem if $netc->{autodetect}{adsl}{$modem};
}
+
+ detect($modules_conf, $netc->{autodetect}, 'isdn');
+ if (my @isdn_modems = @{$netc->{autodetect}{isdn}}) {
+ require network::isdn;
+ %isdn_cards = map { $_->{description} => $_ } grep { $_->{driver} =~ /dsl/i } map { network::isdn::get_capi_card($_) } @isdn_modems;
+ push @adsl_devices, keys %isdn_cards;
+ }
},
name => N("ADSL configuration") . "\n\n" . N("Select the network interface to configure:"),
data => [ { label => N("Net Device"), type => "list", val => \$ntf_name, allow_empty_list => 1,
- list => \@adsl_devices, format => sub { $eth_intf{$_[0]} || $adsl_devices{$_[0]} } } ],
+ list => \@adsl_devices, format => sub { $eth_intf{$_[0]} || $adsl_devices{$_[0]} || $_[0] } } ],
post => sub {
my %packages = (
'eci' => [ 'eciadsl', 'missing' ],
- 'sagem' => [ 'eagle-usb', "$::prefix/usr/sbin/eaglectrl" ],
- 'speedtouch' => [ 'speedtouch', "$::prefix/usr/share/speedtouch/speedtouch.sh" ],
+ 'sagem' => [ 'eagle-usb', "/usr/sbin/eaglectrl" ],
+ 'speedtouch' => [ 'speedtouch', "/usr/sbin/modem_run" ],
);
return 'adsl_unsupported_eci' if $ntf_name eq 'eci';
- $in->do_pkgs->install($packages{$ntf_name}[0]) if $packages{$ntf_name} && !-e $packages{$ntf_name}->[1];
+ # FIXME: check that the package installation succeeds, else retry or abort
+ $in->do_pkgs->ensure_is_installed(@{$packages{$ntf_name}}) if $packages{$ntf_name};
if ($ntf_name eq 'speedtouch') {
- $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "$::prefix/usr/share/speedtouch/mgmt.o");
+ $in->do_pkgs->ensure_is_installed_if_available('speedtouch_mgmt', "/usr/share/speedtouch/mgmt.o");
return 'adsl_speedtouch_firmware' if ! -e "$::prefix/usr/share/speedtouch/mgmt.o";
}
$netcnx->{bus} = $netc->{autodetect}{adsl}{bewan}{bus} if $ntf_name eq 'bewan';
if ($ntf_name eq 'bewan' && !$::testing) {
- $in->do_pkgs->ensure_is_installed_if_available('unicorn', "$::prefix/usr/bin/bewan_adsl_status");
+ if (my @unicorn_packages = $in->do_pkgs->check_kernel_module_packages('unicorn-kernel', 'unicorn')) {
+ $in->do_pkgs->install(@unicorn_packages);
+ }
}
- return 'adsl_provider' if $adsl_devices{$ntf_name};
- return 'adsl_protocol';
+ if (exists($isdn_cards{$ntf_name})) {
+ require network::isdn;
+ $netcnx->{capi} = $isdn_cards{$ntf_name};
+ $adsl_type = "capi";
+ return 'adsl_account';
+ }
+ return 'adsl_provider';
},
},
@@ -761,15 +795,17 @@ and copy the mgmt.o in /usr/share/speedtouch", 'http://prdownloads.sourceforge.n
# preselect right protocol for ethernet though connections:
if (!exists $adsl_devices{$ntf_name}) {
$ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
- $adsl_type = $ethntf->{BOOTPROTO} || "dhcp";
+ $adsl_type ||= $ethntf->{BOOTPROTO} || "dhcp";
+ #- pppoa shouldn't be selected by default for ethernet devices, fallback on pppoe
+ $adsl_type = "pppoe" if $adsl_type eq "pppoa";
}
},
name => N("Connect to the Internet") . "\n\n" .
N("The most common way to connect with adsl is pppoe.
-Some connections use pptp, a few use dhcp.
-If you don't know, choose 'use pppoe'"),
+Some connections use PPTP, a few use DHCP.
+If you don't know, choose 'use PPPoE'"),
data => [
- { text => N("ADSL connection type :"), val => \$adsl_type, type => "list",
+ { text => N("ADSL connection type:"), val => \$adsl_type, type => "list",
list => [ sort { $adsl_types{$a} cmp $adsl_types{$b} } keys %adsl_types ],
format => sub { $adsl_types{$_[0]} },
},
@@ -779,13 +815,19 @@ If you don't know, choose 'use pppoe'"),
# blacklist bogus driver, enable ifplugd support else:
$find_lan_module->();
$ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->();
+ if ($ntf_name eq "sagem" && member($adsl_type, qw(manual dhcp))) {
+ #- "fctStartAdsl -i" builds ifcfg-ethX from ifcfg-sagem and echoes ethX
+ #- it auto-detects dhcp/static modes thanks to encapsulation setting
+ $ethntf = $intf->{sagem} ||= {};
+ $ethntf->{DEVICE} = "`/usr/sbin/fctStartAdsl -i`";
+ $ethntf->{MII_NOT_SUPPORTED} = "yes";
+ }
# process static/dhcp ethernet devices:
- if (!exists $adsl_devices{$ntf_name} && member($adsl_type, qw(manual dhcp))) {
+ if (exists($intf->{$ntf_name}) && member($adsl_type, qw(manual dhcp))) {
+ $ethntf->{TYPE} = "ADSL";
$auto_ip = $adsl_type eq 'dhcp';
return 'lan_intf';
}
- network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name);
- $netc->{NET_DEVICE} = $ntf_name if $adsl_type eq 'pppoe';
return 'adsl_account';
},
},
@@ -793,6 +835,11 @@ If you don't know, choose 'use pppoe'"),
adsl_account =>
{
+ pre => sub {
+ network::adsl::adsl_probe_info($netcnx, $netc, $adsl_type, $ntf_name);
+ $netc->{NET_DEVICE} = member($adsl_type, 'pppoe', 'pptp') ? $ntf_name : 'ppp0';
+ $netc->{NET_INTERFACE} = 'ppp0';
+ },
name => N("Connection Configuration") . "\n\n" .
N("Please fill or check the field below"),
data => sub {
@@ -802,10 +849,12 @@ If you don't know, choose 'use pppoe'"),
{ label => N("Second DNS Server (optional)"), val => \$netc->{dnsServer3} },
{ label => N("Account Login (user name)"), val => \$netcnx->{login} },
{ label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1 },
- { label => N("Virtual Path ID (VPI):"), val => \$netc->{vpi}, advanced => 1 },
- { label => N("Virtual Circuit ID (VCI):"), val => \$netc->{vci}, advanced => 1 },
+ if_($adsl_type ne "capi",
+ { label => N("Virtual Path ID (VPI):"), val => \$netc->{vpi}, advanced => 1 },
+ { label => N("Virtual Circuit ID (VCI):"), val => \$netc->{vci}, advanced => 1 }
+ ),
if_($ntf_name eq "sagem",
- { label => N("Encapsulation :"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ],
+ { label => N("Encapsulation:"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ],
format => sub { $encapsulations{$_[0]} }, advanced => 1,
},
),
@@ -813,7 +862,7 @@ If you don't know, choose 'use pppoe'"),
},
post => sub {
$netc->{internet_cnx_choice} = 'adsl';
- network::adsl::adsl_conf_backend($in, $netcnx, $netc, $ntf_name, $adsl_type, $netcnx); #FIXME
+ network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); #FIXME
$config->{adsl} = { kind => $ntf_name, protocol => $adsl_type };
$handle_multiple_cnx->();
},
@@ -838,11 +887,12 @@ You can find a driver on http://eciadsl.flashtux.org/"),
allow_empty_list => 1, format => sub { translate($eth_intf{$_[0]} || $_[0]) } } ];
},
post => sub {
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
if ($ntf_name eq "Manually load a driver") {
- modules::interactive::load_category__prompt($in, 'network/main|gigabit|pcmcia|usb|wireless');
+ require network::ethernet;
+ modules::interactive::load_category__prompt($in, $modules_conf, network::ethernet::get_eth_categories());
return 'lan';
}
+ $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
$::isInstall && $netc->{NET_DEVICE} eq $ethntf->{DEVICE} ? 'lan_alrd_cfg' : 'lan_protocol';
},
},
@@ -850,9 +900,10 @@ You can find a driver on http://eciadsl.flashtux.org/"),
lan_alrd_cfg =>
{
name => N("WARNING: this device has been previously configured to connect to the Internet.
-Simply accept to keep this device configured.
-Modifying the fields below will override this configuration."),
+Modifying the fields below will override this configuration.
+Do you really want to reconfigure this device?"),
type => "yesorno",
+ default => "no",
post => sub {
my ($res) = @_;
return $res ? "lan_protocol" : "alrd_end";
@@ -873,6 +924,9 @@ Modifying the fields below will override this configuration."),
{
pre => sub {
$find_lan_module->();
+ my $intf_type = member($module, list_modules::category2modules('network/gigabit')) ? "ethernet_gigabit" : "ethernet";
+ defined($ethntf->{METRIC}) or $ethntf->{METRIC} = network::tools::get_default_metric($intf_type);
+
$protocol = $l10n_lan_protocols{defined $auto_ip ? ($auto_ip ? 'dhcp' : 'static') : $ethntf->{BOOTPROTO}} || 0;
},
name => sub {
@@ -904,6 +958,7 @@ Modifying the fields below will override this configuration."),
$track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop();
delete $ethntf->{NETWORK};
delete $ethntf->{BROADCAST};
+ delete $ethntf->{TYPE} unless $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
@fields = qw(IPADDR NETMASK);
$netc->{dhcp_client} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd)) || "dhcp-client";
$netc->{dhcp_client} = "dhcp-client" if $netc->{dhcp_client} eq "dhclient";
@@ -927,7 +982,9 @@ notation (for example, 1.2.3.4).")),
),
{ text => N("Track network card id (useful for laptops)"), val => \$track_network_id, type => "bool" },
{ text => N("Network Hotplugging"), val => \$hotplug, type => "bool" },
- { text => N("Start at boot"), val => \$onboot, type => "bool" },
+ if_($netcnx->{type} eq "lan",
+ { text => N("Start at boot"), val => \$onboot, type => "bool" },
+ ),
if_($auto_ip,
{ label => N("DHCP client"), val => \$netc->{dhcp_client},
list => [ qw(dhcp-client dhcpcd pump dhcpxd) ], advanced => 1 },
@@ -942,7 +999,15 @@ notation (for example, 1.2.3.4).")),
$in->ask_warn(N("Error"), N("IP address should be in format 1.2.3.4"));
return 1, $bad[0];
}
- $in->ask_warn(N("Error"), N("Warning : IP address %s is usually reserved !", $ethntf->{IPADDR})) if is_ip_forbidden($ethntf->{IPADDR});
+ if (is_ip_forbidden($ethntf->{IPADDR})) {
+ $in->ask_warn(N("Error"), N("Warning: IP address %s is usually reserved!", $ethntf->{IPADDR}));
+ return 1;
+ }
+ #- test if IP address is already used (do not test for sagem DSL devices since it may use many ifcfg files)
+ if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %$intf) {
+ $in->ask_warn(N("Error"), N("%s already in use\n", $ethntf->{IPADDR}));
+ return 1;
+ }
},
focus_out => sub {
$ethntf->{NETMASK} ||= netmask($ethntf->{IPADDR}) unless $_[0]
@@ -952,14 +1017,8 @@ notation (for example, 1.2.3.4).")),
$ethntf->{NEEDHOSTNAME} = bool2yesno($needhostname);
$ethntf->{MII_NOT_SUPPORTED} = bool2yesno(!$hotplug);
$ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR};
+ $netc->{$_} = $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE);
$in->do_pkgs->install($netc->{dhcp_client}) if $auto_ip;
- set_cnx_script($netc, "cable", qq(
-/sbin/ifup $netc->{NET_DEVICE}
-),
- qq(
-/sbin/ifdown $netc->{NET_DEVICE}
-), $netcnx->{type}) if $netcnx->{type} eq 'cable';
-
return $is_wireless ? "wireless" : "static_hostname";
},
},
@@ -1017,7 +1076,7 @@ or off.")
help => N("Here, one can configure some extra wireless parameters such as:
ap, channel, commit, enc, power, retry, sens, txpower (nick is already set as the hostname).
-See iwpconfig(8) man page for further information."),
+See iwconfig(8) man page for further information."),
},
{ label =>
#-PO: split the "xyz command extra argument" translated string into two lines if it's bigger than the english one
@@ -1047,34 +1106,50 @@ See iwpriv(8) man page for further information."),
post => sub {
# untranslate parameters
$ethntf->{WIRELESS_MODE} = $wireless_mode{$ethntf->{WIRELESS_MODE}};
+ if ($module =~ /^prism2_/) {
+ $in->do_pkgs->install('prism2-utils');
+ if ($ethntf->{WIRELESS_ESSID}) {
+ my $update_vars_in_wlan = sub { #- FIXME: to be improved (quotes, comments) and moved in common files
+ my ($file, $vars) = @_;
+ substInFile {
+ while (my ($key, $value) = each(%$vars)) {
+ s/^#?\Q$key\E=(?:"[^#]*"|[^#\s]*)(\s*#.*)?/$key=$value$1/ and delete $vars->{$key};
+ }
+ $_ .= join('', map { "$_=$vars->{$_}\n" } keys %$vars) if eof;
+ } $file;
+ };
+ my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf";
+ my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]);
+ push @wlan_devices, $ethntf->{DEVICE} unless member($ethntf->{DEVICE}, @wlan_devices);
+ #- enable device and make it use the choosen ESSID
+ $update_vars_in_wlan->($wlan_conf_file,
+ {
+ WLAN_DEVICES => qq("@wlan_devices"),
+ "SSID_$ethntf->{DEVICE}" => qq("$ethntf->{WIRELESS_ESSID}"),
+ "ENABLE_$ethntf->{DEVICE}" => "y"
+ });
+ my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$ethntf->{WIRELESS_ESSID}";
+ #- copy default settings for this ESSID if config file doesn't exist
+ -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file);
+ #- enable/disable encryption
+ $update_vars_in_wlan->($wlan_ssid_file,
+ {
+ (map { $_ => $ethntf->{WIRELESS_ENC_KEY} ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)),
+ AuthType => $ethntf->{WIRELESS_ENC_KEY} ? qq("sharedkey") : qq("opensystem"),
+ if_($ethntf->{WIRELESS_ENC_KEY},
+ dot11WEPDefaultKeyID => 0,
+ dot11WEPDefaultKey0 => qq("$ethntf->{WIRELESS_ENC_KEY}")
+ )
+ });
+ #- apply settings on wlan interface
+ require services;
+ services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan');
+ }
+ }
return "static_hostname";
},
},
- conf_network_card =>
- {
- pre => sub {
- #-type =static or dhcp
- modules::interactive::load_category($in, 'network/main|gigabit|usb', !$::expert, 1);
- @all_cards = network::ethernet::get_eth_cards() or
- # FIXME: fix this
- $in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system.
-I cannot set up this connection type.")), return;
-
- },
- name => N("Choose the network interface") . "\n\n" .
- N("Please choose which network adapter you want to use to connect to Internet."),
- data => [ { val => \$interface, type => "list", list => \@all_cards, } ],
- format => sub { my ($e) = @_; $e->[0] . ($e->[1] ? " (using module $e->[1])" : "") },
-
- post => sub {
- network::ethernet::write_ether_conf();
- modules::write_conf() if $::isStandalone;
- my $_device = network::ethernet::conf_network_card_backend($netc, $intf, $type, $interface->[0], $ipadr, $netadr);
- return "lan";
- },
- },
-
static_hostname =>
{
pre => sub {
@@ -1082,6 +1157,11 @@ I cannot set up this connection type.")), return;
$netc->{dnsServer} ||= dns($ethntf->{IPADDR});
$gateway_ex = gateway($ethntf->{IPADDR});
# $netc->{GATEWAY} ||= gateway($ethntf->{IPADDR});
+ if ($ntf_name eq "sagem") {
+ my @sagem_ip = split(/\./, $ethntf->{IPADDR});
+ @sagem_ip[3] = 254;
+ $netc->{GATEWAY} = join(".", @sagem_ip);
+ }
}
},
name => N("Please enter your host name.
@@ -1099,8 +1179,8 @@ N("Last but not least you can also type in your DNS server IP addresses."),
help => N("By default search domain will be set from the fully-qualified host name") },
{ label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} },
if_(@all_cards > 1,
- { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ sort keys %eth_intf ],
- format => sub { $eth_intf{$_[0]} } },
+ { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ sort keys %all_eth_intf ],
+ format => sub { $all_eth_intf{$_[0]} } },
),
),
],
@@ -1151,7 +1231,7 @@ It is not necessary on most networks."),
apply_settings =>
{
- name => N("Configuration is complete, do you want to apply settings ?"),
+ name => N("Configuration is complete, do you want to apply settings?"),
type => "yesorno",
},
@@ -1168,25 +1248,52 @@ It is not necessary on most networks."),
my ($res) = @_;
$netc->{at_boot} = $res;
$res = bool2yesno($res);
- substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof }
- $netc->{internet_cnx_choice} eq 'adsl' ?
- "$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0" :
- "$::prefix/etc/sysconfig/network-scripts/ifcfg-ippp0";
+ $ethntf->{ONBOOT} = $res if $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
+ my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
+ -f $ifcfg_file and substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } $ifcfg_file;
+ return $after_start_on_boot_step->();
+ },
+ },
+
+ isdn_dial_on_boot =>
+ {
+ pre => sub {
+ $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written
+ @isdn_dial_methods = ({ name => N("Automatically at boot"),
+ ONBOOT => 1, DIAL_ON_IFUP => 1 },
+ { name => N("By using Net Applet in the system tray"),
+ ONBOOT => 0, DIAL_ON_IFUP => 1 },
+ { name => N("Manually (the interface would still be activated at boot)"),
+ ONBOOT => 1, DIAL_ON_IFUP => 0 });
+ my $method = find {
+ $_->{ONBOOT} eq text2bool($intf->{ippp0}{ONBOOT}) &&
+ $_->{DIAL_ON_IFUP} eq text2bool($intf->{ippp0}{DIAL_ON_IFUP})
+ } @isdn_dial_methods;
+ #- use net_applet by default
+ $isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name};
+ },
+ name => N("How do you want to dial this connection?"),
+ data => sub {
+ [ { type => "list", val => \$isdn->{dial_method}, list => [ map { $_->{name} } @isdn_dial_methods ] } ]
+ },
+ post => sub {
+ my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods;
+ $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
return $after_start_on_boot_step->();
},
},
restart =>
{
- name => N("The network needs to be restarted. Do you want to restart it ?"),
+ name => N("The network needs to be restarted. Do you want to restart it?"),
type => "yesorno",
post => sub {
my ($a) = @_;
- network::ethernet::write_ether_conf($in, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan';
+ network::ethernet::write_ether_conf($in, $modules_conf, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan';
if ($a && !$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) {
$success = 0;
$in->ask_okcancel(N("Network Configuration"),
- N("A problem occured while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
+ N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
}
return $offer_to_connect->();
},
@@ -1203,7 +1310,7 @@ It is not necessary on most networks."),
if ($a) {
# local $::isWizard = 0;
my $_w = $in->wait_message('', N("Testing your connection..."), 1);
- connect_backend();
+ connect_backend($netc);
my $s = 30;
$type =~ /modem/ and $s = 50;
$type =~ /adsl/ and $s = 35;
@@ -1226,7 +1333,7 @@ Try to reconfigure your connection.");
no_back => 1,
end => 1,
post => sub {
- $::isInstall and disconnect_backend();
+ $::isInstall and disconnect_backend($netc);
return "end";
},
},
@@ -1238,7 +1345,7 @@ Try to reconfigure your connection.");
"), if_($::isStandalone && $in->isa('interactive::gtk'),
N("After this is done, we recommend that you restart your X environment to avoid any hostname-related problems."))) :
- N("Problems occured during configuration.
+ N("Problems occurred during configuration.
Test your connection via net_monitor or mcc. If your connection doesn't work, you might want to relaunch the configuration.");
},
end => 1,
@@ -1256,13 +1363,7 @@ Click on Ok to keep your configuration, or cancel to reconfigure your Internet &
"), 1)
and do {
$netcnx->{type} = 'lan';
- # should use write_cnx_file:
- output_with_perm("$::prefix$network::tools::connect_file", 0755, qq(ifup eth0
-));
- output("$::prefix$network::tools::disconnect_file", 0755, qq(
-ifdown eth0
-));
- $direct_net_install = 1;
+ $netc->{$_} = 'eth0' foreach qw(NET_DEVICE NET_INTERFACE);
$use_wizard = 0;
};
}
@@ -1275,68 +1376,24 @@ ifdown eth0
mouse => $mouse,
intf => $intf,
};
- wizards->new->safe_process($wiz, $in);
+ wizards->new->process($wiz, $in);
}
# install needed packages:
- $network_configured or network::network::configureNetwork2($in, $::prefix, $netc, $intf);
-
- my $connect_cmd;
- if ($netcnx->{type} =~ /modem/ || $netcnx->{type} =~ /isdn_external/) {
- $connect_cmd = qq(
-#!/bin/bash
-if [ -n "\$DISPLAY" ]; then
- if [ -e /usr/bin/kppp ]; then
- /sbin/route del default
- /usr/bin/kppp &
- else
- /usr/sbin/net_monitor --connect
- fi
- else
- $network::tools::connect_file
-fi
-);
- } elsif ($netcnx->{type}) {
- $connect_cmd = qq(
-#!/bin/bash
-if [ -n "\$DISPLAY" ]; then
- /usr/sbin/net_monitor --connect
-else
- $network::tools::connect_file
-fi
-);
- } else {
- $connect_cmd = qq(
-#!/bin/bash
-/usr/sbin/drakconnect
-);
- }
- if ($direct_net_install) {
- $connect_cmd = qq(
-#!/bin/bash
-if [ -n "\$DISPLAY" ]; then
- /usr/sbin/net_monitor --connect
-else
- $network::tools::connect_file
-fi
-);
- }
- output_with_perm("$::prefix$network::tools::connect_prog", 0755, $connect_cmd) if $connect_cmd;
+ $network_configured or network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
+
$netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
$netcnx->{type} =~ /adsl/ or run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null");
-
- if ($::isInstall && $::o->{security} >= 3) {
- require network::drakfirewall;
- network::drakfirewall::main($in, $::o->{security} <= 3);
- }
}
sub main {
- my ($_prefix, $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
- eval { real_main('', , $netcnx, $in, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) };
+ my ($_prefix, $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
+ eval { real_main('', , $netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) };
my $err = $@;
if ($err) { # && $in->isa('interactive::gtk')
- local $::isEmbedded = 0; # to prevent sub window embedding
+ $err =~ /wizcancel/ and $in->exit(0);
+
+ local $::isEmbedded = 0; # to prevent sub window embedding
local $::isWizard = 0 if !$::isInstall; # to prevent sub window embedding
#err_dialog(N("Error"), N("An unexpected error has happened:\n%s", $err));
$in->ask_warn(N("Error"), N("An unexpected error has happened:\n%s", $err));
@@ -1373,14 +1430,6 @@ sub get_profiles() {
map { if_(m!([^/]*)/$!, $1) } glob("$::prefix/etc/netprofile/profiles/*/");
}
-sub load_conf {
- my ($netcnx, $netc, $intf) = @_;
- my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") };
-
- $netcnx->{PROFILE} = $current->{PROFILE} || 'default';
- network::network::read_all_conf($::prefix, $netc, $intf, $netcnx);
-}
-
sub get_net_device() {
my $connect_file = $network::tools::connect_file;
my $network_file = "$::prefix/etc/sysconfig/network";
@@ -1396,23 +1445,30 @@ sub get_net_device() {
}
sub read_net_conf {
- my ($_prefix, $netcnx, $netc) = @_;
- $netc->{$_} = $netcnx->{$_} foreach 'NET_DEVICE', 'NET_INTERFACE';
- $netcnx->{$netcnx->{type}} ||= {};
+ my ($netcnx, $netc, $intf) = @_;
+ my $current = { getVarsFromSh("$::prefix/etc/netprofile/current") };
+
+ $netcnx->{PROFILE} = $current->{PROFILE} || 'default';
+ network::network::read_all_conf($::prefix, $netc, $intf, $netcnx);
+
+ foreach ('NET_DEVICE', 'NET_INTERFACE') {
+ $netc->{$_} = $netcnx->{$_} if $netcnx->{$_}
+ }
+ $netcnx->{$netcnx->{type}} ||= {} if $netcnx->{type};
}
sub start_internet {
my ($o) = @_;
init_globals($o);
#- give a chance for module to be loaded using kernel-BOOT modules...
- $::isStandalone or modules::load_category('network/main|gigabit|usb');
- run_program::rooted($::prefix, $network::tools::connect_file);
+ $::isStandalone or modules::load_category($o->{modules_conf}, 'network/*');
+ connect_backend($o->{netc});
}
sub stop_internet {
my ($o) = @_;
init_globals($o);
- run_program::rooted($::prefix, $network::tools::disconnect_file);
+ disconnect_backend($o->{netc});
}
1;
@@ -1431,7 +1487,7 @@ local $in = class_discard->new;
network::netconnect::init_globals($in);
my %i;
-&network::netconnect::detect(\%i);
+network::netconnect::detect($modules_conf, \%i);
print Dumper(\%i),"\n";
=cut
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 9f4256770..febaa632d 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -27,15 +27,15 @@ sub read_conf {
}
sub read_resolv_conf_raw {
- my ($file) = @_;
- $file ||= "$::prefix/etc/resolv.conf";
- { nameserver => [ cat_($file) =~ /^\s*nameserver\s+(\S+)/mg ],
- search => [ if_(cat_($file) =~ /^\s*search\s+(.*)/m, split(' ', $1)) ] };
+ 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 ($file) = @_;
- my $resolv_conf = read_resolv_conf_raw($file);
+ 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}),
@@ -53,40 +53,33 @@ sub read_interface_conf {
}
sub read_dhcpd_conf {
- my ($file) = @_;
- $file ||= "$::prefix/etc/dhcpd.conf";
- { option_routers => [ cat_($file) =~ /^\s*option routers\s+(\S+);/mg ],
- subnet_mask => [ if_(cat_($file) =~ /^\s*option subnet-mask\s+(.*);/mg, split(' ', $1)) ],
- domain_name => [ if_(cat_($file) =~ /^\s*option domain-name\s+"(.*)";/mg, split(' ', $1)) ],
- domain_name_servers => [ if_(cat_($file) =~ /^\s*option domain-name-servers\s+(.*);/m, split(' ', $1)) ],
- dynamic_bootp => [ if_(cat_($file) =~ /^\s*range dynamic-bootp\s+\S+\.(\d+)\s+\S+\.(\d+)\s*;/m, split(' ', $1)) ],
- default_lease_time => [ if_(cat_($file) =~ /^\s*default-lease-time\s+(.*);/m, split(' ', $1)) ],
- max_lease_time => [ if_(cat_($file) =~ /^\s*max-lease-time\s+(.*);/m, split(' ', $1)) ] };
+ 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 ($file) = @_;
- $file ||= "$::prefix/etc/squid/squid.conf";
- { http_port => [ cat_($file) =~ /^\s*http_port\s+(.*)/mg ],
- cache_size => [ if_(cat_($file) =~ /^\s*cache_dir diskd\s+(.*)/mg, split(' ', $1)) ],
- admin_mail => [ if_(cat_($file) =~ /^\s*err_html_text\s+(.*)/mg, split(' ', $1)) ] };
+ 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) = @_;
- local *F; open F, $file or die "cannot open file $file: $!";
- local $_;
- my %outf;
-
- while (<F>) {
- ($outf{ZEROCONF_HOSTNAME}) = /^\s*hostname\s*=\s*(\w+)/ and return \%outf;
- }
-
- \%outf;
+sub 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) = @_;
+ my ($netc) = @_;
+ my $file = "$::prefix/etc/sysconfig/network";
if ($netc->{HOSTNAME} && $netc->{HOSTNAME} =~ /\.(.+)$/) {
$netc->{DOMAINNAME} = $1;
@@ -149,14 +142,10 @@ sub write_resolv_conf {
sub write_interface_conf {
my ($file, $intf, $_netc, $_prefix) = @_;
- if ($intf->{HWADDR} && -e "$::prefix/sbin/ip") {
- $intf->{HWADDR} = undef;
- if (my $s = `LC_ALL= LANG= $::prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`) {
- if ($s =~ m|.*link/ether\s([0-9a-z:]+)\s|) {
- $intf->{HWADDR} = $1;
- }
- }
- }
+ 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};
@@ -166,27 +155,38 @@ sub write_interface_conf {
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/;
- local $intf->{WIRELESS_ENC_KEY} = $intf->{WIRELESS_ENC_KEY} && network::tools::convert_wep_key_for_iwconfig($intf->{WIRELESS_ENC_KEY});
- setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR MII_NOT_SUPPORTED),
+ 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->{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 = map { if_(/\s*(\S+)(.*)/, $1 => $2) }
- grep { !/\s+\Q$hostname\E\s*$/ } cat_($file);
+ 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);
- my $sub_hostname = $hostname =~ /(.*?)\./ ? " $1" : '';
- $l{$_} = "\t\t$hostname$sub_hostname" foreach grep { $_ } @ips;
+ push @{$l{$_}}, $hostname, if_($sub_hostname, $sub_hostname) foreach grep { $_ } @ips;
log::explanations("writing host information to $file");
- output($file, map { "$_$l{$_}\n" } keys %l);
+ output($file, map { "$_\t\t" . join(" ", @{$l{$_}}) . "\n" } keys %l);
}
# The interface/gateway needs to be configured before this will work!
@@ -216,6 +216,10 @@ sub sethostname {
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($) {
@@ -234,7 +238,7 @@ sub dnsServers {
sub findIntf {
my ($intf, $device) = @_;
- $intf->{$device}{DEVICE} = $device;
+ $intf->{$device}{DEVICE} = undef;
$intf->{$device};
}
@@ -339,17 +343,23 @@ sub read_all_conf {
my $netcnx = $o_netcnx || {};
add2hash($netc, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network";
add2hash($netc, read_resolv_conf());
- add2hash($netc, read_tmdns_conf("$::prefix/etc/tmdns.conf")) if -r "$::prefix/etc/tmdns.conf";
+ add2hash($netc, read_tmdns_conf());
foreach (all("$::prefix/etc/sysconfig/network-scripts")) {
- if (/^ifcfg-([A-Za-z0-9.:]+)$/ && $1 ne 'lo') {
- my $intf = findIntf($intf, $1);
+ 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->{WIRELESS_ENC_KEY} = network::tools::get_wep_key_from_iwconfig($intf->{WIRELESS_ENC_KEY});
+ $intf->{DEVICE} ||= $device;
+ $intf->{WIRELESS_ENC_KEY} = network::tools::get_wep_key_from_iwconfig($intf->{WIRELESS_ENC_KEY});
}
}
- $netcnx->{type} or probe_netcnx_type($::prefix, $netc, $intf, $netcnx);
+ 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.
@@ -363,26 +373,35 @@ sub probe_netcnx_type {
}
sub easy_dhcp {
- my ($netc, $intf) = @_;
+ my ($modules_conf, $netc, $intf) = @_;
return if text2bool($netc->{NETWORKING});
require modules;
require network::ethernet;
- modules::load_category('network/main|gigabit|usb');
- my @all_cards = network::ethernet::get_eth_cards();
+ 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 network card
- (any { $_->[0] eq 'eth0' } @all_cards) && (every { $_->[0] ne 'eth1' } @all_cards) or return;
+ #- 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;
- log::explanations("easy_dhcp: found eth0");
+ my $dhcp_intf = $ether_dev[0];
+ log::explanations("easy_dhcp: found $dhcp_intf");
- network::ethernet::conf_network_card_backend($netc, $intf, 'dhcp', 'eth0');
-
- put_in_hash($netc, {
+ 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;
}
@@ -411,22 +430,44 @@ sub easy_dhcp {
#- $intf->{$device}{DEVICE} : DEVICE = $device
#- $intf->{$device}{BOOTPROTO} : boot prototype : "bootp" or "dhcp" or "pump" or ...
sub configureNetwork2 {
- my ($in, $_prefix, $netc, $intf) = @_;
+ my ($in, $modules_conf, $_prefix, $netc, $intf) = @_;
my $etc = "$::prefix/etc";
if (!$::testing) {
- $netc->{wireless_eth} and $in->do_pkgs->ensure_is_installed('wireless-tools', '/sbin/iwconfig', 'auto');
- write_conf("$etc/sysconfig/network", $netc);
- write_resolv_conf("$etc/resolv.conf", $netc) if ! $netc->{DHCP};
- write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $netc, $::prefix) foreach grep { $_->{DEVICE} ne 'ppp0' } values %$intf;
- add2hosts("$etc/hosts", $netc->{HOSTNAME}, map { $_->{IPADDR} } values %$intf) if $netc->{HOSTNAME} && !$netc->{DHCP};
+ 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($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_is_installed('tmdns', '/sbin/tmdns', 'auto') if !$in->do_pkgs->is_installed('bind');
- $in->do_pkgs->ensure_is_installed('zcip', '/sbin/zcip', 'auto');
- write_zeroconf("$etc/tmdns.conf", $netc->{ZEROCONF_HOSTNAME});
- } else { run_program::rooted($::prefix, "chkconfig", "--del", $_) foreach qw(tmdns zcip) } # disable zeroconf
+ $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');
}
}
diff --git a/perl-install/network/nfs.pm b/perl-install/network/nfs.pm
index 39faa716e..37dd954e5 100644
--- a/perl-install/network/nfs.pm
+++ b/perl-install/network/nfs.pm
@@ -29,7 +29,7 @@ sub to_dev_raw {
sub check {
my ($_class, $in) = @_;
- $in->do_pkgs->ensure_is_installed('nfs-utils-clients', '/usr/sbin/showmount') or return;
+ $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;
}
diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm
index f518bd00e..94ce0abb1 100644
--- a/perl-install/network/shorewall.pm
+++ b/perl-install/network/shorewall.pm
@@ -69,7 +69,8 @@ sub default_interfaces {
my @l = detect_devices::getNet() or return;
-my @all_cards = network::ethernet::get_eth_cards();
+ 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+' });
@@ -128,9 +129,8 @@ sub write {
(map { [ 'loc', $_, 'detect' ] } @{$conf->{loc_interface} || []}),
);
set_config_file('policy',
- if_($conf->{loc_interface}[0], [ 'loc', 'net', 'ACCEPT' ]),
+ if_($conf->{loc_interface}[0], [ 'loc', 'net', 'ACCEPT' ], [ 'fw', 'loc', 'ACCEPT' ]),
[ 'fw', 'net', 'ACCEPT' ],
- [ 'fw', 'loc', 'ACCEPT' ],
[ 'net', 'all', 'DROP', 'info' ],
[ 'all', 'all', 'REJECT', 'info' ],
);
diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm
index 27a6a4186..57eba8234 100644
--- a/perl-install/network/smb.pm
+++ b/perl-install/network/smb.pm
@@ -15,9 +15,9 @@ 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);
+ my ($options, $unknown) = fs::mount_options::unpack($part);
$options->{"$_="} = $e->{server}{$_} foreach qw(username password domain);
- fs::mount_options_pack($part, $options, $unknown);
+ fs::mount_options::pack($part, $options, $unknown);
}
$part;
}
@@ -32,7 +32,7 @@ sub to_dev_raw {
sub check {
my ($_class, $in) = @_;
- $in->do_pkgs->ensure_is_installed('samba-client', '/usr/bin/nmblookup');
+ $in->do_pkgs->ensure_binary_is_installed('samba-client', 'nmblookup');
}
sub smbclient {
@@ -42,7 +42,15 @@ sub smbclient {
my $group = $server->{group} ? " -W $server->{group}" : '';
my $U = $server->{username} ? sprintf("%s/%s%%%s", @$server{'domain', 'username', 'password'}) : '%';
- `smbclient -U $U -L $name $ip$group 2>/dev/null`;
+ 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 {
@@ -64,10 +72,9 @@ sub find_servers {
}
if ($browse) {
my %l;
- foreach (smbclient($browse)) {
- my $nb = /^\s*Workgroup/ .. /^$/;
- $nb > 2 or next;
- my ($group, $name) = split(' ', lc($_));
+ my $workgroups = smbclient($browse)->{Workgroup} || [];
+ foreach (@$workgroups) {
+ my ($group, $name) = map { lc($_) } @$_;
# already done
next if any { $group eq $_->{group} } values %servers;
@@ -87,15 +94,14 @@ sub find_exports {
my ($_class, $server) = @_;
my @l;
- foreach (smbclient($server)) {
- chomp;
- s/^\t//;
- /NT_STATUS_/ and die $_;
- my ($name, $type, $comment) = unpack "A15 A10 A*", $_;
- if (($name eq '---------' && $type eq '----' && $comment eq '-------') .. /^$/) {
- push @l, { name => $name, type => $type, comment => $comment, server => $server }
- if $type eq 'Disk' && $name !~ /\$$/ && $name !~ /NETLOGON|SYSVOL/;
- }
+ 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;
}
@@ -116,11 +122,11 @@ sub fstab_entry_to_credentials {
my ($server_name) = network::smb->from_dev($part->{device}) or return;
- my ($options, $unknown) = fs::mount_options_unpack($part);
+ 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;
+ fs::mount_options::pack_($part, $options, $unknown), \%h;
}
sub remove_bad_credentials {
@@ -165,12 +171,12 @@ sub write_smb_conf {
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
- character set = ISO8859-15
+ unix charset = ISO8859-15
os level = 18
local master = No
dns proxy = No
- winbind uid = 10000-20000
- winbind gid = 10000-20000
+ idmap uid = 10000-20000
+ idmap gid = 10000-20000
winbind separator = +
template homedir = /home/%D/%U
template shell = /bin/bash
@@ -179,7 +185,7 @@ sub write_smb_conf {
}
sub write_smb_ads_conf {
- my ($domain,$realm) = @_;
+ 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
diff --git a/perl-install/network/smbnfs.pm b/perl-install/network/smbnfs.pm
index d9b53aedb..c38903028 100644
--- a/perl-install/network/smbnfs.pm
+++ b/perl-install/network/smbnfs.pm
@@ -35,9 +35,9 @@ sub to_fullstring {
$class->to_dev($e) . ($comment ? " ($comment)" : '');
}
sub to_fstab_entry_raw {
- my ($class, $e, $pt_type) = @_;
- my $fs_entry = { device => $class->to_dev($e), pt_type => $pt_type };
- fs::set_default_options($fs_entry);
+ 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;
}
diff --git a/perl-install/network/test.pm b/perl-install/network/test.pm
new file mode 100644
index 000000000..435e8a676
--- /dev/null
+++ b/perl-install/network/test.pm
@@ -0,0 +1,158 @@
+package network::test; # $Id$
+
+use strict;
+use MDK::Common;
+use run_program;
+use Socket;
+
+sub new {
+ my ($class, $o_hostname) = @_;
+ bless {
+ hostname => $o_hostname || "mandriva.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 Mandriva
+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 Mandriva
+#- 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
index aae98c90d..14fe48e3f 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -3,12 +3,13 @@ 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);
+@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";
@@ -71,11 +72,37 @@ sub passwd_by_login {
}
}
-sub connect_backend() { run_program::rooted($::prefix, "$connect_file &") }
+sub connect_backend {
+ my ($netc) = @_;
+ run_program::rooted($::prefix, "ifup $netc->{NET_INTERFACE} &");
+}
-sub disconnect_backend() { run_program::rooted($::prefix, "$disconnect_file &") }
+sub disconnect_backend {
+ my ($netc) = @_;
+ run_program::rooted($::prefix, "ifdown $netc->{NET_INTERFACE} &");
+}
-sub connected() { gethostbyname("mandrakesoft.com") ? 1 : 0 }
+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("mandriva.com") ? 1 : 0 }
# request a ref on a bg_connect and a ref on a scalar
sub connected_bg__raw {
@@ -145,21 +172,18 @@ sub check_link_beat() {
sub remove_initscript() {
$::testing and return;
- -e "$::prefix/etc/rc.d/init.d/internet" and do {
- $::isStandalone ? system("/sbin/chkconfig --del internet") : do {
- rm_rf("$::prefix/etc/rc.d/rc$_") foreach '0.d/K11internet', '1.d/K11internet', '2.d/K11internet',
- '3.d/S89internet', '5.d/S89internet', '6.d/K11internet';
- };
+ if (-e "$::prefix/etc/rc.d/init.d/internet") {
+ run_program::rooted($::prefix, "/sbin/chkconfig", "--del", "internet");
rm_rf("$::prefix/etc/rc.d/init.d/internet");
log::explanations("Removed internet service");
- };
+ }
}
sub use_windows {
my ($file) = @_;
my $all_hds = fsedit::get_hds({}, undef);
- fs::get_info_from_fstab($all_hds, '');
- my $part = find { $_->{device_windobe} eq 'C' } fsedit::get_fstab(@{$all_hds->{hds}});
+ fs::get_info_from_fstab($all_hds);
+ my $part = find { $_->{device_windobe} eq 'C' } fs::get::fstab($all_hds);
$part or my $failed = N("No partition available");
my $source = find { -d $_ && -r "$_/$file" } map { "$part->{mntpoint}/$_" } qw(windows/system winnt/system windows/system32/drivers winnt/system32/drivers);
log::explanations($failed || "Seek in $source to find firmware");
@@ -189,20 +213,12 @@ sub is_dynamic_host {
any { defined $_->{DHCP_HOSTNAME} } values %$intf;
}
-sub reread_net_conf {
- my ($netcnx, $netc, $intf) = @_;
- network::netconnect::read_net_conf('', $netcnx, $netc);
- modules::load_category('net');
- network::netconnect::load_conf($netcnx, $netc, $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) = @_;
- unquotify \$key;
- member(length($key), (5, 13)) ? qq("s:$key") : qq("$key");
+ member(length($key), (5, 13)) ? "s:$key" : $key;
}
sub get_wep_key_from_iwconfig {
@@ -213,4 +229,58 @@ sub get_wep_key_from_iwconfig {
$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;