summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-06-03 07:14:48 +0000
committerOlivier Blin <oblin@mandriva.org>2005-06-03 07:14:48 +0000
commit8fc41a1333f01496878ca0561f3ca1ad186b6d64 (patch)
tree2dd030c580d5b8e954bce95508ac7ecacc6127b9 /perl-install
parent671adafbfbb78f044970bc4af895ed43dff99757 (diff)
downloaddrakx-backup-do-not-use-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar
drakx-backup-do-not-use-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.gz
drakx-backup-do-not-use-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.bz2
drakx-backup-do-not-use-8fc41a1333f01496878ca0561f3ca1ad186b6d64.tar.xz
drakx-backup-do-not-use-8fc41a1333f01496878ca0561f3ca1ad186b6d64.zip
- merge network settings in a $net hash (it modifies $o fields too):
o $netc becomes $net->{network} and $net->{resolv} o $intf becomes $net->{ifcfg} - move zeroconf config stuff in write_zeroconf - read_tmdns_conf -> read_zeroconf - read_all_conf -> read_net_conf - configureNetwork2 -> configure_network - configure_network: write ifcfg files for ppp interfaces too - don't install wireless-tools in configure_network, this package is in basesystem - most functions don't need the file path as an argument in network::network - drop network::tools::remove_initscript - don't export too much from network::network - don't export from network::tools - remove adsl_unsupported_eci step in drakconnect - drop passwd2 field in network::adsl - drop $net->{isdn_internal} - network::netconnect : main -> safe_main - use network::netconnect::real_main during install - don't read network config in network::netconnect::real_main - install_steps::upNetwork : resolv.conf is already symlinked by network::network::configure_network when appropriate - try to fix install_any::generate_automatic_stage1_params to use a real interface configuration - put authentication stuff in $net->{auth} - drop network::ethernet::write_ether_conf - drop network::adsl::get_wizard - use 'static' instead of 'manual' as ADSL method - drop first_modem and its workarounds in network::modem - drop deprecated "multiple_internet_cnx" step in drakconnect - don't save /etc/sysconfig/drakconnect anymore - drop MDK::Common::Globals stuff - drop getIP in net_applet (Pixel) - drop $netc->{DHCP} - configure_network(): write resolv.conf even if a dhcp interface is configured
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/authentication.pm32
-rw-r--r--perl-install/install2.pm23
-rw-r--r--perl-install/install_any.pm20
-rw-r--r--perl-install/install_steps.pm25
-rw-r--r--perl-install/install_steps_interactive.pm15
-rw-r--r--perl-install/network/adsl.pm136
-rw-r--r--perl-install/network/adsl_consts.pm2
-rw-r--r--perl-install/network/ethernet.pm17
-rw-r--r--perl-install/network/isdn.pm2
-rw-r--r--perl-install/network/modem.pm18
-rw-r--r--perl-install/network/netconnect.pm492
-rw-r--r--perl-install/network/network.pm285
-rw-r--r--perl-install/network/tools.pm54
-rwxr-xr-xperl-install/standalone/drakauth9
-rwxr-xr-xperl-install/standalone/drakautoinst4
-rwxr-xr-xperl-install/standalone/drakconnect149
-rwxr-xr-xperl-install/standalone/drakpxe18
-rwxr-xr-xperl-install/standalone/finish-install12
-rw-r--r--perl-install/standalone/net_applet29
-rwxr-xr-xperl-install/standalone/net_monitor21
20 files changed, 538 insertions, 825 deletions
diff --git a/perl-install/authentication.pm b/perl-install/authentication.pm
index c59bc2d2e..b67e46159 100644
--- a/perl-install/authentication.pm
+++ b/perl-install/authentication.pm
@@ -73,7 +73,7 @@ sub domain_to_ldap_domain {
}
sub ask_parameters {
- my ($in, $netc, $authentication, $kind) = @_;
+ my ($in, $net, $authentication, $kind) = @_;
#- keep only this authentication kind
foreach (kinds()) {
@@ -81,15 +81,15 @@ sub ask_parameters {
}
if ($kind eq 'LDAP') {
- $netc->{LDAPDOMAIN} ||= domain_to_ldap_domain($netc->{DOMAINNAME});
+ $net->{auth}{LDAPDOMAIN} ||= domain_to_ldap_domain($net->{resolv}{DOMAINNAME});
$in->ask_from('',
N("Authentication LDAP"),
- [ { label => N("LDAP Base dn"), val => \$netc->{LDAPDOMAIN} },
+ [ { label => N("LDAP Base dn"), val => \$net->{auth}{LDAPDOMAIN} },
{ label => N("LDAP Server"), val => \$authentication->{LDAP_server} },
]) or return;
} elsif ($kind eq 'AD') {
- $authentication->{AD_domain} ||= $netc->{DOMAINNAME};
+ $authentication->{AD_domain} ||= $net->{resolv}{DOMAINNAME};
$authentication->{AD_users_db} ||= 'cn=users,' . domain_to_ldap_domain($authentication->{AD_domain});
$in->do_pkgs->install(qw(perl-Net-DNS));
@@ -125,10 +125,10 @@ sub ask_parameters {
} elsif ($kind eq 'NIS') {
$authentication->{NIS_server} ||= 'broadcast';
- $netc->{NISDOMAIN} ||= $netc->{DOMAINNAME};
+ $net->{network}{NISDOMAIN} ||= $net->{resolv}{DOMAINNAME};
$in->ask_from('',
N("Authentication NIS"),
- [ { label => N("NIS Domain"), val => \$netc->{NISDOMAIN} },
+ [ { label => N("NIS Domain"), val => \$net->{network}{NISDOMAIN} },
{ label => N("NIS Server"), val => \$authentication->{NIS_server}, list => ["broadcast"], not_edit => 0 },
]) or return;
} elsif ($kind eq 'winbind' || $kind eq 'SMBKRB') {
@@ -141,16 +141,16 @@ Should this setup fail for some reason and domain authentication is not working,
The command 'wbinfo -t' will test whether your authentication secrets are good."))
if $kind eq 'winbind';
- $authentication->{AD_domain} ||= $netc->{DOMAINNAME} if $kind eq 'SMBKRB';
+ $authentication->{AD_domain} ||= $net->{resolv}{DOMAINNAME} if $kind eq 'SMBKRB';
$authentication->{AD_users_idmap} ||= 'ou=idmap,' . domain_to_ldap_domain($authentication->{AD_domain}) if $kind eq 'SMBKRB';
- $netc->{WINDOMAIN} ||= $netc->{DOMAINNAME};
+ $net->{auth}{WINDOMAIN} ||= $net->{resolv}{DOMAINNAME};
my $anonymous;
$in->ask_from('',
$kind eq 'SMBKRB' ? N("Authentication Active Directory") : N("Authentication Windows Domain"),
[ if_($kind eq 'SMBKRB',
{ label => N("Domain"), val => \$authentication->{AD_domain} }
),
- { label => N("Windows Domain"), val => \$netc->{WINDOMAIN} },
+ { label => N("Windows Domain"), val => \$net->{auth}{WINDOMAIN} },
{ label => N("Domain Admin User Name"), val => \$authentication->{winuser} },
{ label => N("Domain Admin Password"), val => \$authentication->{winpass}, hidden => 1 },
{ label => N("Use Idmap for store UID/SID "), val => \$anonymous, type => 'bool' },
@@ -162,7 +162,7 @@ The command 'wbinfo -t' will test whether your authentication secrets are good."
}
sub ask_root_password_and_authentication {
- my ($in, $netc, $superuser, $authentication, $meta_class, $security) = @_;
+ my ($in, $net, $superuser, $authentication, $meta_class, $security) = @_;
my $kind = to_kind($authentication);
my @kinds = kinds($in->do_pkgs, $meta_class);
@@ -189,7 +189,7 @@ sub ask_root_password_and_authentication {
{ label => N("Authentication"), val => \$kind, type => 'list', list => \@kinds, format => \&kind2name, advanced => 1 },
]) or delete $superuser->{password};
- ask_parameters($in, $netc, $authentication, $kind) or goto &ask_root_password_and_authentication;
+ ask_parameters($in, $net, $authentication, $kind) or goto &ask_root_password_and_authentication;
}
@@ -205,7 +205,7 @@ sub get() {
}
sub set {
- my ($in, $netc, $authentication, $o_when_network_is_up) = @_;
+ my ($in, $net, $authentication, $o_when_network_is_up) = @_;
my $when_network_is_up = $o_when_network_is_up || sub { my ($f) = @_; $f->() };
@@ -230,7 +230,7 @@ sub set {
} elsif ($kind eq 'LDAP') {
$in->do_pkgs->install(qw(openldap-clients nss_ldap pam_ldap autofs));
- my $domain = $netc->{LDAPDOMAIN} || do {
+ my $domain = $net->{auth}{LDAPDOMAIN} || do {
my $s = run_program::rooted_get_stdout($::prefix, 'ldapsearch', '-x', '-h', $authentication->{LDAP_server}, '-b', '', '-s', 'base', '+');
first($s =~ /namingContexts: (.+)/);
} or log::l("no ldap domain found on server $authentication->{LDAP_server}"), return;
@@ -304,7 +304,7 @@ sub set {
} elsif ($kind eq 'NIS') {
$in->do_pkgs->install(qw(ypbind autofs));
- my $domain = $netc->{NISDOMAIN};
+ my $domain = $net->{auth}{NISDOMAIN};
$domain || $authentication->{NIS_server} ne "broadcast" or die N("Can not use broadcast with no NIS domain");
my $t = $domain ? "domain $domain" . ($authentication->{NIS_server} ne "broadcast" && " server") : "ypserver";
substInFile {
@@ -324,7 +324,7 @@ sub set {
#- TODO: also do it during install since nis can be useful to resolve domain names. Not done because 9.2-RC
} elsif ($kind eq 'winbind') {
- my $domain = uc $netc->{WINDOMAIN};
+ my $domain = uc $net->{auth}{WINDOMAIN};
$in->do_pkgs->install('samba-winbind');
@@ -342,7 +342,7 @@ sub set {
});
} elsif ($kind eq 'SMBKRB') {
$authentication->{AD_server} ||= 'ads.' . $authentication->{AD_domain};
- my $domain = uc $netc->{WINDOMAIN};
+ my $domain = uc $net->{auth}{WINDOMAIN};
my $realm = $authentication->{AD_domain};
configure_krb5_for_AD($authentication);
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 10a9abf8d..9b76bb651 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -54,12 +54,15 @@ $o = $::o = {
steps => \%steps::installSteps,
orderedSteps => \@steps::orderedInstallSteps,
-#- for the list of fields available for user and superuser, see @etc_pass_fields in install_steps.pm
-#- intf => { eth0 => { DEVICE => "eth0", IPADDR => '1.2.3.4', NETMASK => '255.255.255.128' } },
+ #- for the list of fields available, see network/network.pm
+ net => {
+ #- network => { HOSTNAME => 'abcd' },
+ #- resolv => { DOMAINNAME => 'foo.xyz' },
+ #- ifcfg => {
+ #- eth0 => { DEVICE => "eth0", IPADDR => '1.2.3.4', NETMASK => '255.255.255.128' }
+ #- },
+ },
- netc => {},
- intf => {},
-
#-step : the current one
#-prefix
#-mouse
@@ -266,7 +269,7 @@ sub configureNetwork {
my ($_clicked, $_ent_number, $auto) = @_;
#- get current configuration of network device.
require network::network;
- eval { network::network::read_all_conf($o->{prefix}, $o->{netc}, $o->{intf}) };
+ eval { network::network::read_net_conf($o->{net}) };
installStepsCall($o, $auto, 'configureNetwork') if !$o->{isUpgrade};
}
#------------------------------------------------------------------------------
@@ -480,17 +483,17 @@ sub main {
require network::network;
#- get stage1 network configuration if any.
log::l('found /tmp/network');
- $o->{netc} ||= {};
- add2hash($o->{netc}, network::network::read_conf('/tmp/network'));
+ #- FIXME: DOMAINNAME and DHCP_HOSTNAME shouldn't be in $o->{net}{network}
+ add2hash($o->{net}{network}, network::network::read_conf('/tmp/network'));
if (my ($file) = glob_('/tmp/ifcfg-*')) {
log::l("found network config file $file");
my $l = network::network::read_interface_conf($file);
- $o->{intf}{$l->{DEVICE}} ||= $l;
+ $o->{net}{ifcfg}{$l->{DEVICE}} ||= $l;
}
if (-e '/etc/resolv.conf') {
my $file = '/etc/resolv.conf';
log::l("found network config file $file");
- add2hash($o->{netc}, network::network::read_resolv_conf($file));
+ add2hash($o->{net}{resolv}, network::network::read_resolv_conf($file));
}
}
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 371de8790..e0fd743a8 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -423,7 +423,7 @@ sub prep_net_suppl_media {
#- from install_steps_interactive:
local $::expert = $::expert;
require network::netconnect;
- network::netconnect::main($o->{netcnx} ||= {}, $o, $o->{modules_conf}, $o->{netc}, $o->{mouse}, $o->{intf}, 0, 1);
+ network::netconnect::real_main($o->{net}, $o, $o->{modules_conf});
require install_interactive;
install_interactive::upNetwork($o);
sleep(3);
@@ -902,7 +902,7 @@ sub set_authentication {
} 'configureNetwork';
};
require authentication;
- authentication::set($o, $o->{netc}, $o->{authentication} ||= {}, $when_network_is_up);
+ authentication::set($o, $o->{net}, $o->{authentication} ||= {}, $when_network_is_up);
}
sub killCardServices() {
@@ -1147,7 +1147,7 @@ sub g_auto_install {
$_->{mntpoint} && fs::format::known_type($_);
} @{$::o->{fstab}} ];
- exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(locale authentication mouse netc timezone superuser intf keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security security_user libsafe netcnx useSupermount autoExitInstall X services postInstall postInstallNonRooted); #- TODO modules bootloader
+ exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(locale authentication mouse net timezone superuser keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security security_user libsafe useSupermount autoExitInstall X services postInstall postInstallNonRooted); #- TODO modules bootloader
$o->{printer} = $::o->{printer} if $::o->{printer};
@@ -1164,10 +1164,10 @@ sub g_auto_install {
);
$_ = { %{$_ || {}} }, delete @$_{@user_info_to_remove} foreach $o->{superuser}, @{$o->{users} || []};
- if ($b_respect_privacy && $o->{netcnx}) {
- if (my $type = $o->{netcnx}{type}) {
- my @netcnx_type_to_remove = qw(passwd passwd2 login phone_in phone_out);
- $_ = { %{$_ || {}} }, delete @$_{@netcnx_type_to_remove} foreach $o->{netcnx}{$type};
+ if ($b_respect_privacy && $o->{net}) {
+ if (my $type = $o->{net}{type}) {
+ my @net_type_to_remove = qw(passwd login phone_in phone_out);
+ $_ = { %{$_ || {}} }, delete @$_{@net_type_to_remove} foreach $o->{net}{$type};
}
}
my $warn_privacy = $b_respect_privacy ? "!! This file has been simplified to respect privacy when reporting problems.
@@ -1369,14 +1369,14 @@ sub generate_automatic_stage1_params {
if ($ENV{PROXY}) {
push @ks, proxy_host => $ENV{PROXY}, proxy_port => $ENV{PROXYPORT};
}
- my ($intf) = values %{$o->{intf}};
+ my ($intf) = first(values %{$o->{net}{ifcfg}});
push @ks, interface => $intf->{DEVICE};
if ($intf->{BOOTPROTO} eq 'dhcp') {
push @ks, network => 'dhcp';
} else {
- push @ks, network => 'static', ip => $intf->{IPADDR}, netmask => $intf->{NETMASK}, gateway => $o->{netc}{GATEWAY};
+ push @ks, network => 'static', ip => $intf->{IPADDR}, netmask => $intf->{NETMASK}, gateway => $o->{net}{network}{GATEWAY};
require network::network;
- if (my @dnss = network::network::dnsServers($o->{netc})) {
+ if (my @dnss = network::network::dnsServers($o->{net})) {
push @ks, dns => $dnss[0];
}
}
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index f4b170a93..356541707 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -404,7 +404,7 @@ sub beforeInstallPackages {
install_any::write_fstab($o);
require network::network;
- network::network::add2hosts("$o->{prefix}/etc/hosts", "localhost", "127.0.0.1");
+ network::network::add2hosts("localhost", "127.0.0.1");
log::l("setting excludedocs to $o->{excludedocs}");
substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$o->{prefix}/etc/rpm/macros";
@@ -655,10 +655,9 @@ sub selectMouse($) {
sub configureNetwork {
my ($o) = @_;
require network::network;
- network::network::configureNetwork2($o, $o->{modules_conf}, $o->{prefix}, $o->{netc}, $o->{intf});
+ network::network::configure_network($o->{net}, $o, $o->{modules_conf});
if ($o->{method} =~ /ftp|http|nfs/) {
- $o->{netcnx}{type} = 'lan';
- $o->{netcnx}{$_} = $o->{netc}{$_} foreach qw(NET_DEVICE NET_INTERFACE);
+ $o->{net}{type} = 'lan';
}
configure_firewall($o) if !$o->{isUpgrade};
@@ -965,8 +964,8 @@ risk!
#------------------------------------------------------------------------------
sub hasNetwork {
my ($o) = @_;
- $o->{netcnx}{type} && $o->{netc}{NETWORKING} ne 'no' and return 1;
- log::l("no network seems to be configured for internet ($o->{netcnx}{type},$o->{netc}{NETWORKING})");
+ $o->{net}{type} && $o->{net}{network}{NETWORKING} ne 'no' and return 1;
+ log::l("no network seems to be configured for internet ($o->{net}{type},$o->{net}{network}{NETWORKING})");
0;
}
@@ -974,27 +973,23 @@ sub hasNetwork {
sub upNetwork {
my ($o, $b_pppAvoided) = @_;
- #- do not destroy this file if prefix is '' or even '/' (could it happens ?).
- if (length($o->{prefix}) > 1) {
- -f "$o->{prefix}/etc/$_" && symlinkf("$o->{prefix}/etc/$_", "/etc/$_") foreach qw(resolv.conf protocols services);
- }
member($o->{method}, qw(ftp http nfs)) and return 1;
$o->{modules_conf}->write;
if (hasNetwork($o)) {
- if ($o->{netcnx}{type} =~ /adsl|lan|cable/) {
- log::l("starting network ($o->{netcnx}{type})");
+ if ($o->{net}{type} =~ /adsl|lan|cable/) {
+ log::l("starting network ($o->{net}{type})");
require network::netconnect;
network::netconnect::start_internet($o);
return 1;
} elsif (!$b_pppAvoided) {
- log::l("starting network (ppp: $o->{netcnx}{type})");
+ log::l("starting network (ppp: $o->{net}{type})");
eval { modules::load(qw(serial ppp bsd_comp ppp_deflate)) };
run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "start");
require network::netconnect;
network::netconnect::start_internet($o);
return 1;
} else {
- log::l(qq(not starting network (b/c ppp avoided and type is "$o->{netcnx}{type})"));
+ log::l(qq(not starting network (b/c ppp avoided and type is "$o->{net}{type})"));
}
}
$::testing;
@@ -1011,7 +1006,7 @@ sub downNetwork {
require network::netconnect;
network::netconnect::stop_internet($o);
return 1;
- } elsif ($o->{netc}{type} !~ /adsl|lan|cable/) {
+ } elsif (member($o->{net}{type}, qw(adsl lan cable))) {
require network::netconnect;
network::netconnect::stop_internet($o);
run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "stop");
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 63f2df1a1..8f5c0ff44 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -785,10 +785,10 @@ sub configureNetwork {
if ($o->{meta_class} eq 'firewall') {
require network::netconnect;
- network::netconnect::main($o->{netcnx} ||= {}, $o, $o->{modules_conf}, $o->{netc}, $o->{mouse}, $o->{intf}, 0, 1);
+ network::netconnect::real_main($o->{net}, $o, $o->{modules_conf});
} else {
require network::network;
- network::network::easy_dhcp($o->{modules_conf}, $o->{netc}, $o->{intf}) and $o->{netcnx}{type} = 'lan';
+ network::network::easy_dhcp($o->{net}, $o->{modules_conf});
$o->SUPER::configureNetwork;
}
}
@@ -914,7 +914,7 @@ sub summaryBefore {
#- get back network configuration.
require network::network;
eval {
- network::network::read_all_conf($o->{prefix}, $o->{netc} ||= {}, $o->{intf} ||= {}, $o->{netcnx} ||= {});
+ network::network::read_net_conf($o->{net});
};
log::l("summaryBefore: network configuration: ", formatError($@)) if $@;
}
@@ -1061,14 +1061,11 @@ sub summary {
push @l, {
group => N("Network & Internet"),
label => N("Network"),
- val => sub { $o->{netcnx}{type} },
+ val => sub { $o->{net}{type} },
clicked => sub {
local $::expert = $::expert;
require network::netconnect;
- network::netconnect::main($o->{netcnx} ||= {}, $o, $o->{modules_conf}, $o->{netc}, $o->{mouse}, $o->{intf}, 0, 1);
- #- in case netcnx type is not updated.
- require network::network;
- network::network::probe_netcnx_type($o->{prefix}, $o->{netc}, $o->{intf}, $o->{netcnx});
+ network::netconnect::real_main($o->{net}, $o, $o->{modules_conf});
},
};
@@ -1194,7 +1191,7 @@ sub setRootPassword {
if ($o->{security} >= 1 || $clicked) {
require authentication;
- authentication::ask_root_password_and_authentication($o, $o->{netc}, $sup, $o->{authentication} ||= {}, $o->{meta_class}, $o->{security});
+ authentication::ask_root_password_and_authentication($o, $o->{net}, $sup, $o->{authentication} ||= {}, $o->{meta_class}, $o->{security});
}
install_steps::setRootPassword($o);
}
diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm
index d12627387..6b6e07fb8 100644
--- a/perl-install/network/adsl.pm
+++ b/perl-install/network/adsl.pm
@@ -10,77 +10,23 @@ use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(adsl_conf_backend);
-
-sub get_wizard {
- my ($wiz) = @_;
- my $netc = $wiz->{var}{netc};
-
- my %l = (
- 'pppoe' => N("use PPPoE"),
- 'pptp' => N("use PPTP"),
- 'dhcp' => N("use DHCP"),
- 'speedtouch' => N("Alcatel Speedtouch USB") . if_($netc->{autodetect}{adsl}{speedtouch}, N(" - detected")),
- 'sagem' => N("Sagem (using PPPoA) USB") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
- 'sagem_dhcp' => N("Sagem (using DHCP) USB") . if_($netc->{autodetect}{adsl}{sagem}, N(" - detected")),
- # 'eci' => N("ECI Hi-Focus"), # this one needs eci agreement
- );
-
- $wiz->{var}{adsl} = {
- connection_list => \%l,
- type => "",
- };
- add2hash($wiz->{pages},
- {
- adsl_old => {
- name => N("Connect to the Internet") . "\n\n" .
- N("The most common way to connect with adsl is pppoe.
-Some connections use PPTP, a few use DHCP.
-If you do not know, choose 'use PPPoE'"),
- data => [
- {
- label => N("ADSL connection type:"), val => \$wiz->{var}{adsl}{type}, list => [ sort values %l ] },
- ],
- pre => sub {
- $wiz->{var}{adsl}{type} = $l{sagem}; # debug
- $wiz->{var}{adsl}{type} ||= find { $netc->{autodetect}{adsl}{$_} } keys %l;
- print qq(\n\ntype is "$wiz->{var}{adsl}{type}"\n\n);
- },
- post => sub {
- $wiz->{var}{adsl}{type} = find { $l{$_} eq $wiz->{var}{adsl}{type} } keys %l;
- my $adsl = $wiz->{var}{adsl}{connection};
- my $type = $wiz->{var}{adsl}{type};
- my $netcnx = $wiz->{var}{netcnx};
- $netcnx->{type} = "adsl_$type";
-
- $netcnx->{"adsl_$type"} = {};
- $netcnx->{"adsl_$type"}{vpivci} = '' if $type =~ /eci|speedtouch/;
- return 'ethernet' if $type eq 'dhcp';
- adsl_probe_info($adsl, $netc, $type);
- # my ($adsl, $netc, $intf, $adsl_type) = @_;
- # ask_info2($adsl, $netc);
- return "hw_account";
- },
- },
- });
-}
-
sub adsl_probe_info {
- my ($adsl, $netc, $adsl_type, $o_adsl_modem) = @_;
+ my ($net) = @_;
my $pppoe_file = "$::prefix/etc/ppp/pppoe.conf";
- my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (! defined $adsl_type || $adsl_type eq 'pppoe') && -f $pppoe_file;
+ my %pppoe_conf; %pppoe_conf = getVarsFromSh($pppoe_file) if (!exists $net->{adsl}{method} || $net->{adsl}{method} eq 'pppoe') && -f $pppoe_file;
my $login = $pppoe_conf{USER};
foreach (qw(/etc/ppp/peers/ppp0 /etc/ppp/options /etc/ppp/options.adsl)) {
($login) = map { if_(/^user\s+"([^"]+)"/, $1) } cat_("$::prefix/$_") if !$login && -r "$::prefix/$_";
}
- my $passwd = passwd_by_login($login);
- if (!$netc->{vpi} && !$netc->{vci} && member($o_adsl_modem, qw(eci speedtouch))) {
- ($netc->{vpi}, $netc->{vci}) =
+ my $passwd = network::tools::passwd_by_login($login);
+ if (!$net->{adsl}{vpi} && !$net->{adsl}{vci}) {
+ ($net->{adsl}{vpi}, $net->{adsl}{vci}) =
(map { if_(/^.*-vpi\s+(\d+)\s+-vci\s+(\d+)/, map { sprintf("%x", $_) } $1, $2) } cat_("$::prefix/etc/ppp/peers/ppp0"));
}
$pppoe_conf{DNS1} ||= '';
$pppoe_conf{DNS2} ||= '';
- add2hash($netc, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' });
- add2hash($adsl, { login => $login, passwd => $passwd, passwd2 => '' });
+ add2hash($net->{resolv}, { dnsServer2 => $pppoe_conf{DNS1}, dnsServer3 => $pppoe_conf{DNS2}, DOMAINNAME2 => '' });
+ add2hash($net->{adsl}, { login => $login, passwd => $passwd });
}
sub adsl_detect() {
@@ -101,8 +47,10 @@ sub adsl_detect() {
}
sub sagem_set_parameters {
- my ($netc) = @_;
- my %l = map { $_ => sprintf("%08s", $netc->{$_}) } qw(vci vpi Encapsulation);
+ my ($net) = @_;
+ my %l = map { $_ => sprintf("%08s", $net->{adsl}{$_}) } qw(vci vpi Encapsulation);
+
+ my $static_ip = $net->{adsl}{method} eq 'static' && $net->{ifcfg}{sagem}{IPADDR};
foreach my $cfg_file (qw(/etc/analog/adiusbadsl.conf /etc/eagle-usb/eagle-usb.conf)) {
substInFile {
s/Linetype=.*\n/Linetype=0000000A\n/; #- use CMVs
@@ -110,16 +58,16 @@ sub sagem_set_parameters {
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};
+ s!</eaglectrl>!STATIC_IP=$static_ip\n</eaglectrl>! if $static_ip;
#- TODO: add ISP info, $netc->{provider_id}
} "$::prefix$cfg_file";
}
#- create CMV symlinks for both POTS and ISDN lines
foreach my $type (qw(p i)) {
my $cmv;
- my ($country) = $netc->{provider_id} =~ /^([a-zA-Z]+)\d+$/;
+ my ($country) = $net->{adsl}{provider_id} =~ /^([a-zA-Z]+)\d+$/;
#- try to find a CMV for this specific ISP
- $cmv = "$::prefix/etc/eagle-usb/CMVe${type}$netc->{provider_id}.txt" if $netc->{provider_id};
+ $cmv = "$::prefix/etc/eagle-usb/CMVe${type}$net->{adsl}{provider_id}.txt" if $net->{adsl}{provider_id};
#- if not found, try to found a CMV for the country
-f $cmv or $cmv = "$::prefix/etc/eagle-usb/CMVe${type}${country}.txt";
#- fallback on the generic CMV if no other matched
@@ -131,14 +79,13 @@ sub sagem_set_parameters {
}
sub adsl_conf_backend {
- my ($in, $modules_conf, $adsl, $netc, $intf, $adsl_device, $adsl_type, $o_netcnx) = @_;
- # FIXME: should not be needed:
- defined $o_netcnx and $netc->{adsltype} = $o_netcnx->{type};
- $netc->{adsltype} ||= "adsl_$adsl_type";
- $adsl_type eq 'pptp' and $adsl_device = 'pptp_modem';
- $adsl_type eq 'capi' and $adsl_device = 'capi_modem';
+ my ($in, $modules_conf, $net) = @_;
+
my $bewan_module;
- $bewan_module = $o_netcnx->{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $adsl_device eq "bewan";
+ $bewan_module = $net->{adsl}{bus} eq 'PCI' ? 'unicorn_pci_atm' : 'unicorn_usb_atm' if $net->{adsl}{device} eq "bewan";
+
+ my $adsl_type = $net->{adsl}{method};
+ my $adsl_device = $net->{adsl}{device};
# all supported modems came with their own pppoa module, so no need for "plugin pppoatm.so"
my %modems =
@@ -154,7 +101,7 @@ sleep 10
),
stop => qq(modprobe -r $bewan_module),
plugin => {
- pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci}))
+ pppoa => "pppoatm.so " . join('.', hex($net->{adsl}{vpi}), hex($net->{adsl}{vci}))
},
ppp_options => qq(
default-asyncmap
@@ -178,7 +125,7 @@ sync
pppoa => qq("/usr/sbin/pppoa3 -c")
},
plugin => {
- pppoa => "pppoatm.so " . join('.', hex($netc->{vpi}), hex($netc->{vci})),
+ pppoa => "pppoatm.so " . join('.', hex($net->{adsl}{vpi}), hex($net->{adsl}{vci})),
},
ppp_options => qq(
sync
@@ -222,7 +169,7 @@ novjccomp),
{
start => '/usr/bin/startmodem',
server => {
- pppoe => qq("/usr/bin/pppoeci -v 1 -vpi $netc->{vpi} -vci $netc->{vci}"),
+ pppoe => qq("/usr/bin/pppoeci -v 1 -vpi $net->{adsl}{vpi} -vci $net->{adsl}{vci}"),
},
ppp_options => qq(
noipdefault
@@ -268,7 +215,7 @@ avmadsl)
(
pppoe =>
{
- server => '"pppoe -I ' . ($modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $netc->{NET_DEVICE}) . '"',
+ server => '"pppoe -I ' . ($modems{$adsl_device}{get_intf} ? "`$modems{$adsl_device}{get_intf}`" : $net->{adsl}{ethernet_device}) . '"',
ppp_options => qq(default-asyncmap
mru 1492
mtu 1492
@@ -320,15 +267,15 @@ holdoff 4
maxfail 25
$pty_option
$plugin
-user "$adsl->{login}"
+user "$net->{adsl}{login}"
));
- write_secret_backend($adsl->{login}, $adsl->{passwd});
+ network::tools::write_secret_backend($net->{adsl}{login}, $net->{adsl}{passwd});
- if ($netc->{NET_DEVICE} =~ /^eth/) {
- my $net_device = $netc->{NET_DEVICE};
- $intf->{$net_device} = {
- DEVICE => $net_device,
+ my $ethernet_device = $net->{adsl}{ethernet_device};
+ if ($ethernet_device =~ /^eth/) {
+ $net->{ifcfg}{$ethernet_device} = {
+ DEVICE => $ethernet_device,
BOOTPROTO => 'none',
NETMASK => '255.255.255.0',
NETWORK => '10.0.0.0',
@@ -340,20 +287,17 @@ user "$adsl->{login}"
#- FIXME: ppp0 and ippp0 are hardcoded
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=ADSL
-METRIC=$metric
-)) unless member($adsl_type, qw(manual dhcp));
+ put_in_hash($net->{ifcfg}{ppp0}, {
+ DEVICE => 'ppp0',
+ TYPE => 'ADSL',
+ METRIC => $metric,
+ }) unless member($adsl_type, qw(static dhcp));
#- remove file used with sagem for dhcp/static connections
unlink("$::prefix/etc/sysconfig/network-scripts/ifcfg-sagem");
#- set vpi, vci and encapsulation parameters for sagem
- if ($adsl_device eq 'sagem') {
- $netc->{static_ip} = $intf->{sagem}{IPADDR} if $adsl_type eq 'manual';
- sagem_set_parameters($netc);
- }
+ $adsl_device eq 'sagem' and sagem_set_parameters($net);
#- set aliases
if (exists $modems{$adsl_device}{aliases}) {
@@ -365,11 +309,9 @@ METRIC=$metric
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");
+ network::isdn::setup_capi_conf($net->{adsl}{capi_card});
+ services::set_status('isdn4linux', 0);
+ services::set_status('capi4linux', 1);
#- install and run drdsl for dsl connections, once capi driver is loaded
$in->do_pkgs->ensure_is_installed_if_available("drdsl", "/usr/sbin/drdsl");
diff --git a/perl-install/network/adsl_consts.pm b/perl-install/network/adsl_consts.pm
index 93b6dba33..a360b7887 100644
--- a/perl-install/network/adsl_consts.pm
+++ b/perl-install/network/adsl_consts.pm
@@ -583,7 +583,7 @@ our %adsl_data = (
vpi => 8,
vci => 23,
Encapsulation => 3,
- method => 'manual',
+ method => 'static',
},
N("Italy") . "|Tiscali.it, Alice" =>
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 35e22308b..dcda7b643 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -12,31 +12,16 @@ use network::tools;
our @dhcp_clients = qw(dhclient dhcpcd pump dhcpxd);
sub install_dhcp_client {
- my ($in, $ethntf) = @_;
+ my ($in, $client) = @_;
my %packages = (
"dhclient" => "dhcp-client",
);
- my $client = $ethntf->{DHCP_CLIENT};
#- use default dhcp client if none is provided
$client ||= $dhcp_clients[0];
$client = $packages{$client} if exists $packages{$client};
$in->do_pkgs->install($client);
}
-sub write_ether_conf {
- my ($in, $modules_conf, $netcnx, $netc, $intf) = @_;
- configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
- $netc->{NETWORKING} = "yes";
- if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} =~ /dhcp/ } values %$intf) {
- $netcnx->{type} = 'lan';
- $netcnx->{NET_DEVICE} = $netc->{NET_DEVICE} = '';
- $netcnx->{NET_INTERFACE} = 'lan'; #$netc->{NET_INTERFACE};
- }
- $::isStandalone and $modules_conf->write;
- 1;
-}
-
-
sub mapIntfToDevice {
my ($interface) = @_;
my $hw_addr = c::getHwIDs($interface);
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index 21e701bb5..5c835c154 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -116,7 +116,7 @@ my $file = "$ENV{SHARE_PATH}/ldetect-lst/isdn.db";
$file = "$::prefix$file" if !-e $file;
sub get_info_providers_backend {
- my ($isdn, $_netc, $name) = @_;
+ my ($isdn, $name) = @_;
$name eq N("Unlisted - edit manually") and return;
foreach (catMaybeCompressed($file)) {
chop;
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index 6359069eb..f600db844 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -8,12 +8,6 @@ use detect_devices;
use mouse;
use network::tools;
-sub first_modem {
- my ($netc) = @_;
- return "/mnt/root" if $::isInstall;
- first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}});
-}
-
sub get_user_home() {
my $home;
if ($ENV{USER} ne "root") {
@@ -25,13 +19,8 @@ sub get_user_home() {
$home;
}
-sub ppp_read_conf {
- my ($netcnx, $netc) = @_;
- my $modem = $netcnx->{$netcnx->{type}} ||= {};
- if (my $detected_modem = first_modem($netc)) {
- $modem->{device} ||= $detected_modem->{device};
- }
- $modem->{device} ||= '/dev/modem';
+sub ppp_read_conf() {
+ my $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/;
@@ -58,14 +47,13 @@ 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->{device} ||= '/dev/modem';
$modem;
}
#-----modem conf
sub ppp_configure {
my ($in, $modem) = @_;
- $modem or return;
$in->do_pkgs->install('ppp') if !$::testing;
$in->do_pkgs->install('kdenetwork-kppp') if !$::testing && $in->do_pkgs->is_installed('kdebase');
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index 1b98ef6c0..1982b0afe 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -5,15 +5,11 @@ use common;
use log;
use detect_devices;
use list_modules;
-use run_program;
use modules;
-use any;
-use fs;
use mouse;
use network::network;
use network::tools;
use network::thirdparty;
-use MDK::Common::Globals "network", qw($in);
sub detect {
my ($modules_conf, $auto_detect, $o_class) = @_;
@@ -39,11 +35,6 @@ sub detect {
return;
}
-sub init_globals {
- my ($in) = @_;
- MDK::Common::Globals::init(in => $in);
-}
-
sub detect_timezone() {
my %tmz2country = (
'Europe/Paris' => N("France"),
@@ -63,31 +54,16 @@ sub detect_timezone() {
\@country;
}
-# load sub category's wizard pages into main wizard data structure
-sub get_subwizard {
- my ($wiz, $type) = @_;
- my %net_conf_callbacks = (adsl => sub { require network::adsl; &network::adsl::get_wizard },
- #cable => sub { require network::ethernet; &network::ethernet::get_wizard },
- #isdn => sub { require network::isdn; &network::isdn::get_wizard },
- #lan => sub { require network::ethernet; &network::ethernet::get_wizard },
- #modem => sub { require network::modem; &network::modem::get_wizard },
- );
- $net_conf_callbacks{$type}->($wiz);
-}
-
-# configuring all network devices
sub real_main {
- my ($netcnx, $in, $modules_conf, $o_netc, $o_mouse, $o_intf, $o_first_time, $o_noauto) = @_;
- my $netc = $o_netc ||= {};
- my $mouse = $o_mouse ||= {};
- my $intf = $o_intf ||= {};
- my $first_time = $o_first_time || 0;
- my ($network_configured, $cnx_type, $type, @all_cards, %eth_intf, %all_eth_intf);
+ my ($net, $in, $modules_conf) = @_;
+ #- network configuration should have been already read in $net at this point
+ my $mouse = $::o->{mouse} || {};
+ my ($cnx_type, @all_cards, %eth_intf, %all_eth_intf);
my (%connections, @connection_list);
- my ($modem, $modem_name, $modem_conf_read, $modem_dyn_dns, $modem_dyn_ip);
+ my ($modem, $modem_name, $modem_dyn_dns, $modem_dyn_ip);
my $cable_no_auth;
- my ($adsl_type, @adsl_devices, %adsl_cards, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider, $adsl_vpi, $adsl_vci);
- my ($ntf_name, $gateway_ex, $up, $need_restart_network);
+ my (@adsl_devices, %adsl_cards, %adsl_data, $adsl_data, $adsl_provider, $adsl_old_provider, $adsl_vpi, $adsl_vci);
+ my ($ntf_name, $gateway_ex, $up);
my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods);
my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")");
my (@ndiswrapper_drivers, $ndiswrapper_driver, $ndiswrapper_device);
@@ -98,8 +74,6 @@ sub real_main {
my $ethntf = {};
my $db_path = "/usr/share/apps/kppp/Provider";
my (%countries, @isp, $country, $provider, $old_provider);
- my $config = {};
- eval(cat_("$::prefix/etc/sysconfig/drakconnect"));
my %l10n_lan_protocols = (
static => N("Manual configuration"),
@@ -114,16 +88,10 @@ sub real_main {
3 => N("Protocol for the rest of the world\nNo D-Channel (leased lines)"),
);
- network::tools::remove_initscript();
-
- init_globals($in);
-
- read_net_conf($netcnx, $netc, $intf);
-
- $netc->{autodetect} = {};
+ $net->{autodetect} = {};
my $lan_detect = sub {
- detect($modules_conf, $netc->{autodetect}, 'lan');
+ detect($modules_conf, $net->{autodetect}, 'lan');
require network::ethernet;
modules::interactive::load_category($in, $modules_conf, list_modules::ethernet_categories(), !$::expert, 0);
@all_cards = network::ethernet::get_eth_cards($modules_conf);
@@ -159,7 +127,7 @@ sub real_main {
my %adsl_types = (
dhcp => N("Dynamic Host Configuration Protocol (DHCP)"),
- manual => N("Manual TCP/IP configuration"),
+ static => N("Manual TCP/IP configuration"),
pptp => N("Point to Point Tunneling Protocol (PPTP)"),
pppoe => N("PPP over Ethernet (PPPoE)"),
pppoa => N("PPP over ATM (PPPoA)"),
@@ -191,60 +159,36 @@ sub real_main {
);
my $offer_to_connect = sub {
- return "ask_connect_now" if $netc->{internet_cnx_choice} eq 'adsl' && !member($adsl_type, qw(manual dhcp));
- return "ask_connect_now" if member($netc->{internet_cnx_choice}, qw(modem isdn isdn_external));
+ if ($net->{type} eq 'adsl' && !member($net->{adsl}{method}, qw(static dhcp)) ||
+ member($net->{type}, qw(modem isdn isdn_external))) {
+ return "ask_connect_now";
+ }
return "end";
};
my $after_lan_intf_selection = sub { $is_wireless ? 'wireless' : 'lan_protocol' };
my $after_start_on_boot_step = sub {
- if ($netc->{internet_cnx_choice} && exists $netc->{internet_cnx}{$netc->{internet_cnx_choice}}) {
- $netcnx->{type} = $netc->{internet_cnx}{$netc->{internet_cnx_choice}}{type};
- } else {
- undef $netc->{NET_DEVICE};
- }
- if ($netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp)) && member($ntf_name, qw(sagem speedtouch))) {
- #- we may need to write sagem specific parameters and load corresponding modules/programs (sagem/speedtouch)
- 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 && !$::isInstall && !$::expert;
+ #- can't be done in adsl_account step because of static/dhcp adsl methods
+ #- we need to write sagem specific parameters and load corresponding modules/programs (sagem/speedtouch)
+ $net->{type} eq 'adsl' and network::adsl::adsl_conf_backend($in, $modules_conf, $net);
+
+ network::network::configure_network($net, $in, $modules_conf);
return $offer_to_connect->();
};
my $goto_start_on_boot_ifneeded = sub {
- return $after_start_on_boot_step->() if $netcnx->{type} eq "lan";
- return "isdn_dial_on_boot" if $netcnx->{type} eq 'isdn';
+ return $after_start_on_boot_step->() if $net->{type} eq "lan";
+ return "isdn_dial_on_boot" if $net->{type} eq 'isdn';
return "network_on_boot";
};
- my $save_cnx = sub {
- if (keys %$config) {
- require Data::Dumper;
- output("$::prefix/etc/sysconfig/drakconnect", Data::Dumper->Dump([ $config ], [ '$p' ]));
- }
- return "allow_user_ctl";
- };
-
- my $handle_multiple_cnx = sub {
- $need_restart_network = member($netcnx->{type}, qw(cable lan)) || $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
- my $nb = keys %{$netc->{internet_cnx}};
- if (1 < $nb) {
- return "multiple_internet_cnx";
- } else {
- $netc->{internet_cnx_choice} = $nb == 1 ? (keys %{$netc->{internet_cnx}})[0] : $netcnx->{type};
- return $save_cnx->();
- }
- };
-
my $delete_gateway_settings = sub {
my ($device) = @_;
#- delete gateway settings if gateway device is invalid or matches the reconfigured device
- if (!$netc->{GATEWAYDEV} || !exists $eth_intf{$netc->{GATEWAYDEV}} || $netc->{GATEWAYDEV} eq $device) {
- delete $netc->{GATEWAY};
- delete $netc->{GATEWAYDEV};
+ if (!$net->{network}{GATEWAYDEV} || !exists $eth_intf{$net->{network}{GATEWAYDEV}} || $net->{network}{GATEWAYDEV} eq $device) {
+ delete $net->{network}{GATEWAY};
+ delete $net->{network}{GATEWAYDEV};
}
};
@@ -258,7 +202,7 @@ sub real_main {
#- redetect interfaces (so that the ndiswrapper module can be detected)
$lan_detect->();
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
1;
};
@@ -297,10 +241,6 @@ sub real_main {
welcome =>
{
pre => sub {
- # keep b/c of translations in case they can be reused somewhere else:
- my @_a = (N("(detected on port %s)", 'toto'),
- #-PO: here, "(detected)" string will be appended to eg "ADSL connection"
- N("(detected %s)", 'toto'), N("(detected)"));
my @connections = (
[ N("LAN connection"), "lan" ],
[ N("Wireless connection"), "lan" ],
@@ -323,35 +263,24 @@ sub real_main {
data => \@connection_list,
post => sub {
$is_wireless = $cnx_type eq N("Wireless connection");
- #- why read again the net_conf here?
- read_net_conf($netcnx, $netc, $intf) if $::isInstall; # :-(
- $type = $netcnx->{type} = $connections{$cnx_type};
- return $type;
+ return $net->{type} = $connections{$cnx_type};
},
},
- prepare_detection =>
- {
- name => N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.",
- translate($type), N("Next")),
- post => $handle_multiple_cnx,
- },
-
-
isdn_account =>
{
pre => sub {
- network::isdn::get_info_providers_backend($isdn, $netc, $provider);
+ network::isdn::get_info_providers_backend($isdn, $provider);
$isdn->{huptimeout} ||= 180;
},
name => N("Connection Configuration") . "\n\n" . N("Please fill or check the field below"),
data => sub {
[
{ label => N("Your personal phone number"), val => \$isdn->{phone_in} },
- { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} },
+ { label => N("Provider name (ex provider.net)"), val => \$net->{resolv}{DOMAINNAME2} },
{ label => N("Provider phone number"), val => \$isdn->{phone_out} },
- { label => N("Provider DNS 1 (optional)"), val => \$netc->{dnsServer2} },
- { label => N("Provider DNS 2 (optional)"), val => \$netc->{dnsServer3} },
+ { label => N("Provider DNS 1 (optional)"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("Provider DNS 2 (optional)"), val => \$net->{resolv}{dnsServer3} },
{ label => N("Dialing mode"), list => ["auto", "manual"], val => \$isdn->{dialing_mode} },
{ label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"], val => \$isdn->{speed} },
{ label => N("Connection timeout (in sec)"), val => \$isdn->{huptimeout} },
@@ -366,42 +295,33 @@ sub real_main {
},
post => sub {
network::isdn::write_config($isdn);
- $netc->{$_} = 'ippp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $handle_multiple_cnx->();
+ $net->{net_interface} = 'ippp0';
+ "allow_user_ctl";
},
},
cable =>
{
pre => sub {
- $cable_no_auth = sub { $netc->{bpalogin} eq N("None") };
+ $cable_no_auth = sub { $net->{cable}{bpalogin} eq N("None") };
},
name => N("Cable: account options"),
data => sub {
[
- { label => N("Authentication"), type => "list", val => \$netc->{bpalogin}, list => [ N("None"), N("Use BPALogin (needed for Telstra)") ] },
- { label => N("Account Login (user name)"), val => \$netcnx->{login}, disabled => $cable_no_auth },
- { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1, disabled => $cable_no_auth },
+ { label => N("Authentication"), type => "list", val => \$net->{cable}{bpalogin}, list => [ N("None"), N("Use BPALogin (needed for Telstra)") ] },
+ { label => N("Account Login (user name)"), val => \$net->{cable}{login}, disabled => $cable_no_auth },
+ { label => N("Account Password"), val => \$net->{cable}{passwd}, hidden => 1, disabled => $cable_no_auth },
];
},
post => sub {
- if ($cable_no_auth->()) {
- if (-f "$::prefix/etc/rc.d/init.d/bpalogin") {
- require services;
- services::stop("bpalogin");
- services::do_not_start_service_on_boot("bpalogin");
- }
- } else {
- if ($in->do_pkgs->install("bpalogin")) {
- substInFile {
- s/username\s+.*\n/username $netcnx->{login}\n/;
- s/password\s+.*\n/password $netcnx->{passwd}\n/;
- } "$::prefix/etc/bpalogin.conf";
- require services;
- services::start_service_on_boot("bpalogin");
- services::restart("bpalogin");
- }
- }
+ my $use_bpalogin = !$cable_no_auth->();
+ if ($in->do_pkgs->install("bpalogin")) {
+ substInFile {
+ s/username\s+.*\n/username $net->{cable}{login}\n/;
+ s/password\s+.*\n/password $net->{cable}{passwd}\n/;
+ } "$::prefix/etc/bpalogin.conf";
+ }
+ services::set_status("bpalogin", $use_bpalogin);
$auto_ip = 1;
return "lan";
}
@@ -410,8 +330,8 @@ sub real_main {
isdn =>
{
pre=> sub {
- detect($modules_conf, $netc->{autodetect}, 'isdn');
- %isdn_cards = map { $_->{description} => $_ } @{$netc->{autodetect}{isdn}};
+ detect($modules_conf, $net->{autodetect}, 'isdn');
+ %isdn_cards = map { $_->{description} => $_ } @{$net->{autodetect}{isdn}};
},
name => N("Select the network interface to configure:"),
data => sub {
@@ -419,18 +339,15 @@ sub real_main {
list => [ $my_isdn, N("External ISDN modem"), keys %isdn_cards ] } ];
},
post => sub {
- # !intern_pci:
- # data => [ { val => \$isdn_type, type => "list", list => [ , ], } ],
- # post => sub {
if ($isdn_name eq $my_isdn) {
return "isdn_ask";
} elsif ($isdn_name eq N("External ISDN modem")) {
- $netcnx->{type} = 'isdn_external';
+ $net->{type} = 'isdn_external';
return "modem";
}
# FIXME: some of these should be taken from isdn db
- $netcnx->{isdn_internal} = $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) };
+ $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) };
if ($isdn->{id}) {
log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
@@ -489,7 +406,7 @@ If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
},
post => sub {
- $netcnx->{isdn_internal} = $isdn = $isdn_cards{$isdn_name};
+ $isdn = $isdn_cards{$isdn_name};
return "isdn_protocol";
}
},
@@ -549,9 +466,9 @@ Take a look at http://www.linmodems.org"),
{
pre => sub {
require network::modem;
- detect($modules_conf, $netc->{autodetect}, 'modem');
+ detect($modules_conf, $net->{autodetect}, 'modem');
$modem = {};
- if ($netcnx->{type} eq 'isdn_external') {
+ if ($net->{type} eq 'isdn_external') {
#- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i
#- it does not even work with TA 128 modems
#- http://bugs.mandrakelinux.com/query.php?bug=1033
@@ -561,17 +478,17 @@ Take a look at http://www.linmodems.org"),
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") ], } ];
+ list => [ keys %{$net->{autodetect}{modem}}, N("Manual choice") ], } ];
},
complete => sub {
- my $driver = $netc->{autodetect}{modem}{$modem_name}{driver} or return 0;
+ my $driver = $net->{autodetect}{modem}{$modem_name}{driver} or return 0;
!network::thirdparty::setup_device($in, 'rtc', $driver, $modem, qw(device));
},
post => sub {
return 'choose_serial_port' if $modem_name eq N("Manual choice");
- if (exists $netc->{autodetect}{modem}{$modem_name}{device}) {
+ if (exists $net->{autodetect}{modem}{$modem_name}{device}) {
#- this is a serial probed modem
- $modem->{device} = $netc->{autodetect}{modem}{$modem_name}{device};
+ $modem->{device} = $net->{autodetect}{modem}{$modem_name}{device};
return "ppp_provider";
} else {
#- driver exists but device field hasn't been filled by network::thirdparty::setup_device
@@ -590,7 +507,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', '/dev/ttyS14',) ] } ];
+ list => [ grep { $_ ne $mouse->{device} } (mouse::serial_ports(), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ];
},
post => sub {
return 'ppp_provider';
@@ -601,8 +518,7 @@ Take a look at http://www.linmodems.org"),
ppp_provider =>
{
pre => sub {
- network::modem::ppp_read_conf($netcnx, $netc) if !$modem_conf_read;
- $modem_conf_read = 1;
+ add2hash($modem, network::modem::ppp_read_conf());
$in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path);
my $p_db_path = "$::prefix$db_path";
@isp = map {
@@ -703,8 +619,8 @@ Take a look at http://www.linmodems.org"),
},
post => sub {
network::modem::ppp_configure($in, $modem);
- $netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
- $handle_multiple_cnx->();
+ $net->{net_interface} = 'ppp0';
+ "allow_user_ctl";
},
},
@@ -712,22 +628,21 @@ Take a look at http://www.linmodems.org"),
adsl =>
{
pre => sub {
- get_subwizard($wiz, 'adsl');
$lan_detect->();
@adsl_devices = keys %eth_intf;
- detect($modules_conf, $netc->{autodetect}, 'adsl');
+ detect($modules_conf, $net->{autodetect}, 'adsl');
%adsl_cards = ();
- foreach my $modem_type (keys %{$netc->{autodetect}{adsl}}) {
- foreach my $modem (@{$netc->{autodetect}{adsl}{$modem_type}}) {
+ foreach my $modem_type (keys %{$net->{autodetect}{adsl}}) {
+ foreach my $modem (@{$net->{autodetect}{adsl}{$modem_type}}) {
my $name = join(': ', $adsl_descriptions{$modem_type}, $modem->{description});
$adsl_cards{$name} = [ $modem_type, $modem ];
}
}
push @adsl_devices, keys %adsl_cards;
- detect($modules_conf, $netc->{autodetect}, 'isdn');
- if (my @isdn_modems = @{$netc->{autodetect}{isdn}}) {
+ detect($modules_conf, $net->{autodetect}, 'isdn');
+ if (my @isdn_modems = @{$net->{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;
@@ -743,12 +658,12 @@ Take a look at http://www.linmodems.org"),
if (exists $adsl_cards{$ntf_name}) {
my $modem;
($ntf_name, $modem) = @{$adsl_cards{$ntf_name}};
- $netcnx->{bus} = $modem->{bus} if $ntf_name eq 'bewan';
+ $net->{adsl}{bus} = $modem->{bus} if $ntf_name eq 'bewan';
}
if (exists($isdn_cards{$ntf_name})) {
require network::isdn;
- $netcnx->{capi} = $isdn_cards{$ntf_name};
- $adsl_type = "capi";
+ $net->{adsl}{capi_card} = $isdn_cards{$ntf_name};
+ $net->{adsl}{method} = "capi";
return 'adsl_account';
}
return 'adsl_provider';
@@ -769,12 +684,12 @@ Take a look at http://www.linmodems.org"),
list => [ sort(N("Unlisted - edit manually"), keys %adsl_data) ], sort => 0 } ];
},
post => sub {
- $adsl_type = 'pppoa' if member($ntf_name, qw(bewan speedtouch));
+ $net->{adsl}{method} = 'pppoa' if member($ntf_name, qw(bewan speedtouch));
if ($adsl_provider ne N("Unlisted - edit manually")) {
$adsl_data = $adsl_data{$adsl_provider};
if ($adsl_provider ne $adsl_old_provider) {
- $netc->{$_} = $adsl_data->{$_} foreach qw(DOMAINNAME2 Encapsulation vpi vci provider_id);
- $adsl_type = $adsl_data->{method};
+ $net->{adsl}{$_} = $adsl_data->{$_} foreach qw(Encapsulation vpi vci provider_id method);
+ $net->{resolv}{$_} = $adsl_data->{$_} foreach qw(DOMAINNAME2);
}
}
return 'adsl_protocol';
@@ -787,12 +702,10 @@ Take a look at http://www.linmodems.org"),
pre => sub {
# preselect right protocol for ethernet though connections:
if (!exists $adsl_descriptions{$ntf_name}) {
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
- $adsl_type ||= $ethntf->{BOOTPROTO} || "dhcp";
- #- FIXME: use static instead of manual as key in %adsl_types
- $adsl_type = "manual" if $adsl_type eq "static";
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
+ $net->{adsl}{method} ||= $ethntf->{BOOTPROTO} || "dhcp";
#- pppoa shouldn't be selected by default for ethernet devices, fallback on pppoe
- $adsl_type = "pppoe" if $adsl_type eq "pppoa";
+ $net->{adsl}{method} = "pppoe" if $net->{adsl}{method} eq "pppoa";
}
},
name => N("Connect to the Internet") . "\n\n" .
@@ -800,38 +713,38 @@ Take a look at http://www.linmodems.org"),
Some connections use PPTP, a few use DHCP.
If you do not know, choose 'use PPPoE'"),
data => [
- { text => N("ADSL connection type:"), val => \$adsl_type, type => "list",
+ { text => N("ADSL connection type:"), val => \$net->{adsl}{method}, type => "list",
list => [ sort { $adsl_types{$a} cmp $adsl_types{$b} } keys %adsl_types ],
format => sub { $adsl_types{$_[0]} },
},
],
post => sub {
my $real_interface = $ntf_name;
- $netcnx->{type} = 'adsl';
+ $net->{type} = 'adsl';
# blacklist bogus driver, enable ifplugd support else:
$find_lan_module->();
$ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->();
- if ($ntf_name eq "sagem" && member($adsl_type, qw(manual dhcp))) {
+ if ($ntf_name eq "sagem" && member($net->{adsl}{method}, qw(static 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 = $net->{ifcfg}{sagem} ||= {};
$ethntf->{DEVICE} = "`/usr/sbin/fctStartAdsl -i`";
$ethntf->{MII_NOT_SUPPORTED} = "yes";
}
- if ($ntf_name eq "speedtouch" && member($adsl_type, qw(manual dhcp))) {
+ if ($ntf_name eq "speedtouch" && member($net->{adsl}{method}, qw(static dhcp))) {
#- use ATMARP with the atm0 interface
$real_interface = "atm0";
- $ethntf = $intf->{$real_interface} ||= {};
+ $ethntf = $net->{ifcfg}{$real_interface} ||= {};
$ethntf->{DEVICE} = $real_interface;
$ethntf->{ATM_ADDR} = undef;
$ethntf->{MII_NOT_SUPPORTED} = "yes";
}
#- delete gateway settings if gateway device is invalid or if reconfiguring the gateway interface
- exists $intf->{$real_interface} and $delete_gateway_settings->($real_interface);
+ exists $net->{ifcfg}{$real_interface} and $delete_gateway_settings->($real_interface);
# process static/dhcp ethernet devices:
- if (exists($intf->{$real_interface}) && member($adsl_type, qw(manual dhcp))) {
+ if (exists($net->{ifcfg}{$real_interface}) && member($net->{adsl}{method}, qw(static dhcp))) {
$ethntf->{TYPE} = "ADSL";
- $auto_ip = $adsl_type eq 'dhcp';
+ $auto_ip = $net->{adsl}{method} eq 'dhcp';
return 'lan_intf';
}
return 'adsl_account';
@@ -842,26 +755,26 @@ If you do not 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';
- ($adsl_vpi, $adsl_vci) = map { hex($_) } @$netc{'vpi', 'vci'};
+ network::adsl::adsl_probe_info($net);
+ member($net->{adsl}{method}, qw(pppoe pptp)) and $net->{adsl}{ethernet_device} = $ntf_name;
+ $net->{net_interface} = 'ppp0';
+ ($adsl_vpi, $adsl_vci) = (hex($net->{adsl}{vpi}), hex($net->{adsl}{vci}));
},
name => N("Connection Configuration") . "\n\n" .
N("Please fill or check the field below"),
data => sub {
[
- if_(0, { label => N("Provider name (ex provider.net)"), val => \$netc->{DOMAINNAME2} }),
- { label => N("First DNS Server (optional)"), val => \$netc->{dnsServer2} },
- { label => N("Second DNS Server (optional)"), val => \$netc->{dnsServer3} },
- { label => N("Account Login (user name)"), val => \$netcnx->{login} },
- { label => N("Account Password"), val => \$netcnx->{passwd}, hidden => 1 },
- if_($adsl_type ne "capi",
+ if_(0, { label => N("Provider name (ex provider.net)"), val => \$net->{resolv}{DOMAINNAME2} }),
+ { label => N("First DNS Server (optional)"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("Second DNS Server (optional)"), val => \$net->{resolv}{dnsServer3} },
+ { label => N("Account Login (user name)"), val => \$net->{adsl}{login} },
+ { label => N("Account Password"), val => \$net->{adsl}{passwd}, hidden => 1 },
+ if_($net->{adsl}{method} ne "capi",
{ label => N("Virtual Path ID (VPI):"), val => \$adsl_vpi, advanced => 1 },
{ label => N("Virtual Circuit ID (VCI):"), val => \$adsl_vci, advanced => 1 }
),
if_($ntf_name eq "sagem",
- { label => N("Encapsulation:"), val => \$netc->{Encapsulation}, list => [ keys %encapsulations ],
+ { label => N("Encapsulation:"), val => \$net->{adsl}{Encapsulation}, list => [ keys %encapsulations ],
format => sub { $encapsulations{$_[0]} }, advanced => 1,
},
),
@@ -871,25 +784,18 @@ If you do not know, choose 'use PPPoE'"),
#- update ATM_ADDR for ATMARP connections
exists $ethntf->{ATM_ADDR} and $ethntf->{ATM_ADDR} = join('.', $adsl_vpi, $adsl_vci);
#- convert VPI/VCI back to hex
- @$netc{'vpi', 'vci'} = map { sprintf("%x", $_) } ($adsl_vpi, $adsl_vci);
+ ($net->{adsl}{vpi}, $net->{adsl}{vci}) = map { sprintf("%x", $_) } ($adsl_vpi, $adsl_vci);
- $netc->{internet_cnx_choice} = 'adsl';
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $ntf_name, $adsl_type, $netcnx); #FIXME
- $config->{adsl} = { kind => $ntf_name, protocol => $adsl_type };
- $handle_multiple_cnx->();
+ $net->{adsl}{device} =
+ $net->{adsl}{method} eq 'pptp' ? 'pptp_modem' :
+ $net->{adsl}{method} eq 'capi' ? 'capi_modem' :
+ $ntf_name;
+ network::adsl::adsl_conf_backend($in, $modules_conf, $net);
+ "allow_user_ctl";
},
},
- adsl_unsupported_eci =>
- {
- name => N("The ECI Hi-Focus modem cannot be supported due to binary driver distribution problem.
-
-You can find a driver on http://eciadsl.flashtux.org/"),
- end => 1,
- },
-
-
lan =>
{
pre => $lan_detect,
@@ -921,7 +827,7 @@ You can find a driver on http://eciadsl.flashtux.org/"),
} elsif ($ntf_name eq "Use a Windows driver (with ndiswrapper)") {
return $ndiswrapper_next_step->();
}
- $ethntf = $intf->{$ntf_name} ||= { DEVICE => $ntf_name };
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= { DEVICE => $ntf_name };
return $after_lan_intf_selection->();
},
},
@@ -951,8 +857,6 @@ You can find a driver on http://eciadsl.flashtux.org/"),
},
- # FIXME: is_install: no return for each card "last step" because of manual popping
- # better construct an hash of { current_netintf => next_step } which next_step = last_card ? next_eth_step : next_card ?
lan_intf =>
{
pre => sub {
@@ -966,7 +870,7 @@ You can find a driver on http://eciadsl.flashtux.org/"),
$ethntf->{MII_NOT_SUPPORTED} ||= $is_hotplug_blacklisted->();
$hotplug = !text2bool($ethntf->{MII_NOT_SUPPORTED});
$track_network_id = $::isStandalone && $ethntf->{HWADDR} || detect_devices::isLaptop();
- delete $ethntf->{TYPE} if $netcnx->{type} ne 'adsl' || !member($adsl_type, qw(manual dhcp));
+ delete $ethntf->{TYPE} if $net->{type} ne 'adsl' || !member($net->{adsl}{method}, qw(static dhcp));
$ethntf->{DHCP_CLIENT} ||= (find { -x "$::prefix/sbin/$_" } qw(dhclient dhcpcd pump dhcpxd));
},
name => sub { join('',
@@ -989,7 +893,7 @@ notation (for example, 1.2.3.4).")),
{ text => N("Track network card id (useful for laptops)"), val => \$track_network_id, type => "bool" },
if_(!$is_wireless,
{ text => N("Network Hotplugging"), val => \$hotplug, type => "bool" }),
- if_($netcnx->{type} eq "lan",
+ if_($net->{type} eq "lan",
{ text => N("Start at boot"), val => \$onboot, type => "bool" },
),
{ label => N("Metric"), val => \$ethntf->{METRIC}, advanced => 1 },
@@ -1005,7 +909,6 @@ notation (for example, 1.2.3.4).")),
},
complete => sub {
$ethntf->{BOOTPROTO} = $auto_ip ? "dhcp" : "static";
- $netc->{DHCP} = $auto_ip;
return 0 if $auto_ip;
if (!is_ip($ethntf->{IPADDR})) {
$in->ask_warn(N("Error"), N("IP address should be in format 1.2.3.4"));
@@ -1020,7 +923,7 @@ notation (for example, 1.2.3.4).")),
return 1, 0;
}
#- 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) {
+ if ($ntf_name ne "sagem" && find { $_->{DEVICE} ne $ethntf->{DEVICE} && $_->{IPADDR} eq $ethntf->{IPADDR} } values %{$net->{ifcfg}}) {
$in->ask_warn(N("Error"), N("%s already in use\n", $ethntf->{IPADDR}));
return 1, 0;
}
@@ -1038,7 +941,7 @@ notation (for example, 1.2.3.4).")),
$ethntf->{HWADDR} = $track_network_id or delete $ethntf->{HWADDR};
#- FIXME: special case for sagem where $ethntf->{DEVICE} is the result of a command
#- we can't always use $ntf_name because of some USB DSL modems
- $netc->{$_} = $ntf_name eq "sagem" ? "sagem" : $ethntf->{DEVICE} foreach qw(NET_DEVICE NET_INTERFACE);
+ $net->{net_interface} = $ntf_name eq "sagem" ? "sagem" : $ethntf->{DEVICE};
if ($auto_ip) {
#- delete gateway settings if gateway device is invalid or if reconfiguring the gateway interface to dhcp
$delete_gateway_settings->($ntf_name);
@@ -1082,8 +985,6 @@ notation (for example, 1.2.3.4).")),
{
pre => sub {
require network::wireless;
- $ethntf->{wireless_eth} = 1;
- $netc->{wireless_eth} = 1;
$ethntf->{WIRELESS_MODE} ||= "Managed";
$ethntf->{WIRELESS_ESSID} ||= "any";
($wireless_enc_key, my $restricted) = network::wireless::get_wep_key_from_iwconfig($ethntf->{WIRELESS_ENC_KEY});
@@ -1207,7 +1108,7 @@ set TxRate=0);
dvb_adapter =>
{
pre => sub {
- my $previous_ethntf = find { $is_dvb_interface->($_) } values %$intf;
+ my $previous_ethntf = find { $is_dvb_interface->($_) } values %{$net->{ifcfg}};
$dvb_ad = $previous_ethntf->{DVB_ADAPTER_ID};
$dvb_net = $previous_ethntf->{DVB_NETWORK_DEMUX};
$dvb_pid = $previous_ethntf->{DVB_NETWORK_PID};
@@ -1225,7 +1126,7 @@ set TxRate=0);
},
post => sub {
$ntf_name = 'dvb' . $dvb_ad . '_' . $dvb_net;
- $ethntf = $intf->{$ntf_name} ||= {};
+ $ethntf = $net->{ifcfg}{$ntf_name} ||= {};
$ethntf->{DEVICE} = $ntf_name;
$ethntf->{DVB_ADAPTER_ID} = qq("$dvb_ad");
$ethntf->{DVB_NETWORK_DEMUX} = qq("$dvb_net");
@@ -1238,13 +1139,13 @@ set TxRate=0);
{
pre => sub {
if ($ethntf->{IPADDR}) {
- $netc->{dnsServer} ||= dns($ethntf->{IPADDR});
+ $net->{resolv}{dnsServer} ||= dns($ethntf->{IPADDR});
$gateway_ex = gateway($ethntf->{IPADDR});
- # $netc->{GATEWAY} ||= gateway($ethntf->{IPADDR});
+ # $net->{network}{GATEWAY} ||= gateway($ethntf->{IPADDR});
if ($ntf_name eq "sagem") {
my @sagem_ip = split(/\./, $ethntf->{IPADDR});
$sagem_ip[3] = 254;
- $netc->{GATEWAY} = join(".", @sagem_ip);
+ $net->{network}{GATEWAY} = join(".", @sagem_ip);
}
}
},
@@ -1255,16 +1156,16 @@ You may also enter the IP address of the gateway if you have one.") .
" " . # better looking text (to be merged into texts since some languages (eg: ja) doesn't need it
N("Last but not least you can also type in your DNS server IP addresses."),
data => sub {
- [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$netc->{HOSTNAME} },
+ [ { label => $auto_ip ? N("Host name (optional)") : N("Host name"), val => \$net->{network}{HOSTNAME} },
if_(!$auto_ip,
- { label => N("DNS server 1"), val => \$netc->{dnsServer} },
- { label => N("DNS server 2"), val => \$netc->{dnsServer2} },
- { label => N("DNS server 3"), val => \$netc->{dnsServer3} },
- { label => N("Search domain"), val => \$netc->{DOMAINNAME},
+ { label => N("DNS server 1"), val => \$net->{resolv}{dnsServer} },
+ { label => N("DNS server 2"), val => \$net->{resolv}{dnsServer2} },
+ { label => N("DNS server 3"), val => \$net->{resolv}{dnsServer3} },
+ { label => N("Search domain"), val => \$net->{resolv}{DOMAINNAME},
help => N("By default search domain will be set from the fully-qualified host name") },
- { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$netc->{GATEWAY} },
+ { label => N("Gateway (e.g. %s)", $gateway_ex), val => \$net->{network}{GATEWAY} },
if_(@all_cards > 1,
- { label => N("Gateway device"), val => \$netc->{GATEWAYDEV}, list => [ N_("None"), sort keys %all_eth_intf ],
+ { label => N("Gateway device"), val => \$net->{network}{GATEWAYDEV}, list => [ N_("None"), sort keys %all_eth_intf ],
format => sub { $all_eth_intf{$_[0]} || translate($_[0]) } },
),
),
@@ -1272,18 +1173,18 @@ N("Last but not least you can also type in your DNS server IP addresses."),
},
complete => sub {
foreach my $dns (qw(dnsServer dnsServer2 dnsServer3)) {
- if ($netc->{$dns} && !is_ip($netc->{$dns})) {
+ if ($net->{resolv}{$dns} && !is_ip($net->{resolv}{$dns})) {
$in->ask_warn(N("Error"), N("DNS server address should be in format 1.2.3.4"));
return 1;
}
}
- if ($netc->{GATEWAY} && !is_ip($netc->{GATEWAY})) {
+ if ($net->{network}{GATEWAY} && !is_ip($net->{network}{GATEWAY})) {
$in->ask_warn(N("Error"), N("Gateway address should be in format 1.2.3.4"));
return 1;
}
},
post => sub {
- $netc->{GATEWAYDEV} eq "None" and delete $netc->{GATEWAYDEV};
+ $net->{network}{GATEWAYDEV} eq "None" and delete $net->{network}{GATEWAYDEV};
return "zeroconf";
}
},
@@ -1295,32 +1196,14 @@ N("Last but not least you can also type in your DNS server IP addresses."),
This is the name your machine will use to advertise any of
its shared resources that are not managed by the network.
It is not necessary on most networks."),
- data => [ { label => N("Zeroconf Host name"), val => \$netc->{ZEROCONF_HOSTNAME} } ],
+ data => [ { label => N("Zeroconf Host name"), val => \$net->{zeroconf}{hostname} } ],
complete => sub {
- if ($netc->{ZEROCONF_HOSTNAME} =~ /\./) {
+ if ($net->{zeroconf}{hostname} =~ /\./) {
$in->ask_warn(N("Error"), N("Zeroconf host name must not contain a ."));
return 1;
}
},
- post => $handle_multiple_cnx,
- },
-
-
- multiple_internet_cnx =>
- {
- name => N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n") . if_(!$::isStandalone, "You may want to configure some profiles after the installation, in the Mandriva Control Center"),
- data => sub {
- [ { label => N("Internet connection"), val => \$netc->{internet_cnx_choice},
- list => [ keys %{$netc->{internet_cnx}} ] } ];
- },
- post => $save_cnx,
- },
-
-
- apply_settings =>
- {
- name => N("Configuration is complete, do you want to apply settings?"),
- type => "yesorno",
+ next => "allow_user_ctl",
},
@@ -1328,13 +1211,10 @@ It is not necessary on most networks."),
{
name => N("Do you want to allow users to start the connection?"),
type => "yesorno",
- default => sub { bool2yesno(text2bool($intf->{$netc->{NET_INTERFACE}}{USERCTL})) },
+ default => sub { bool2yesno(text2bool($net->{ifcfg}{$net->{net_interface}}{USERCTL})) },
post => sub {
my ($res) = @_;
- $res = bool2yesno($res);
- $intf->{$netc->{NET_INTERFACE}}{USERCTL} = $res;
- my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
- -f $ifcfg_file and substInFile { s/^USERCTL.*\n//; $_ .= qq(USERCTL=$res\n) if eof } $ifcfg_file;
+ $net->{ifcfg}{$net->{net_interface}}{USERCTL} = bool2yesno($res);
return $goto_start_on_boot_ifneeded->();
},
},
@@ -1342,20 +1222,12 @@ It is not necessary on most networks."),
network_on_boot =>
{
- pre => sub {
- # condition is :
- member($netc->{internet_cnx_choice}, ('adsl', 'isdn')); # and $netc->{at_boot} = $in->ask_yesorno(N("Network Configuration Wizard"), N("Do you want to start the connection at boot?"));
- },
name => N("Do you want to start the connection at boot?"),
type => "yesorno",
- default => sub { ($type eq 'modem' ? 'no' : 'yes') },
+ default => sub { ($net->{type} eq 'modem' ? 'no' : 'yes') },
post => sub {
my ($res) = @_;
- $netc->{at_boot} = $res;
- $res = bool2yesno($res);
- $ethntf->{ONBOOT} = $res if $netcnx->{type} eq 'adsl' && member($adsl_type, qw(manual dhcp));
- my $ifcfg_file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$netc->{NET_INTERFACE}";
- -f $ifcfg_file and substInFile { s/^ONBOOT.*\n//; $_ .= qq(ONBOOT=$res\n) if eof } $ifcfg_file;
+ $net->{ifcfg}{$net->{net_interface}} = bool2yesno($res);
return $after_start_on_boot_step->();
},
},
@@ -1364,7 +1236,7 @@ It is not necessary on most networks."),
isdn_dial_on_boot =>
{
pre => sub {
- $intf->{ippp0} ||= { DEVICE => "ippp0" }; # we want the ifcfg-ippp0 file to be written
+ $net->{ifcfg}{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"),
@@ -1372,8 +1244,8 @@ It is not necessary on most networks."),
{ 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});
+ $_->{ONBOOT} eq text2bool($net->{ifcfg}{ippp0}{ONBOOT}) &&
+ $_->{DIAL_ON_IFUP} eq text2bool($net->{ifcfg}{ippp0}{DIAL_ON_IFUP});
} @isdn_dial_methods;
#- use net_applet by default
$isdn->{dial_method} = $method->{name} || $isdn_dial_methods[1]{name};
@@ -1384,49 +1256,31 @@ It is not necessary on most networks."),
},
post => sub {
my $method = find { $_->{name} eq $isdn->{dial_method} } @isdn_dial_methods;
- $intf->{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
+ $net->{ifcfg}{ippp0}{$_} = bool2yesno($method->{$_}) foreach qw(ONBOOT DIAL_ON_IFUP);
return $after_start_on_boot_step->();
},
},
-
- restart =>
- {
- name => N("The network needs to be restarted. Do you want to restart it?"),
- type => "yesorno",
- post => sub {
- my ($a) = @_;
- network::ethernet::write_ether_conf($in, $modules_conf, $netcnx, $netc, $intf) if $netcnx->{type} eq 'lan';
- if ($a && !$::testing && !run_program::rooted($::prefix, "/etc/rc.d/init.d/network restart")) {
- $success = 0;
- $in->ask_okcancel(N("Network Configuration"),
- N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), 0);
- }
- return $offer_to_connect->();
- },
- },
-
-
ask_connect_now =>
{
name => N("Do you want to try to connect to the Internet now?"),
type => "yesorno",
post => sub {
my ($a) = @_;
- my $type = $netc->{internet_cnx_choice};
+ my $type = $net->{type};
$up = 1;
if ($a) {
# local $::isWizard = 0;
my $_w = $in->wait_message('', N("Testing your connection..."), 1);
- disconnect_backend($netc);
+ network::tools::disconnect_backend($net);
sleep 1;
- connect_backend($netc);
+ network::tools::connect_backend($net);
my $s = 30;
$type =~ /modem/ and $s = 50;
$type =~ /adsl/ and $s = 35;
$type =~ /isdn/ and $s = 20;
sleep $s;
- $up = connected();
+ $up = network::tools::connected();
}
$success = $up;
return $a ? "disconnect" : "end";
@@ -1445,7 +1299,7 @@ Try to reconfigure your connection.");
no_back => 1,
end => 1,
post => sub {
- $::isInstall and disconnect_backend($netc);
+ $::isInstall and network::tools::disconnect_backend($net);
return "end";
},
},
@@ -1466,42 +1320,31 @@ Test your connection via net_monitor or mcc. If your connection does not work, y
},
};
- my $use_wizard = 1;
- if ($::isInstall) {
- if ($first_time && $in->{method} =~ /^(ftp|http|nfs)$/) {
- local $::isWizard;
- !$::expert && !$o_noauto || $in->ask_okcancel(N("Network Configuration"),
- N("Because you are doing a network installation, your network is already configured.
+ #- keeping the translations in case someone want to restore these texts
+ if_(0,
+ # keep b/c of translations in case they can be reused somewhere else:
+ N("(detected on port %s)", 'toto'),
+ #-PO: here, "(detected)" string will be appended to eg "ADSL connection"
+ N("(detected %s)", 'toto'), N("(detected)"),
+ N("Network Configuration"),
+ N("Because you are doing a network installation, your network is already configured.
Click on Ok to keep your configuration, or cancel to reconfigure your Internet & Network connection.
-"), 1)
- and do {
- $netcnx->{type} = 'lan';
- $netc->{$_} = 'eth0' foreach qw(NET_DEVICE NET_INTERFACE);
- $use_wizard = 0;
- };
- }
- }
-
- if ($use_wizard) {
- require wizards;
- $wiz->{var} = {
- netc => $netc,
- mouse => $mouse,
- intf => $intf,
- };
- wizards->new->process($wiz, $in);
- }
-
- # install needed packages:
- $network_configured or network::network::configureNetwork2($in, $modules_conf, $::prefix, $netc, $intf);
-
- $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
- $netcnx->{type} =~ /adsl/ or run_program::rooted($::prefix, "/chkconfig --del adsl 2> /dev/null");
+"),
+ N("The network needs to be restarted. Do you want to restart it?"),
+ N("A problem occurred while restarting the network: \n\n%s", `/etc/rc.d/init.d/network restart`), #- nice one ...
+ N("We are now going to configure the %s connection.\n\n\nPress \"%s\" to continue.", 'a', 'b'),
+ N("Configuration is complete, do you want to apply settings?"),
+ N("You have configured multiple ways to connect to the Internet.\nChoose the one you want to use.\n\n"),
+ N("Internet connection"),
+ );
+
+ require wizards;
+ wizards->new->process($wiz, $in);
}
-sub main {
- my ($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) };
+sub safe_main {
+ my ($net, $in, $modules_conf) = @_;
+ eval { real_main($net, $in, $modules_conf) };
my $err = $@;
if ($err) { # && $in->isa('interactive::gtk')
$err =~ /wizcancel/ and $in->exit(0);
@@ -1513,23 +1356,17 @@ sub main {
}
}
-sub read_net_conf {
- my ($netcnx, $netc, $intf) = @_;
- network::network::read_all_conf($::prefix, $netc, $intf, $netcnx);
-}
-
sub start_internet {
my ($o) = @_;
- init_globals($o);
#- give a chance for module to be loaded using kernel-BOOT modules...
+ #- FIXME, this has nothing to do there
$::isStandalone or modules::load_category($o->{modules_conf}, 'network/*');
- connect_backend($o->{netc});
+ network::tools::connect_backend($o->{net});
}
sub stop_internet {
my ($o) = @_;
- init_globals($o);
- disconnect_backend($o->{netc});
+ network::tools::disconnect_backend($o->{net});
}
1;
@@ -1540,14 +1377,11 @@ sub stop_internet {
use lib qw(/usr/lib/libDrakX);
use network::netconnect;
+use modules;
use Data::Dumper;
-use class_discard;
-
-local $in = class_discard->new;
-
-network::netconnect::init_globals($in);
my %i;
+my $modules_conf = modules::any_conf->read;
network::netconnect::detect($modules_conf, \%i);
print Dumper(\%i),"\n";
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 2bccad7df..ab0130d37 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -15,12 +15,45 @@ use any;
use vars qw(@ISA @EXPORT);
use log;
+my $network_file = "$::prefix/etc/sysconfig/network";
+my $resolv_file = "$::prefix/etc/resolv.conf";
+my $tmdns_file = "$::prefix/etc/tmdns.conf";
+
+
@ISA = qw(Exporter);
-@EXPORT = qw(add2hosts addDefaultRoute configureNetwork2 dns dnsServers findIntf gateway guessHostname is_ip is_ip_forbidden masked_ip netmask read_all_conf read_conf read_interface_conf read_resolv_conf resolv sethostname write_conf write_resolv_conf);
+@EXPORT = qw(addDefaultRoute dns dnsServers gateway guessHostname is_ip is_ip_forbidden masked_ip netmask resolv sethostname);
+
+#- $net hash structure
+#- autodetect
+#- type
+#- net_interface
+#- PROFILE: selected netprofile
+#- network (/etc/sysconfig/network) : GATEWAY GATEWAYDEV HOSTNAME NETWORKING NISDOMAIN
+#- NETWORKING : networking flag : string : "yes" by default
+#- FORWARD_IPV4 : forward IP flag : string : "false" by default
+#- HOSTNAME : hostname : string : "localhost.localdomain" by default
+#- GATEWAY : gateway
+#- GATEWAYDEV : gateway interface
+#- NISDOMAIN : nis domain
+#- resolv (/etc/resolv.conf): dnsServer, dnsServer2, dnsServer3, DOMAINNAME, DOMAINNAME2, DOMAINNAME3
+#- dnsServer : dns server 1
+#- dnsServer2 : dns server 2
+#- dnsServer3 : dns server 3 : note that we uses the dns1 for the LAN, and the 2 others for the internet conx
+#- DOMAINNAME : domainname : string : $netc->{HOSTNAME} =~ /\.(.*)/ by default
+#- DOMAINNAME2 : well it's another domainname : have to look further why we used 2
+#- adsl: bus, Encapsulation, vpi, vci provider_id, method, login, passwd, ethernet_device, capi_card
+#- cable: bpalogin, login, passwd
+#- zeroconf: hostname
+#- auth: LDAPDOMAIN WINDOMAIN
+#- ifcfg (/etc/sysconfig/network-scripts/ifcfg-*):
+#- key : device name
+#- value : hash containing ifcfg file values
+#- DHCP_HOSTNAME : If you have a dhcp and want to set the hostname
+#- IPADDR : IP address
+#- NETMASK : netmask
+#- DEVICE : device name
+#- BOOTPROTO : boot prototype : "bootp" or "dhcp" or "pump" or ...
-#-######################################################################################
-#- Functions
-#-######################################################################################
sub read_conf {
my ($file) = @_;
+{ getVarsFromSh($file) };
@@ -52,38 +85,48 @@ sub read_interface_conf {
\%intf;
}
-sub read_tmdns_conf() {
- my $file = "$::prefix/etc/tmdns.conf";
- cat_($file) =~ /^\s*hostname\s*=\s*(\w+)/m && { ZEROCONF_HOSTNAME => $1 };
+sub read_zeroconf() {
+ cat_($tmdns_file) =~ /^\s*hostname\s*=\s*(\w+)/m && { ZEROCONF_HOSTNAME => $1 };
}
-sub write_conf {
- my ($netc) = @_;
- my $file = "$::prefix/etc/sysconfig/network";
+sub write_network_conf {
+ my ($net) = @_;
- if ($netc->{HOSTNAME} && $netc->{HOSTNAME} =~ /\.(.+)$/) {
- $netc->{DOMAINNAME} = $1;
+ if ($net->{network}{HOSTNAME} && $net->{network}{HOSTNAME} =~ /\.(.+)$/) {
+ $net->{resolv}{DOMAINNAME} = $1;
}
- $netc->{NETWORKING} = 'yes';
+ $net->{network}{NETWORKING} = 'yes';
- setVarsInSh($file, $netc, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN));
+ setVarsInSh($network_file, $net->{network}, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN));
}
sub write_zeroconf {
- my ($file, $zhostname) = @_;
- eval { substInFile { s/^\s*(hostname)\s*=.*/$1 = $zhostname/ } $file };
+ my ($net, $in) = @_;
+ my $zhostname = $net->{zeroconf}{hostname};
+
+ if ($zhostname) {
+ $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 blank hostname even if disabled so that drakconnect does not assume zeroconf is enabled
+ eval { substInFile { s/^\s*(hostname)\s*=.*/$1 = $zhostname/ } $tmdns_file } if $zhostname || -f $tmdns_file;
+
+ require services;
+ services::set_status('tmdns', $net->{zeroconf}{hostname});
}
sub write_resolv_conf {
- my ($file, $netc) = @_;
+ my ($net) = @_;
+ my $resolv = $net->{resolv};
my %new = (
- search => [ grep { $_ } uniq(@$netc{'DOMAINNAME', 'DOMAINNAME2', 'DOMAINNAME3'}) ],
- nameserver => [ grep { $_ } uniq(@$netc{'dnsServer', 'dnsServer2', 'dnsServer3'}) ],
+ search => [ grep { $_ } uniq(@$resolv{'DOMAINNAME', 'DOMAINNAME2', 'DOMAINNAME3'}) ],
+ nameserver => [ grep { $_ } uniq(@$resolv{'dnsServer', 'dnsServer2', 'dnsServer3'}) ],
);
my (%prev, @unknown);
- foreach (cat_($file)) {
+ foreach (cat_($resolv_file)) {
s/\s+$//;
s/^[#\s]*//;
@@ -94,7 +137,7 @@ sub write_resolv_conf {
push @unknown, $_;
}
}
- unlink $file if -l $file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever
+ unlink $resolv_file if -l $resolv_file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever
if (@{$new{search}} || @{$new{nameserver}}) {
$prev{$_} = [ difference2($prev{$_} || [], $new{$_}) ] foreach keys %new;
@@ -109,7 +152,7 @@ sub write_resolv_conf {
my @old = map { "# nameserver $_\n" } @{$prev{nameserver}};
@new, @old;
};
- output_with_perm($file, 0644, @search, @nameserver, (map { "# $_\n" } @unknown), "\n# ppp temp entry\n");
+ output_with_perm($resolv_file, 0644, @search, @nameserver, (map { "# $_\n" } @unknown), "\n# ppp temp entry\n");
#-res_init(); # reinit the resolver so DNS changes take affect
1;
@@ -128,10 +171,16 @@ sub update_broadcast_and_network {
}
sub write_interface_conf {
- my ($file, $intf, $_netc, $_prefix) = @_;
+ my ($net, $name) = @_;
+
+ my $file = "$::prefix/etc/sysconfig/network-scripts/ifcfg-$name";
+ #- prefer ifcfg-XXX files
+ unlink("$::prefix/etc/sysconfig/network-scripts/$name");
+
+ my $intf = $net->{ifcfg}{$name};
require network::ethernet;
- my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
+ my (undef, $mac_address) = network::ethernet::get_eth_card_mac_address($intf->{DEVICE});
$intf->{HWADDR} &&= $mac_address; #- set HWADDR to MAC address if required
update_broadcast_and_network($intf);
@@ -147,15 +196,16 @@ sub write_interface_conf {
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 ($hostname, @ips) = @_;
my ($sub_hostname) = $hostname =~ /(.*?)\./;
+ my $file = "$::prefix/etc/hosts";
+
my %l;
foreach (cat_($file)) {
my ($ip, $aliases) = /^\s*(\S+)\s+(\S+.*)$/ or next;
@@ -170,35 +220,34 @@ sub add2hosts {
# The interface/gateway needs to be configured before this will work!
sub guessHostname {
- my ($_prefix, $netc, $intf) = @_;
+ my ($net, $intf_name) = @_;
- $intf->{isUp} && dnsServers($netc) or return 0;
- $netc->{HOSTNAME} && $netc->{DOMAINNAME} and return 1;
+ $net->{ifcfg}{$intf_name}{isUp} && dnsServers($net) or return 0;
+ $net->{network}{HOSTNAME} && $net->{resolv}{DOMAINNAME} and return 1;
- write_resolv_conf("$::prefix/etc/resolv.conf", $netc);
+ write_resolv_conf($net);
- my $name = gethostbyaddr(Socket::inet_aton($intf->{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0;
+ my $name = gethostbyaddr(Socket::inet_aton($net->{ifcfg}{$intf_name}{IPADDR}), Socket::AF_INET()) or log::explanations("reverse name lookup failed"), return 0;
log::explanations("reverse name lookup worked");
- add2hash($netc, { HOSTNAME => $name });
+ $net->{network}{HOSTNAME} ||= $name;
1;
}
sub addDefaultRoute {
- my ($netc) = @_;
- c::addDefaultRoute($netc->{GATEWAY}) if $netc->{GATEWAY};
+ my ($net) = @_;
+ c::addDefaultRoute($net->{network}{GATEWAY}) if $net->{network}{GATEWAY};
}
sub sethostname {
- my ($netc) = @_;
+ my ($net) = @_;
my $text;
- syscall_("sethostname", $netc->{HOSTNAME}, length $netc->{HOSTNAME}) ? ($text="set sethostname to $netc->{HOSTNAME}") : ($text="sethostname failed: $!");
+ my $hostname = $net->{network}{HOSTNAME};
+ syscall_("sethostname", $hostname, length $hostname) ? ($text="set sethostname to $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");
- }
+ run_program::run("/usr/bin/run-parts", "--arg", $hostname, "/etc/sysconfig/network-scripts/hostname.d") unless $::isInstall;
}
sub resolv($) {
@@ -210,15 +259,16 @@ sub resolv($) {
}
sub dnsServers {
- my ($netc) = @_;
- my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3);
+ my ($net) = @_;
+ #- FIXME: that's weird
+ my %used_dns; @used_dns{$net->{network}{dnsServer}, $net->{network}{dnsServer2}, $net->{network}{dnsServer3}} = (1, 2, 3);
sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns;
}
sub findIntf {
- my ($intf, $device) = @_;
- $intf->{$device}{DEVICE} = undef;
- $intf->{$device};
+ my ($net, $device) = @_;
+ $net->{ifcfg}{$device}{DEVICE} = undef;
+ $net->{ifcfg}{$device};
}
my $ip_regexp = qr/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
@@ -293,16 +343,16 @@ sub gateway {
sub netprofile_set {
- my ($netc, $profile) = @_;
- $netc->{PROFILE} = $profile;
- system('/sbin/set-netprofile', $netc->{PROFILE});
- log::explanations(qq(Switching to "$netc->{PROFILE}" profile));
+ my ($net, $profile) = @_;
+ $net->{PROFILE} = $profile;
+ system('/sbin/set-netprofile', $net->{PROFILE});
+ log::explanations(qq(Switching to "$net->{PROFILE}" profile));
}
sub netprofile_save {
- my ($netc) = @_;
- system('/sbin/save-netprofile', $netc->{PROFILE});
- log::explanations(qq(Saving "$netc->{PROFILE}" profile));
+ my ($net) = @_;
+ system('/sbin/save-netprofile', $net->{PROFILE});
+ log::explanations(qq(Saving "$net->{PROFILE}" profile));
}
sub netprofile_delete {
@@ -313,9 +363,9 @@ sub netprofile_delete {
}
sub netprofile_add {
- my ($netc, $profile) = @_;
+ my ($net, $profile) = @_;
return if !$profile || $profile eq "default" || member($profile, netprofile_list());
- system('/sbin/clone-netprofile', $netc->{PROFILE}, $profile);
+ system('/sbin/clone-netprofile', $net->{PROFILE}, $profile);
log::explanations(qq("Creating "$profile" profile));
}
@@ -324,9 +374,9 @@ sub netprofile_list() {
}
sub netprofile_read {
- my ($netc) = @_;
+ my ($net) = @_;
my $config = { getVarsFromSh("$::prefix/etc/netprofile/current") };
- $netc->{PROFILE} = $config->{PROFILE} || 'default';
+ $net->{PROFILE} = $config->{PROFILE} || 'default';
}
@@ -430,46 +480,45 @@ xml:readonly:$defaults_dir
}
}
-sub read_all_conf {
- my ($_prefix, $netc, $intf, $o_netcnx) = @_;
- $netc ||= {}; $intf ||= {};
- my $netcnx = $o_netcnx || {};
- add2hash($netc, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network";
- add2hash($netc, read_resolv_conf());
- add2hash($netc, read_tmdns_conf());
+sub read_net_conf {
+ my ($net) = @_;
+ add2hash($net->{network} ||= {}, read_conf("$::prefix/etc/sysconfig/network")) if -r "$::prefix/etc/sysconfig/network";
+ add2hash($net->{resolv} ||= {}, read_resolv_conf());
+ add2hash($net->{zeroconf} ||= {}, read_zeroconf());
foreach (all("$::prefix/etc/sysconfig/network-scripts")) {
my ($device) = /^ifcfg-([A-Za-z0-9.:_-]+)$/;
next if $device =~ /.rpmnew$|.rpmsave$/;
if ($device && $device ne 'lo') {
- my $intf = findIntf($intf, $device);
+ my $intf = findIntf($net, $device);
add2hash($intf, { getVarsFromSh("$::prefix/etc/sysconfig/network-scripts/$_") });
$intf->{DEVICE} ||= $device;
}
}
- netprofile_read($netc);
- if (my $default_intf = network::tools::get_default_gateway_interface($netc, $intf)) {
- $netcnx->{type} ||= network::tools::get_interface_type($intf->{$default_intf});
+ netprofile_read($net);
+ if (my $default_intf = network::tools::get_default_gateway_interface($net)) {
+ $net->{net_interface} = $default_intf;
+ $net->{type} = network::tools::get_interface_type($net->{ifcfg}{$default_intf});
}
}
#- FIXME: this is buggy, use network::tools::get_default_gateway_interface
sub probe_netcnx_type {
- my ($_prefix, $_netc, $intf, $netcnx) = @_;
+ my ($net) = @_;
#- try to probe $netcnx->{type} which is used almost everywhere.
- unless ($netcnx->{type}) {
+ unless ($net->{type}) {
#- ugly hack to determine network type (avoid saying not configured in summary).
- -e "$::prefix/etc/ppp/peers/adsl" and $netcnx->{type} ||= 'adsl'; # enough ?
- -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $netcnx->{type} ||= 'isdn'; # enough ?
- $intf->{ppp0} and $netcnx->{type} ||= 'modem';
- $intf->{eth0} and $netcnx->{type} ||= 'lan';
+ -e "$::prefix/etc/ppp/peers/adsl" and $net->{type} ||= 'adsl'; # enough ?
+ -e "$::prefix/etc/ppp/ioptions1B" || -e "$::prefix/etc/ppp/ioptions2B" and $net->{type} ||= 'isdn'; # enough ?
+ $net->{ifcfg}{ppp0} and $net->{type} ||= 'modem';
+ $net->{ifcfg}{eth0} and $net->{type} ||= 'lan';
}
}
sub easy_dhcp {
- my ($modules_conf, $netc, $intf) = @_;
+ my ($net, $modules_conf) = @_;
- return if text2bool($netc->{NETWORKING});
+ return if text2bool($net->{network}{NETWORKING});
require modules;
require network::ethernet;
@@ -483,87 +532,45 @@ sub easy_dhcp {
my $dhcp_intf = $ether_dev[0];
log::explanations("easy_dhcp: found $dhcp_intf");
- put_in_hash($netc, {
- NETWORKING => "yes",
- DHCP => "yes",
- NET_DEVICE => $dhcp_intf,
- NET_INTERFACE => $dhcp_intf,
- });
- $intf->{$dhcp_intf} ||= {};
- put_in_hash($intf->{$dhcp_intf}, {
+ put_in_hash($net->{network}, {
+ NETWORKING => "yes",
+ DHCP => "yes",
+ NET_DEVICE => $dhcp_intf,
+ NET_INTERFACE => $dhcp_intf,
+ });
+ $net->{ifcfg}{$dhcp_intf} ||= {};
+ put_in_hash($net->{ifcfg}{$dhcp_intf}, {
DEVICE => $dhcp_intf,
BOOTPROTO => 'dhcp',
NETMASK => '255.255.255.0',
ONBOOT => 'yes'
});
+ $net->{type} = 'lan';
+ $net->{net_interface} = $dhcp_intf;
+
1;
}
-#- configureNetwork2 : configure the network interfaces.
-#- input
-#- $prefix
-#- $netc
-#- $intf
-#- $netc input
-#- NETWORKING : networking flag : string : "yes" by default
-#- FORWARD_IPV4 : forward IP flag : string : "false" by default
-#- HOSTNAME : hostname : string : "localhost.localdomain" by default
-#- DOMAINNAME : domainname : string : $netc->{HOSTNAME} =~ /\.(.*)/ by default
-#- DOMAINNAME2 : well it's another domainname : have to look further why we used 2
-#- The following are facultatives
-#- DHCP_HOSTNAME : If you have a dhcp and want to set the hostname
-#- GATEWAY : gateway
-#- GATEWAYDEV : gateway interface
-#- NISDOMAIN : nis domain
-#- $netc->{dnsServer} : dns server 1
-#- $netc->{dnsServer2} : dns server 2
-#- $netc->{dnsServer3} : dns server 3 : note that we uses the dns1 for the LAN, and the 2 others for the internet conx
-#- $intf input: for each $device (for example ethx)
-#- $intf->{$device}{IPADDR} : IP address
-#- $intf->{$device}{NETMASK} : netmask
-#- $intf->{$device}{DEVICE} : DEVICE = $device
-#- $intf->{$device}{BOOTPROTO} : boot prototype : "bootp" or "dhcp" or "pump" or ...
-sub configureNetwork2 {
- my ($in, $modules_conf, $_prefix, $netc, $intf) = @_;
- my $etc = "$::prefix/etc";
+sub configure_network {
+ my ($net, $in, $modules_conf) = @_;
if (!$::testing) {
require network::ethernet;
network::ethernet::update_iftab();
network::ethernet::configure_eth_aliases($modules_conf);
- $netc->{wireless_eth} and $in->do_pkgs->ensure_binary_is_installed('wireless-tools', 'iwconfig', 'auto');
- write_conf($netc);
- write_resolv_conf("$etc/resolv.conf", $netc) unless $netc->{DHCP};
+ write_network_conf($net);
+ write_resolv_conf($net);
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";
+ symlink "$::prefix/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);
- $intf->{$_}{BOOTPROTO} eq "dhcp" and network::ethernet::install_dhcp_client($in, $intf->{$_});
- }
- add2hosts("$etc/hosts", $netc->{HOSTNAME}, "127.0.0.1") if $netc->{HOSTNAME};
- add2hosts("$etc/hosts", "localhost", "127.0.0.1");
-
- if ($netc->{ZEROCONF_HOSTNAME}) {
- $in->do_pkgs->ensure_binary_is_installed('tmdns', 'tmdns', 'auto') if !$in->do_pkgs->is_installed('bind');
- $in->do_pkgs->ensure_binary_is_installed('zcip', 'zcip', 'auto');
- write_zeroconf("$etc/tmdns.conf", $netc->{ZEROCONF_HOSTNAME});
- require services;
- services::start_service_on_boot("tmdns");
- services::restart("tmdns");
- } else {
- #- disable zeroconf
- require services;
- #- write blank hostname so that drakconnect does not 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');
+ write_interface_conf($net, $_) foreach keys %{$net->{ifcfg}};
+ network::ethernet::install_dhcp_client($in, $_->{DHCP_CLIENT}) foreach grep { $_->{BOOTPROTO} eq "dhcp" } values %{$net->{ifcfg}};
+ add2hosts($net->{network}{HOSTNAME}, "127.0.0.1") if $net->{network}{HOSTNAME};
+ add2hosts("localhost", "127.0.0.1");
+ write_zeroconf($net, $in);
+
+ any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %{$net->{ifcfg}} and $in->do_pkgs->install('pump');
}
}
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index ba51572a7..478dca21d 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -4,11 +4,6 @@ use strict;
use common;
use run_program;
use c;
-use vars qw(@ISA @EXPORT @EXPORT_OK);
-use MDK::Common::System qw(getVarsFromSh);
-
-@ISA = qw(Exporter);
-@EXPORT = qw(connect_backend connected connected_bg disconnect_backend is_dynamic_ip passwd_by_login read_secret_backend test_connected remove_initscript write_secret_backend start_interface stop_interface);
sub write_secret_backend {
my ($a, $b) = @_;
@@ -159,48 +154,39 @@ sub check_link_beat() {
});
}
-sub remove_initscript() {
- $::testing and return;
- if (-e "$::prefix/etc/rc.d/init.d/internet") {
- run_program::rooted($::prefix, "/sbin/chkconfig", "--del", "internet");
- rm_rf("$::prefix/etc/rc.d/init.d/internet");
- log::explanations("Removed internet service");
- }
-}
-
sub is_dynamic_ip {
- my ($intf) = @_;
- any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %$intf;
+ my ($net) = @_;
+ any { $_->{BOOTPROTO} !~ /^(none|static|)$/ } values %{$net->{ifcfg}};
}
sub is_dynamic_host {
- my ($intf) = @_;
- any { defined $_->{DHCP_HOSTNAME} } values %$intf;
+ my ($net) = @_;
+ any { defined $_->{DHCP_HOSTNAME} } values %{$net->{ifcfg}};
}
#- returns interface whose IP address matchs given IP address, according to its network mask
sub find_matching_interface {
- my ($intf, $address) = @_;
+ my ($net, $address) = @_;
my @ip = split '\.', $address;
find {
- my @intf_ip = split '\.', $intf->{$_}{IPADDR} or return;
- my @mask = split '\.', $intf->{$_}{NETMASK} or return;
+ my @intf_ip = split '\.', $net->{ifcfg}{$_}{IPADDR} or return;
+ my @mask = split '\.', $net->{ifcfg}{$_}{NETMASK} or return;
every { $_ } mapn { ($_[0] & $_[2]) == ($_[1] & $_[2]) } \@intf_ip, \@ip, \@mask;
- } sort keys %$intf;
+ } sort keys %{$net->{ifcfg}};
}
#- returns gateway interface if found
sub get_default_gateway_interface {
- my ($netc, $intf) = @_;
- my @intfs = sort keys %$intf;
+ my ($net) = @_;
+ my @intfs = sort keys %{$net->{ifcfg}};
`$::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 'wifi' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs) ||
- (find { get_interface_type($intf->{$_}) eq 'ethernet' && $intf->{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
+ $net->{network}{GATEWAYDEV} ||
+ $net->{network}{GATEWAY} && find_matching_interface($net, $net->{network}{GATEWAY}) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'adsl' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'isdn' && text2bool($net->{ifcfg}{$_}{DIAL_ON_IFUP}) } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'modem' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'wifi' && $net->{ifcfg}{$_}{BOOTPROTO} eq 'dhcp' } @intfs) ||
+ (find { get_interface_type($net->{ifcfg}{$_}) eq 'ethernet' && $net->{ifcfg}{$_}{BOOTPROTO} eq 'dhcp' } @intfs);
}
sub get_interface_status {
@@ -213,9 +199,9 @@ sub get_interface_status {
#- returns (gateway_interface, interface is up, gateway address, dns server address)
sub get_internet_connection {
- my ($netc, $intf, $o_gw_intf) = @_;
- my $gw_intf = $o_gw_intf || get_default_gateway_interface($netc, $intf) or return;
- return $gw_intf, get_interface_status($gw_intf), $netc->{dnsServer};
+ my ($net, $o_gw_intf) = @_;
+ my $gw_intf = $o_gw_intf || get_default_gateway_interface($net) or return;
+ return $gw_intf, get_interface_status($gw_intf), $net->{resolv}{dnsServer};
}
sub get_interface_type {
diff --git a/perl-install/standalone/drakauth b/perl-install/standalone/drakauth
index d29f250ca..db7418d51 100755
--- a/perl-install/standalone/drakauth
+++ b/perl-install/standalone/drakauth
@@ -9,7 +9,8 @@ use interactive;
use authentication;
use network::network;
-read_all_conf('', my $netc = {}, my $_intf = {});
+my $net = {};
+network::network::read_net_conf($net);
my $in = 'interactive'->vnew('su');
@@ -25,11 +26,11 @@ $in->ask_from(N("Authentication"), authentication::kind2description(@kinds),
{ label => N("Authentication"), val => \$kind, type => 'list' , list => \@kinds, format => \&authentication::kind2name },
]) or $in->exit;
-authentication::ask_parameters($in, $netc, $authentication, $kind) or goto main;
+authentication::ask_parameters($in, $net, $authentication, $kind) or goto main;
eval {
- authentication::set($in, $netc, $authentication);
- network::network::write_conf($netc);
+ authentication::set($in, $net, $authentication);
+ network::network::write_conf($net);
};
if (my $err = $@) {
$in->ask_warn(N("Error"), formatError($err));
diff --git a/perl-install/standalone/drakautoinst b/perl-install/standalone/drakautoinst
index 2933eb347..6dbfb3a36 100755
--- a/perl-install/standalone/drakautoinst
+++ b/perl-install/standalone/drakautoinst
@@ -126,9 +126,7 @@ if (!$::isEmbedded && $in->isa('interactive::gtk')) {
manualFstab => 'partition',
useSupermount => '',
partitioning => 'partition',
- intf => 'network',
- netc => 'network',
- netcnx => 'network',
+ net => 'network',
superuser => 'user',
users => 'user',
authentication => '',
diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect
index 1f22003ec..81a15d7dc 100755
--- a/perl-install/standalone/drakconnect
+++ b/perl-install/standalone/drakconnect
@@ -39,7 +39,6 @@ use c;
use modules;
use network::isdn;
use network::adsl;
-use network::tools;
use network::test;
use POSIX ":sys_wait_h";
@@ -50,15 +49,15 @@ if ($in->isa('interactive::gtk')) {
ugtk2->import(qw(:create :dialogs :helpers :wrappers));
}
-my ($netcnx, $netc, $intf) = ({}, {}, {});
-network::netconnect::read_net_conf($netcnx, $netc, $intf);
+my $net = {};
+network::network::read_net_conf($net);
my $modules_conf = modules::any_conf->read;
$::Wizard_title = N("Network & Internet Configuration");
$::Wizard_pix_up = "drakconnect.png";
local $_ = join '', @ARGV;
-/--skip-wizard/ and manage($netc, $intf);
+/--skip-wizard/ and manage();
/--add/ and add_intf();
/--del/ and del_intf();
/--old/ and goto old;
@@ -66,7 +65,7 @@ if (/--install/) {
$::isInstall = 1;
add_intf();
}
-/--internet/ and configure_net($netcnx, $netc, $intf);
+/--internet/ and configure_net();
# default is to run wizard
add_intf();
@@ -89,17 +88,17 @@ my $button_apply;
my $hostname = chomp_(`hostname`);
-my $int_label = Gtk2::Label->new($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
-my $int_name = Gtk2::Label->new($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
+my $int_label = Gtk2::Label->new($net->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
+my $int_name = Gtk2::Label->new($net->{type} eq 'lan' ? $net->{network}{GATEWAY} : $net->{net_interface});
my $isconnected = -1;
my $int_connect = Gtk2::Button->new(N("Wait please"));
$int_connect->set_sensitive(0);
$int_connect->signal_connect(clicked => sub {
if (!$isconnected) {
- connect_backend($netc);
+ network::tools::connect_backend($net);
} else {
- disconnect_backend($netc);
+ network::tools::disconnect_backend($net);
}
});
@@ -132,7 +131,7 @@ $window1->{window}->add(
clicked => sub {
local ($::isWizard, $::Wizard_finished) = (1, 1);
eval { # For wizcancel
- network::netconnect::main($netcnx, $in, $modules_conf, $netc, undef, $intf);
+ network::netconnect::safe_main($net, $in, $modules_conf);
$button_apply->set_sensitive(1);
update();
};
@@ -165,7 +164,7 @@ $window1->{window}->add(
Gtk2::Label->new(N("Please Wait... Applying the configuration")));
$dialog->show_all;
gtkflush();
- apply($netc, $intf);
+ apply();
$dialog->destroy;
}
update();
@@ -182,9 +181,7 @@ gtkflush();
$window1->main;
ugtk2->exit(0);
-sub manage {
- my ($netc, $intf) = @_;
-
+sub manage() {
my $p = {};
my ($interface_menu, $selected, $apply_button);
my $window = ugtk2->new('Manage Connection');
@@ -203,10 +200,10 @@ sub manage {
my $dev = detect_devices::is_lan_interface($_) ? $names{$_} : $_;
$p->{$dev} = {
name => $_ ,
- intf => $intf->{$_}
+ intf => $net->{ifcfg}{$_}
};
}
- while (my ($device, $interface) = each %$intf) {
+ while (my ($device, $interface) = each %{$net->{ifcfg}}) {
exists $names{$device} and next;
my $type = network::tools::get_interface_type($interface);
$p->{"$type ($device)"} = {
@@ -231,7 +228,7 @@ sub manage {
cancel_clicked => sub { $window->destroy; Gtk2->main_quit },
ok_clicked => sub {
if ($apply_button->get_property('sensitive')) {
- save($netc, $p, $apply_button);
+ save($p, $apply_button);
}
$window->destroy;
Gtk2->main_quit;
@@ -239,18 +236,18 @@ sub manage {
},
undef, undef, '',
[ N("Help"), sub { exec("drakhelp --id internet-connection") unless fork() } ],
- [ N("Apply"), sub { save($netc, $p, $apply_button) }, 0, 1 ],
+ [ N("Apply"), sub { save($p, $apply_button) }, 0, 1 ],
),
),
);
$apply_button = $oc->{buttons}{N("Apply")};
each_index {
- my ($name, $interface, $protocol) = ($_, $p->{$_}{name}, $p->{$_}{protocol});
+ my ($name, $interface) = ($_, $p->{$_}{name});
$p->{$name}{gui}{index} = $::i;
$p->{$name}{intf} ||= { DEVICE => $interface };
- build_tree($netc, $p->{$name}{intf}, $name, $interface, $protocol);
- build_notebook($netc, $p->{$name}{intf}, $p->{$name}{gui}, $apply_button, $name, $interface);
+ build_tree($p->{$name}{intf}, $name);
+ build_notebook($p->{$name}{intf}, $p->{$name}{gui}, $apply_button, $name, $interface);
$notebook->append_page(gtkpack(Gtk2::VBox->new(0,0), $p->{$name}{gui}{notebook}));
} (sort keys %$p);
@@ -264,20 +261,19 @@ sub manage {
}
sub build_tree {
- my ($netc, $intf, $interface, $interface_name, $protocol) = @_;
+ my ($intf, $interface) = @_;
if ($interface eq 'adsl') {
$intf->{pages} = { 'TCP/IP' => 1, 'DHCP' => 1, 'Account' => 1, 'Options' => 1, 'Information' => 1 };
- network::adsl::adsl_probe_info($intf, $netc, $protocol, $interface_name);
+ network::adsl::adsl_probe_info($net);
$intf->{save} = sub {
- $netc->{internet_cnx_choice} = 'adsl';
- $netc->{at_boot} = $intf->{ONBOOT} eq 'yes' ? 1 : 0;
- network::adsl::adsl_conf_backend($in, $modules_conf, $netcnx, $netc, $intf, $interface_name, $protocol);
+ $net->{type} = 'adsl';
+ network::adsl::adsl_conf_backend($in, $modules_conf, $net);
};
}
elsif ($interface eq 'modem') {
$intf->{pages} = { 'TCP/IP' => 1, 'Account' => 1, 'Modem' => 1, 'Options' => 1 };
- put_in_hash($intf, network::modem::ppp_read_conf({}, $netc));
+ put_in_hash($intf, network::modem::ppp_read_conf());
$intf->{save} = sub { network::modem::ppp_configure($in, $intf) };
}
elsif ($interface eq 'isdn') {
@@ -292,7 +288,7 @@ sub build_tree {
}
sub build_notebook {
- my ($netc, $intf, $gui, $apply_button, $interface, $interface_name) = @_;
+ my ($intf, $gui, $apply_button, $interface, $interface_name) = @_;
my $apply = sub { $apply_button->set_sensitive(1) };
my $is_ethernet = detect_devices::is_lan_interface($interface);
@@ -340,14 +336,14 @@ sub build_notebook {
gtkpack_(Gtk2::VBox->new,
1, gtkadd(gtkcreate_frame(N("DNS servers")),
gtkpack(Gtk2::VBox->new(0,0),
- Gtk2::Label->new($intf->{dns1} || $netc->{dnsServer}),
- if_($intf->{dns2} || $netc->{dnsServer2},
- Gtk2::Label->new($intf->{dns2} || $netc->{dnsServer2})),
- if_($intf->{dns3} || $netc->{dnsServer3},
- Gtk2::Label->new($intf->{dns3} || $netc->{dnsServer3}))),
+ Gtk2::Label->new($intf->{dns1} || $net->{resolv}{dnsServer}),
+ if_($intf->{dns2} || $net->{resolv}{dnsServer2},
+ Gtk2::Label->new($intf->{dns2} || $net->{resolv}{dnsServer2})),
+ if_($intf->{dns3} || $net->{resolv}{dnsServer3},
+ Gtk2::Label->new($intf->{dns3} || $net->{resolv}{dnsServer3}))),
),
1, gtkadd(gtkcreate_frame(N("Search Domain")),
- Gtk2::Label->new($intf->{domain} || $netc->{DOMAINNAME} || 'none'),
+ Gtk2::Label->new($intf->{domain} || $net->{resolv}{DOMAINNAME} || 'none'),
),
),
);
@@ -365,7 +361,7 @@ sub build_notebook {
delete $gui->{intf}{BOOTPROTO};
}
!$intf->{IPADDR} and ($intf->{IPADDR}, $gui->{active}, $intf->{NETMASK}) = get_intf_ip($interface_name);
- $gui->{netc}{$_}->set_text($netc->{$_}) foreach keys %{$gui->{netc}};
+ $gui->{netc}{$_}->set_text($net->{$_}) foreach keys %{$gui->{netc}};
}
if ($intf->{pages}{DHCP}) {
@@ -636,7 +632,7 @@ sub populate_notebook {
}
sub save {
- my ($netc, $p, $apply_button) = @_;
+ my ($p, $apply_button) = @_;
my $dialog = _create_dialog(N("Please wait"));
gtkpack($dialog->vbox,
@@ -647,8 +643,8 @@ sub save {
Glib::Timeout->add(200, sub {
gtkflush();
foreach (keys %$p) {
- save_notebook($netc, $p->{$_}{intf}, $p->{$_}{gui}) or return;
- $p->{$_}{intf}{save} ? $p->{$_}{intf}{save}->() : apply($netc, $p->{$_}{intf});
+ save_notebook($p->{$_}{intf}, $p->{$_}{gui}) or return;
+ $p->{$_}{intf}{save} ? $p->{$_}{intf}{save}->() : apply($p->{$_}{intf});
}
system("/etc/rc.d/init.d/network restart");
$dialog->response(0);
@@ -661,9 +657,9 @@ sub save {
}
sub save_notebook {
- my ($netc, $intf, $gui) = @_;
+ my ($intf, $gui) = @_;
- $netc->{$_} = $gui->{netc}{$_}->get_text foreach keys %{$gui->{netc}};
+ $net->{$_} = $gui->{netc}{$_}->get_text foreach keys %{$gui->{netc}};
$gui->{intf}{$_} and $intf->{$_} = $gui->{intf}{$_}->get_text foreach keys %{$gui->{intf}};
$gui->{intf_radio}{$_} and $intf->{$_} = $gui->{intf_radio}{$_} foreach keys %{$gui->{intf_radio}};
$intf->{$_} = bool2yesno($gui->{intf_bool}{$_}->get_active) foreach keys %{$gui->{intf_bool}};
@@ -683,7 +679,7 @@ sub save_notebook {
return 0;
}
}
- if ($netc->{GATEWAY} && !is_ip($netc->{GATEWAY})) {
+ if ($net->{network}{GATEWAY} && !is_ip($net->{network}{GATEWAY})) {
$in->ask_warn(N("Error"), N("Gateway address should be in format 1.2.3.4"));
return 0;
}
@@ -692,13 +688,13 @@ sub save_notebook {
sub add_intf() {
$::isWizard = 1;
- network::netconnect::main($netcnx, $in, $modules_conf, $netc, undef, $intf);
+ network::netconnect::safe_main($net, $in, $modules_conf);
$in->exit(0);
}
sub del_intf() {
my ($intf2delete, $failure);
- if (!keys %$intf) {
+ if (!keys %{$net->{ifcfg}}) {
$in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system. Please run the hardware configuration tool."));
$in->exit(0);
}
@@ -713,9 +709,9 @@ sub del_intf() {
no_back => 1,
name => N("Select the network interface to remove:"),
data => [ { label => N("Net Device"), val => \$intf2delete, allow_empty_list => 1,
- list => [ keys %$intf ],
+ list => [ keys %{$net->{ifcfg}} ],
format => sub {
- my $type = network::tools::get_interface_type($intf->{$_[0]});
+ my $type = network::tools::get_interface_type($net->{ifcfg}{$_[0]});
$ethernet_names{$_[0]} || ($type ? "$type ($_[0])" : $_[0]);
}
}
@@ -764,7 +760,7 @@ sub get_intf_ip {
$mask = /Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/mso ? $1 : N("No Mask");
$state = /inet/ ? N("up") : N("down");
} else {
- $ip = $intf->{$interface}{IPADDR};
+ $ip = $net->{ifcfg}{$interface}{IPADDR};
$state = "n/a";
}
($ip, $state, $mask);
@@ -782,7 +778,7 @@ sub update_list {
}
foreach my $interface (@new_intf) {
my ($ip, $state) = get_intf_ip($interface);
- $tree_model->set($intf{$interface}, map_index { $::i => $_ } (gtkcreate_pixbuf("eth_card_mini2.png"), $interface, $ip , $intf->{$interface}{BOOTPROTO}, $new_intf{$interface}, $state));
+ $tree_model->set($intf{$interface}, map_index { $::i => $_ } (gtkcreate_pixbuf("eth_card_mini2.png"), $interface, $ip , $net->{ifcfg}{$interface}{BOOTPROTO}, $new_intf{$interface}, $state));
}
foreach my $i (difference2([ keys %intf ], \@new_intf)) {
$tree_model->remove($intf{$i});
@@ -791,13 +787,10 @@ sub update_list {
}
sub apply {
- my ($netc, $intf) = @_;
+ my ($intf) = @_;
my $dyn = $intf->{BOOTPROTO} ne 'static';
- my $lintf = $intf;
- #- always delete NETWORK and BROADCAST fields so that they get automatically recomputed by write_interface_conf
- delete $lintf->{$_} foreach qw(NETWORK BROADCAST), if_($dyn, qw(IPADDR NETMASK));
- network::network::sethostname($netc) if $dyn;
- network::network::configureNetwork2($in, $modules_conf, '', $netc, { $lintf->{DEVICE} => $lintf });
+ network::network::sethostname($net) if $dyn;
+ network::network::configure_network($net, $in, $modules_conf);
}
sub ethisup { `LC_ALL=C LANGUAGE=C /sbin/ifconfig $_[0]` =~ /inet/ }
@@ -814,8 +807,8 @@ my $to_update;
sub update() {
my $h = chomp_(`hostname`);
$label_host->set_label($h);
- $int_label->set($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
- $int_name->set($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
+ $int_label->set($net->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
+ $int_name->set($net->{type} eq 'lan' ? $net->{network}{GATEWAY} : $net->{net_interface});
update_list($modules_conf);
update_intbutt() if $isconnected != -1;
1;
@@ -830,11 +823,11 @@ sub in_ifconfig {
sub update2() {
undef $to_update;
- connected_bg(\$to_update);
+ network::tools::connected_bg(\$to_update);
if (defined $to_update) {
$isconnected = $to_update;
if ($isconnected != -1) {
- if ($isconnected && !in_ifconfig($netcnx->{NET_INTERFACE})) {
+ if ($isconnected && !in_ifconfig($net->{net_interface})) {
$warning_label1->set(N("Warning, another Internet connection has been detected, maybe using your network"));
$isconnected = 0;
} else { $warning_label1->set("") }
@@ -906,12 +899,12 @@ Configure them first by clicking on 'Configure'")));
# Eth${_}Driver = $all_cards[$_]->[1]
my $interface = $all_cards[$_][0];
my ($ip, undef, $mask) = get_intf_ip($interface);
- $mask ||= $intf->{$interface}{NETMASK};
+ $mask ||= $net->{ifcfg}{$interface}{NETMASK};
@conf_data = ([ N("IP address"), \$ip ],
[ N("Netmask"), \$mask ],
- [ N("Boot Protocol"), \$intf->{$interface}{BOOTPROTO}, ["static", "dhcp", "bootp"] ],
- [ N("Started on boot"), \$intf->{$interface}{ONBOOT} , ["yes", "no"] ],
- [ N("DHCP client"), \$intf->{$interface}{DHCP_CLIENT} ]
+ [ N("Boot Protocol"), \$net->{ifcg}{$interface}{BOOTPROTO}, ["static", "dhcp", "bootp"] ],
+ [ N("Started on boot"), \$net->{ifcg}{$interface}{ONBOOT} , ["yes", "no"] ],
+ [ N("DHCP client"), \$net->{ifcfg}{$interface}{DHCP_CLIENT} ]
);
my $i = 0;
my $size_group = Gtk2::SizeGroup->new('horizontal');
@@ -969,12 +962,12 @@ Configure them first by clicking on 'Configure'")));
my @infos = @{$card_tab[2*$_]};
each_index { ${$_->[1]} = $infos[2*$::i+1]->get_text } @{$card_tab[2*$_+1]};
my $interface = $all_cards[$_][0];
- if ($intf->{$interface}{BOOTPROTO} ne "static") {
- delete @{$intf->{$interface}}{qw(IPADDR NETWORK NETMASK BROADCAST)};
+ if ($net->{ifcfg}{$interface}{BOOTPROTO} ne "static") {
+ delete @{$net->{ifcfg}{$interface}}{qw(IPADDR NETWORK NETMASK BROADCAST)};
} else {
if ($infos[1]->get_text ne "No ip") {
- $intf->{$interface}{IPADDR} = $infos[1]->get_text;
- $intf->{$interface}{NETMASK} = $infos[3]->get_text;
+ $net->{ifcfg}{$interface}{IPADDR} = $infos[1]->get_text;
+ $net->{ifcfg}{$interface}{NETMASK} = $infos[3]->get_text;
}
}
}
@@ -987,17 +980,16 @@ Configure them first by clicking on 'Configure'")));
$window->show_all;
foreach (0..$#all_cards) {
my @infos = @{$card_tab[2*$_]};
- $intf->{$all_cards[$_][0]}{BOOTPROTO} eq "dhcp" or $infos[8]->hide;
+ $net->{ifcfg}{$all_cards[$_][0]}{BOOTPROTO} eq "dhcp" or $infos[8]->hide;
}
$window->run;
}
-sub configure_net {
- my ($netcnx, $netc, $_intf) = @_;
+sub configure_net() {
my $dialog = ugtk2->new('drakconnect');
my $exit_dialogsub = sub { Gtk2->main_quit };
- if (!$netcnx->{type}) {
+ if (!$net->{type}) {
$in->ask_warn(
N("Warning"),
#-PO: here "Add Connection" should be translated the same was as in control-center
@@ -1005,8 +997,6 @@ sub configure_net {
Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a new network interface (LAN, ISDN, ADSL, ...)")));
$in->exit;
}
- my $cnx = {};
- $cnx = $netcnx->{$netcnx->{type}};
unless ($::isEmbedded) {
$dialog->{rwindow}->set_position('center');
$dialog->{rwindow}->set_title(N("Internet connection configuration"));
@@ -1019,15 +1009,15 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
my $i = 0;
#- duplicated code (waiting for 9.1 to be out to merge everything correctly, avoid bug elsewhere).
- if ($netcnx->{type} =~ /adsl/) {
+ if ($net->{type} eq 'adsl') {
require network::adsl;
- network::adsl::adsl_probe_info($cnx, $netc, $intf);
+ network::adsl::adsl_probe_info($net);
}
my @conf_data = (
- [ N("Host name (optional)"), \$netc->{HOSTNAME} ],
- [ N("First DNS Server (optional)"), \$netc->{dnsServer} ], # \$cnx->{dns1}
- [ N("Second DNS Server (optional)"), \$netc->{dnsServer2} ], #\$cnx->{dns2}
- [ N("Third DNS server (optional)"), \$netc->{dnsServer3} ],
+ [ N("Host name (optional)"), \$net->{network}{HOSTNAME} ],
+ [ N("First DNS Server (optional)"), \$net->{resolv}{dnsServer} ],
+ [ N("Second DNS Server (optional)"), \$net->{resolv}{dnsServer2} ],
+ [ N("Third DNS server (optional)"), \$net->{reslov}{dnsServer3} ],
);
my @infos;
gtkpack($param_vbox,
@@ -1053,7 +1043,7 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
1, gtkadd(gtkcreate_frame(N("Internet access")),
gtkset_border_width(create_packtable({ col_spacings => 5, row_spacings => 5, homogenous => 1 },
[ Gtk2::Label->new(N("Connection type: ")),
- Gtk2::Label->new(translate($netcnx->{type})) ],
+ Gtk2::Label->new(translate($net->{type})) ],
[ $int_label, $int_name ],
[ Gtk2::Label->new(N("Status:")),
$int_state = Gtk2::Label->new(N("Testing your connection...")) ]
@@ -1072,8 +1062,7 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
update();
$button_apply->set_sensitive(1);
} else {
- configureNetwork2($in, $modules_conf, '', $netc, $intf);
- write_resolv_conf("/etc/resolv.conf", $netc);
+ network::network::configure_network($net, $in, $modules_conf);
}
$exit_dialogsub->();
}),
diff --git a/perl-install/standalone/drakpxe b/perl-install/standalone/drakpxe
index a3a3f78bc..dba934265 100755
--- a/perl-install/standalone/drakpxe
+++ b/perl-install/standalone/drakpxe
@@ -47,9 +47,8 @@ my $direct = grep { /-direct/ } @ARGV;
#my $shorewall = network::shorewall::read();
#
#- get network configuration.
-my $netc = {};
-my $intf = {};
-network::network::read_all_conf('', $netc, $intf);
+my $net = {};
+network::network::read_net_conf($net);
my $in = 'interactive'->vnew('su');
$::Wizard_title = N("PXE Server Configuration");
@@ -126,7 +125,7 @@ my @intf = grep { exists $_->{NETWORK} } map {
print STDERR "$s\n";
$s =~ /^(\S+)\s+\S+\s+$_->{NETMASK}\s+.*$_->{DEVICE}/ and $_->{NETWORK} = $1;
}
- } $_ } values %$intf;
+ } $_ } values %{$net->{ifcfg}};
if (@intf < 1) {
#- no interface already configured found, ask user to configure.
$in->ask_warn(N("No network adapter on your system!"),
@@ -149,7 +148,7 @@ if (@intf < 1) {
step_ip_range:
#- read current configuration, or create a default suitable automatically.
-my $dhcpd_conf = parse_dhcpd_conf("/etc/dhcpd.conf", {}, $netc, $intf[0]);
+my $dhcpd_conf = parse_dhcpd_conf("/etc/dhcpd.conf", {}, $net, $intf[0]);
#- get back default of ip.
my $pool;
@@ -252,10 +251,10 @@ foreach my $i (0..99) {
}
defined $label or $label = "halt$i", last;
}
-my $server = $intf[0]{IPADDR} || $netc->{HOSTNAME};
+my $server = $intf[0]{IPADDR} || $net->{network}{HOSTNAME};
push @{$pxelinux_cfg->{entry}}, { label => $label,
kernel => "images/alt0/vmlinuz",
- append => "initrd=images/alt0/all.rdz ramdisk=32000 vga=788 ".($auto_inst_cfg ? "kickstart=$auto_inst_cfg " : "")."automatic=method:http,network:dhcp,interface:eth0,dns:$netc->{dnsServer},server:$server,directory:$dir root=/dev/ram3" };
+ append => "initrd=images/alt0/all.rdz ramdisk=32000 vga=788 ".($auto_inst_cfg ? "kickstart=$auto_inst_cfg " : "")."automatic=method:http,network:dhcp,interface:eth0,dns:$net->{resolv}{dnsServer},server:$server,directory:$dir root=/dev/ram3" };
build_pxelinux_cfg($pxelinux_cfg, "/var/lib/tftpboot/PXEClient/pxelinux.cfg/default");
#- make directory available for httpd.
@@ -269,7 +268,7 @@ start_daemons();
#- sub for reading/writing dhcpd.conf and pxelinux.cfg/default...
sub parse_dhcpd_conf {
- my ($file, undef, $netc, $intf) = @_;
+ my ($file, undef, $net, $intf) = @_;
my (%dhcpd_conf, $pool);
local (*F, $_);
@@ -277,7 +276,8 @@ sub parse_dhcpd_conf {
$dhcpd_conf{class_PXE} = 'PXE';
$dhcpd_conf{class} = { PXE => undef, Etherboot => undef, known => undef };
add2hash($dhcpd_conf{network} = { pool => [] }, $intf);
- add2hash($dhcpd_conf{network}, $netc);
+ add2hash($dhcpd_conf{network}, $net->{network});
+ add2hash($dhcpd_conf{network}, $net->{resolv});
if (open F, $file) {
while (<F>) {
diff --git a/perl-install/standalone/finish-install b/perl-install/standalone/finish-install
index 653ddf24a..ac904f8ff 100755
--- a/perl-install/standalone/finish-install
+++ b/perl-install/standalone/finish-install
@@ -6,13 +6,15 @@ use common;
use interactive;
use any;
use authentication;
+use network::network;
use network::netconnect;
use security::level;
$ENV{SHARE_PATH} ||= "/usr/share";
my $authentication = authentication::get();
my $security = security::level::get();
-network::netconnect::read_net_conf(my $netcnx = {}, my $netc = {}, my $intf = {});
+my $net = {};
+network::network::read_net_conf($net);
$::isWizard = 1;
my $in = 'interactive'->vnew;
@@ -29,19 +31,19 @@ sub ask_language() {
sub ask_network() {
my $modules_conf = modules::any_conf->read;
require network::netconnect;
- network::netconnect::real_main($netcnx, $in, $modules_conf, $netc, undef, $intf);
+ network::netconnect::real_main($net, $in, $modules_conf);
}
sub ask_authentication() {
my $meta_class = { getVarsFromSh("/etc/sysconfig/system") }->{META_CLASS};
my $superuser = {};
- authentication::ask_root_password_and_authentication($in, $netc, $superuser, $authentication, $meta_class, $security);
+ authentication::ask_root_password_and_authentication($in, $net, $superuser, $authentication, $meta_class, $security);
authentication::set_root_passwd($superuser, $authentication);
eval {
- authentication::set($in, $netc, $authentication);
- network::network::write_conf($netc);
+ authentication::set($in, $net, $authentication);
+ network::network::write_network_conf($net);
};
if (my $err = $@) {
$in->ask_warn(N("Error"), formatError($err));
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet
index 28d7c8e11..1311da3fe 100644
--- a/perl-install/standalone/net_applet
+++ b/perl-install/standalone/net_applet
@@ -6,7 +6,7 @@ use c;
use common;
use standalone;
use Digest::MD5;
-use network::netconnect;
+use network::network;
use network::tools;
use mygtk2 qw(gtknew);
@@ -27,9 +27,7 @@ is_running('net_applet') and die "net_applet already running\n";
my $prog_name = "/usr/bin/net_applet";
my $current_md5 = md5file($prog_name);
-my $netcnx = {};
-my $netc = {};
-my $intf = {};
+my $net = {};
my $watched_interface;
$SIG{HUP} = sub {
@@ -72,7 +70,7 @@ my %actions = (
'confNetwork' => { name => N("Configure Network"), launch => sub { system("/usr/sbin/drakconnect --skip-wizard &") } },
'chooseInterface' => {
name => N("Watched interface"),
- choices => sub { N("Auto-detect"), sort keys %$intf },
+ choices => sub { N("Auto-detect"), sort keys %{$net->{ifcfg}} },
choice_selected => sub { $watched_interface ? $_[0] eq $watched_interface : $_[0] eq N("Auto-detect") },
launch => sub {
$watched_interface = $_[0] eq N("Auto-detect") ? undef : $_[0];
@@ -82,10 +80,10 @@ my %actions = (
'chooseProfile' => {
name => N("Profiles"),
choices => sub { network::network::netprofile_list() },
- choice_selected => sub { $_[0] eq $netc->{PROFILE} },
+ choice_selected => sub { $_[0] eq $net->{PROFILE} },
launch => sub {
- $netc->{PROFILE} = $_[0];
- network::tools::bg_command_as_root('/sbin/set-netprofile', $netc->{PROFILE});
+ $net->{PROFILE} = $_[0];
+ network::tools::bg_command_as_root('/sbin/set-netprofile', $net->{PROFILE});
}
},
'refresh' => { name => N("Refresh"), launch => sub { checkNetworkForce() } },
@@ -161,27 +159,18 @@ sub netMonitor() {
sub checkNetwork() {
my ($gw_intf, $_is_up, $gw_address) = $watched_interface ?
($watched_interface, network::tools::get_interface_status($watched_interface)) :
- network::tools::get_internet_connection($netc, $intf);
+ network::tools::get_internet_connection($net);
go2State($gw_address ? 'connected' : $gw_intf ? 'disconnected' : 'notconfigured', $gw_intf);
my $new_md5 = md5file($prog_name);
if ($new_md5 ne $current_md5) { exec($prog_name) }
}
sub checkNetworkForce() {
- $netcnx = {};
- $netc = {};
- $intf = {};
- network::netconnect::read_net_conf($netcnx, $netc, $intf);
+ $net = {};
+ network::network::read_net_conf($net);
undef $current_state;
checkNetwork();
}
-sub getIP {
- my ($interface) = shift;
- my $ifconfig = '/sbin/ifconfig';
- my @lines = `$ifconfig $interface`;
- my @ip = map { if_(/inet adr:([\d.]+)/, $1) } @lines;
- return wantarray() ? @ip : $ip[0];
-}
sub cronNetwork() {
$timeout = Glib::Timeout->add(2000, sub {
checkNetwork();
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 240a67049..9904d08b2 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -29,25 +29,22 @@ use c;
use interactive;
use ugtk2 qw(:create :helpers :wrappers);
use common;
-use network::netconnect;
+use network::network;
use network::tools;
-use MDK::Common::Globals "network", qw($in);
use POSIX;
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/net_monitor-mdk.png";
-if ("@ARGV" =~ /--status/) { print connected(); exit(0) }
+if ("@ARGV" =~ /--status/) { print network::tools::connected(); exit(0) }
my $force = "@ARGV" =~ /--force/;
my $quiet = "@ARGV" =~ /--quiet/;
my $connect = "@ARGV" =~ /--connect/;
my $disconnect = "@ARGV" =~ /--disconnect/;
my ($default_intf) = "@ARGV" =~ /--defaultintf (\w+)/;
-my $netcnx = {};
-my $netc = {};
-my $intf = {};
-network::netconnect::read_net_conf($netcnx, $netc, $intf);
-$default_intf ||= network::tools::get_default_gateway_interface($netc, $intf);
+my $net = {};
+network::network::read_net_conf($net);
+$default_intf ||= $net->{default}{interface};
if ($force) {
$connect and network::tools::start_interface($default_intf);
@@ -313,7 +310,7 @@ sub rescan() {
$monitor->{sta} = 0;
$monitor->{nba} = 0;
}
- $label_cnx_type->set_label(translate($netcnx->{type}));
+ $label_cnx_type->set_label(translate($net->{type}));
$monitor->{$_} = 0 foreach 'sr', 'st';
1;
}
@@ -461,17 +458,17 @@ sub update() {
}
@interfaces = @intfs;
if ($isconnected != -2 && $isconnected != -1 && !$during_connection) {
- if ($isconnected == 1 && !in_ifconfig($netcnx->{NET_INTERFACE})) {
+ if ($isconnected == 1 && !in_ifconfig($net->{net_interface})) {
$isconnected = 0;
$statusbar->pop(1);
$statusbar->push(1, N("Warning, another internet connection has been detected, maybe using your network"));
} else {
- #- translators : $netcnx->{type} is the type of network connection (modem, adsl...)
+ #- translators : $net->{type} is the type of network connection (modem, adsl...)
$statusbar->pop(1);
$statusbar->push(1, $isconnected == 1 ? N("Connected") : N("Not connected"));
}
$button_connect->set_sensitive(1);
- $button_connect->set("label", $isconnected == 1 ? N("Disconnect %s", translate($netcnx->{type})) : N("Connect %s", $netcnx->{type}));
+ $button_connect->set("label", $isconnected == 1 ? N("Disconnect %s", translate($net->{type})) : N("Connect %s", $net->{type}));
}
unless ($default_intf || @interfaces) {
$button_connect->set_sensitive(0);