From b8c50cf70eb80b5bcaedcaf6117549ff83bc36cd Mon Sep 17 00:00:00 2001 From: Arnaud Desmons Date: Fri, 6 Dec 2002 11:01:59 +0000 Subject: isdn data are now fetched form system instead of drakconnect conf file --- perl-install/network/adsl.pm | 4 +- perl-install/network/isdn.pm | 104 +++++++++++++++++++++++++++++-------- perl-install/network/modem.pm | 1 + perl-install/network/netconnect.pm | 76 ++++++++------------------- perl-install/network/tools.pm | 34 +++++++++--- 5 files changed, 135 insertions(+), 84 deletions(-) (limited to 'perl-install/network') diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm index b895f90fd..8a88468ab 100644 --- a/perl-install/network/adsl.pm +++ b/perl-install/network/adsl.pm @@ -86,7 +86,9 @@ sub adsl_ask_info { my ($adsl, $netc, $_intf, $adsl_type) = @_; my $pppoe_file = "/etc/ppp/pppoe.conf"; my $pppoe_conf = { getVarsFromSh($pppoe_file) } if $adsl_type =~ /pppoe/ && -f $pppoe_file; - add2hash($netc, { dnsServer2 => '', dnsServer3 => '', DOMAINNAME2 => '' }); + $pppoe_conf->{DNS1} ||= ''; + $pppoe_conf->{DNS2} ||= ''; + add2hash($netc, { dnsServer2 => $pppoe_conf->{DNS1}, dnsServer3 => $pppoe_conf->{DNS2}, DOMAINNAME2 => '' }); add2hash($adsl, { login => $pppoe_conf->{USER}, passwd => '', passwd2 => '' }); ask_info2($adsl, $netc); } diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm index a5c45d7cf..88a6fc013 100644 --- a/perl-install/network/isdn.pm +++ b/perl-install/network/isdn.pm @@ -10,27 +10,43 @@ use network::tools; use vars qw(@ISA @EXPORT); use MDK::Common::Globals "network", qw($in $prefix); use MDK::Common::File; +use Data::Dumper; @ISA = qw(Exporter); @EXPORT = qw(isdn_write_config isdn_write_config_backend get_info_providers_backend isdn_ask_info isdn_ask_protocol isdn_ask isdn_detect isdn_detect_backend isdn_get_list isdn_get_info); sub configure { - my ($netcnx, $netc) = @_; + my ($netcnx, $netc, $isdn) = @_; isdn_step_1: defined $netc->{autodetect}{isdn}{id} and goto intern_pci; $::isInstall and $in->set_help('configureNetworkISDN'); my $e = $in->ask_from_list_(N("Network Configuration Wizard"), - N("What kind is your ISDN connection?"), [ N_("Internal ISDN card"), N_("External ISDN modem") ] + N("Which ISDN configuration do you prefer? + +* The Old configuration uses isdn4net. It contains powerful + tools, but is tricky to configure, and not standard. + +* The New configuration is easier to understand, more + standard, but with less tools. + +We recommand the light configuration. +"), [ N_("New configuration (isdn-light)"), N_("Old configuration (isdn4net)") ] ) or return; + $netc->{autodetect}{isdn}{is_light} = $e =~ /light/ ? 1 : undef; + $e = $in->ask_from_list_(N("Network Configuration Wizard"), + N("What kind is your ISDN connection?"), [ N_("Internal ISDN card"), N_("External ISDN modem") ] + ) or return; + if ($e =~ /card/) { intern_pci: $netc->{isdntype} = 'isdn_internal'; - $netcnx->{isdn_internal} = {}; - $netcnx->{isdn_internal}{$_} = $netc->{autodetect}{isdn}{$_} foreach 'description', 'vendor', 'id', 'driver', 'card_type', 'type'; + $netcnx->{isdn_internal} = isdn_read_config($isdn); + $netcnx->{isdn_internal}{$_} = $netc->{autodetect}{isdn}{$_} foreach 'description', 'vendor', 'id', 'driver', 'card_type', 'type', 'is_light'; isdn_detect($netcnx->{isdn_internal}, $netc) or return; } else { $netc->{isdntype} = 'isdn_external'; - $netcnx->{isdn_external} = {}; + $netcnx->{isdn_external} = isdn_read_config($isdn); $netcnx->{isdn_external}{device} = $netc->{autodetect}{modem}; + $netcnx->{isdn_external}{is_light} = $netc->{autodetect}{isdn}{is_light}; $netcnx->{isdn_external}{special_command} = 'AT&F&O2B40'; require network::modem; network::modem::pppConfig($netcnx->{isdn_external}, undef, $netc) or goto isdn_step_1; @@ -41,19 +57,7 @@ sub configure { sub isdn_write_config { my ($isdn, $netc) = @_; isdn_write_config_step_1: - my $e = $in->ask_from_list_(N("Network Configuration Wizard"), - N("Which ISDN configuration do you prefer? - -* The Old configuration uses isdn4net. It contains powerful - tools, but is tricky to configure, and not standard. - -* The New configuration is easier to understand, more - standard, but with less tools. - -We recommand the light configuration. -"), [ N_("New configuration (isdn-light)"), N_("Old configuration (isdn4net)") ] - ) or return; - my ($rmpackage, $instpackage) = $e =~ /light/ ? ('isdn4net', 'isdn-light') : ('isdn-light', 'isdn4net'); + my ($rmpackage, $instpackage) = $isdn->{is_light} ? ('isdn4net', 'isdn-light') : ('isdn-light', 'isdn4net'); if (!$::isStandalone) { require pkgs; my $p = pkgs::packageByName($in->{packages}, $rmpackage); @@ -61,15 +65,14 @@ We recommand the light configuration. } run_program::rooted($prefix, "rpm", "-e", $rmpackage); $in->do_pkgs->install($instpackage, if_($isdn->{speed} =~ /128/, 'ibod'), 'isdn4k-utils'); - my $light = $e =~ /light/ ? 1 : 0; - isdn_write_config_backend($isdn, $light, $netc); + isdn_write_config_backend($isdn, $netc); 1; } sub isdn_write_config_backend { - my ($isdn, $light, $netc, $netcnx) = @_; + my ($isdn, $netc, $netcnx) = @_; defined $netcnx and $netc->{isdntype} = $netcnx->{type}; - if ($light) { + if ($isdn->{is_light}) { modules::mergein_conf("$prefix/etc/modules.conf"); if ($isdn->{id}) { isdn_detect_backend($isdn); @@ -146,6 +149,63 @@ defaultroute 1; } +sub isdn_read_config { + my ($isdn) = @_; + + if ($isdn->{is_light}) { + my $c = modules::read_conf("/etc/modules.conf"); + $isdn->{driver} = $c->{ippp0}{alias}; + #- 'type' 'protocol' 'mem' 'io' 'io0' 'io1' 'irq' 'id' + foreach (split(' ', $c->{$isdn->{driver}}{options})) { + /(.*)=(.*)/; + $isdn->{$1} = $2; + } + ; + foreach my $f ('ioptions1B', 'ioptions2B') { + foreach (cat_ ("$prefix/etc/ppp/$f")) { + if (/^\s*name\s*(.*)/) { + $isdn->{login} = $1; + goto NEXT; + } + } + } + NEXT : + foreach my $f ('isdn1B.conf', 'isdn2B.conf') { + foreach (cat_ ("$prefix/etc/isdn/$f")) { + /^\s*EAZ\s*=\s*(.*)/ and $isdn->{phone_in} = $1; + /^\s*PHONE_OUT\s*=\s*(.*)/ and $isdn->{phone_out} = $1; + if (/^\s*NAME\s*=\s*ippp0/ .. /PPPBIND\s*=\s*0/) { + /^\s*HUPTIMEOUT\s*=\s*(.*)/ and $isdn->{huptimeout} = $1; + } + } + } + } else { + my %match = (I4L_USERNAME => login, + I4L_LOCALMSN => phone_in, + I4L_REMOTE_OUT => phone_out, + I4L_DIALMODE => dialing_mode, + I4L_MODULE => driver, + I4L_TYPE => type, + I4L_IRQ => irq, + I4L_MEMBASE => mem, + I4L_PORT => io, + I4L_IO0 => io0, + I4L_IO1 => io1, + I4L_FIRMWARE => firmware); + foreach ('link/myisp', 'card/mycard') { + my %conf = getVarsFromSh("$prefix/etc/isdn/profile/$_"); + foreach (keys %conf) { + $isdn->{$match{"$_"}} = $conf{"$_"} if $match{$_}; + } + } + } + $isdn->{passwd} = network::tools::passwd_by_login($isdn->{login}); + #$isdn->{description} = ''; + #$isdn->{vendor} = ''; + #$isdn->{passwd2} = ''; + $isdn; +} + sub get_info_providers_backend { my ($isdn, $_netc, $name, $file) = @_; $name eq 'Unlisted - edit manually' and return; diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm index 87f042208..fd2f54c50 100644 --- a/perl-install/network/modem.pm +++ b/perl-install/network/modem.pm @@ -30,6 +30,7 @@ sub configure { foreach (@$secret) { $modem->{passwd} = $_->{passwd} if $_->{login} eq $modem->{login}; } + foreach (cat_("/etc/sysconfig/network-scripts/chat-ppp0")) { if (/.*ATDT(\d*).*/) { $modem->{phone} = $1; diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index 60ed99235..1ec7d33d7 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -178,38 +178,8 @@ If you don't want to use the auto detection, deselect the checkbox. my %conf; $conf{$_} = $netc->{autodetect}{$_} ? 1 : 0 foreach 'modem', 'winmodem', 'adsl', 'cable', 'lan'; $conf{isdn} = $netc->{autodetect}{isdn}{description} ? 1 : 0; -# my %l; -# my @l = ( -# [N("Normal modem connection"), $netc->{autodetect}{modem}, N_("detected on port %s"), \$conf{modem}], -# [N("ISDN connection"), $netc->{autodetect}{isdn}{description}, N_("detected %s"), \$conf{isdn}], -# [N("ADSL connection"), $netc->{autodetect}{adsl}, N_("detected"), \$conf{adsl}], -# [N("Cable connection"), $netc->{autodetect}{cable}, N_("cable connection detected"), \$conf{cable}], -# [N("LAN connection"), $netc->{autodetect}{lan}, N_("ethernet card(s) detected"), \$conf{lan}] -# ); -# my $i = 0; -# map { defined $set_default or do { $_->[1] and $set_default = $i }; $i++ } @l; -# my %l = ( -# 1 => [N("Normal modem connection") . if_($netc->{autodetect}{modem}, " - " . N("detected on port %s", $netc->{autodetect}{modem})), "modem"], -# 2 => [N("Winmodem connection") . if_($netc->{autodetect}{winmodem}, " - " . N("detected")), "winmodem"], -# 3 => [N("ISDN connection") . if_($netc->{autodetect}{isdn}{description}, " - " . N("detected %s", $netc->{autodetect}{isdn}{description})), "isdn"], -# 4 => [N("ADSL connection") . if_($netc->{autodetect}{adsl}, " - " . N("detected")), "adsl"], -# 5 => [N("Cable connection") . if_($netc->{autodetect}{cable}, " - " . N("cable connection detected")), "cable"], -# 6 => [N("LAN connection") . if_($netc->{autodetect}{lan}, " - " . N("ethernet card(s) detected")), "lan"] -# ); $::isInstall and $in->set_help('configureNetwork'); -# my $e = $in->ask_from(N("Network Configuration Wizard"), N("Choose the connection you want to configure"), -# [{ val => \$cnx_type, list => [sort keys %l], format => sub { $l{$_}[0] }, -# changed => sub { -# return if !$netc->{autodetection}; -# my $c = 0; -# #- $conf{adsl} and $c++; -# $conf{cable} and $c++; -# my $a = keys(%{$netc->{autodetect}{lan}}); -# 0 < $a && $a <= $c and $conf{lan} = undef; -# }}] -# ) or goto step_1; -# $conf{$l{$cnx_type}[1]} = 1; my @l = ( [N("Normal modem connection") . if_($netc->{autodetect}{modem}, " - " . N("detected on port %s", $netc->{autodetect}{modem})), \$conf{modem}], [N("Winmodem connection") . if_($netc->{autodetect}{winmodem}, " - " . N("detected")), \$conf{winmodem}], @@ -233,7 +203,7 @@ If you don't want to use the auto detection, deselect the checkbox. load_conf($netcnx, $netc, $intf); $conf{modem} and do { pre_func("modem"); require network::modem; network::modem::configure($netcnx, $mouse, $netc, $intf) or goto step_2 }; $conf{winmodem} and do { pre_func("winmodem"); require network::modem; network::modem::winmodemConfigure($netc) or goto step_2 }; - $conf{isdn} and do { pre_func("isdn"); require network::isdn; network::isdn::configure($netcnx, $netc) or goto step_2 }; + $conf{isdn} and do { pre_func("isdn"); require network::isdn; network::isdn::configure($netcnx, $netc, $isdn) or goto step_2 }; $conf{adsl} and do { pre_func("adsl"); require network::adsl; network::adsl::configure($netcnx, $netc, $intf, $first_time) or goto step_2 }; $conf{cable} and do { pre_func("cable"); require network::ethernet; network::ethernet::configure_cable($netcnx, $netc, $intf, $first_time) or goto step_2; $netconnect::need_restart_network = 1 }; $conf{lan} and do { pre_func("local network"); require network::ethernet; network::ethernet::configure_lan($netcnx, $netc, $intf, $first_time) or goto step_2; $netconnect::need_restart_network = 1 }; @@ -436,9 +406,9 @@ ADSLInterfacesList= ADSLModem=" . q( # Obsolete information. Please don't use it.) . " ADSLType=" . ($netcnx->{type} =~ /adsl/ ? $netcnx->{type} : '') . " ADSLProviderDomain=$netc->{DOMAINNAME2} -ADSLProviderDNS1=$netc->{dnsServer2} -ADSLProviderDNS2=$netc->{dnsServer3} -ADSLLogin=$adsl->{login} +".#ADSLProviderDNS1=$netc->{dnsServer2} +#ADSLProviderDNS2=$netc->{dnsServer3} +"ADSLLogin=$adsl->{login} ADSLPassword=$adsl->{passwd} DOMAINNAME2=$netc->{DOMAINNAME2}" ); @@ -533,25 +503,25 @@ sub load_conf { # /^Eth([0-9])OnBoot=(.*)\n/ && $intf->{"eth$1"}{DEVICE} and $intf->{"eth$1"}{ONBOOT} = $2; # /^Eth([0-9])Hostname=(.*)\n/ && $intf->{"eth$1"}{DEVICE} and $netc->{HOSTNAME} = $2; # /^Eth([0-9])Driver=(.*)\n/ && $intf->{"eth$1"}{DEVICE} and $intf->{"eth$1"}{driver} = $2; - /^ISDNDriver=(.*)$/ and $isdn->{driver} = $1; - /^ISDNDeviceType=(.*)$/ and $isdn->{type} = $1; - /^ISDNIrq=(.*)/ and $isdn->{irq} = $1; - /^ISDNMem=(.*)$/ and $isdn->{mem} = $1; - /^ISDNIo=(.*)$/ and $isdn->{io} = $1; - /^ISDNIo0=(.*)$/ and $isdn->{io0} = $1; - /^ISDNIo1=(.*)$/ and $isdn->{io1} = $1; - /^ISDNProtocol=(.*)$/ and $isdn->{protocol} = $1; - /^ISDNCardDescription=(.*)$/ and $isdn->{description} = $1; - /^ISDNCardVendor=(.*)$/ and $isdn->{vendor} = $1; - /^ISDNId=(.*)$/ and $isdn->{id} = $1; - /^ISDNProviderPhone=(.*)$/ and $isdn->{phone_out} = $1; - /^ISDNDialing=(.*)$/ and $isdn->{dialing_mode} = $1; - /^ISDNISDNSpeed=(.*)$/ and $isdn->{speed} = $1; - /^ISDNTimeout=(.*)$/ and $isdn->{huptimeout} = $1; - /^ISDNHomePhone=(.*)$/ and $isdn->{phone_in} = $1; - /^ISDNLogin=(.*)$/ and $isdn->{login} = $1; - /^ISDNPassword=(.*)$/ and $isdn->{passwd} = $1; - /^ISDNConfirmPassword=(.*)$/ and $isdn->{passwd2} = $1; +# /^ISDNDriver=(.*)$/ and $isdn->{driver} = $1; +# /^ISDNDeviceType=(.*)$/ and $isdn->{type} = $1; +# /^ISDNIrq=(.*)/ and $isdn->{irq} = $1; +# /^ISDNMem=(.*)$/ and $isdn->{mem} = $1; +# /^ISDNIo=(.*)$/ and $isdn->{io} = $1; +# /^ISDNIo0=(.*)$/ and $isdn->{io0} = $1; +# /^ISDNIo1=(.*)$/ and $isdn->{io1} = $1; +# /^ISDNProtocol=(.*)$/ and $isdn->{protocol} = $1; +# /^ISDNCardDescription=(.*)$/ and $isdn->{description} = $1; +# /^ISDNCardVendor=(.*)$/ and $isdn->{vendor} = $1; +# /^ISDNId=(.*)$/ and $isdn->{id} = $1; +# /^ISDNProviderPhone=(.*)$/ and $isdn->{phone_out} = $1; +# /^ISDNDialing=(.*)$/ and $isdn->{dialing_mode} = $1; +# /^ISDNISDNSpeed=(.*)$/ and $isdn->{speed} = $1; +# /^ISDNTimeout=(.*)$/ and $isdn->{huptimeout} = $1; +# /^ISDNHomePhone=(.*)$/ and $isdn->{phone_in} = $1; +# /^ISDNLogin=(.*)$/ and $isdn->{login} = $1; +# /^ISDNPassword=(.*)$/ and $isdn->{passwd} = $1; +# /^ISDNConfirmPassword=(.*)$/ and $isdn->{passwd2} = $1; #/^PPPDevice=(.*)$/ and $modem->{device} = $1; /^PPPConnectionName=(.*)$/ and $modem->{connection} = $1; # Keep this for futur multiple cnx support diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index c86f9de4c..b654e87f1 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -8,7 +8,7 @@ use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_pro use MDK::Common::System qw(getVarsFromSh); @ISA = qw(Exporter); -@EXPORT = qw(write_cnx_script write_secret_backend write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected connected_bg test_connected connected2 disconnected); +@EXPORT = qw(write_cnx_script write_secret_backend read_secret_backend passwd_by_login write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected connected_bg test_connected connected2 disconnected); @EXPORT_OK = qw($in); sub write_cnx_script { @@ -33,21 +33,39 @@ sub write_secret_backend { } } +sub unquotify { + my ($word) = @_; + ($a, $b, $c) = $$word =~ /"(.*)"|'(.*)'|(.*)/; + $$word = $a ? $a : $b ? $b : $c; +} + sub read_secret_backend { my $conf; foreach my $i ("pap-secrets", "chap-secrets") { foreach (cat_("$prefix/etc/ppp/$i")) { my ($login, $server, $passwd) = split(' '); - my ($a, $b, $c) = $passwd =~ /"(.*)"|'(.*)'|(.*)/; - $passwd = $a ? $a : $b ? $b : $c; - push @$conf, {login => $login, - passwd => $passwd, - server => $server }; + if ($login && $passwd) { + unquotify \$passwd; + unquotify \$login; + unquotify \$server; + push @$conf, {login => $login, + passwd => $passwd, + server => $server }; + } } } $conf; } +sub passwd_by_login { + my ($login) = @_; + + unquotify \$login; + my $secret = read_secret_backend(); + foreach (@$secret) { + return $_->{passwd} if ($_->{login} eq $login); + } +} sub ask_connect_now { my ($type) = @_; @@ -68,8 +86,8 @@ sub ask_connect_now { $up = connected(); } my $m = $up ? N("The system is now connected to Internet.") . - if_($::isInstall, N("For security reason, it will be disconnected now.")) : - N("The system doesn't seem to be connected to internet. + if_($::isInstall, N("For security reason, it will be disconnected now.")) : + N("The system doesn't seem to be connected to internet. Try to reconfigure your connection."); if ($::isWizard) { $::Wizard_no_previous = 1; -- cgit v1.2.1