summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/any.pm170
-rw-r--r--perl-install/network/ethernet.pm2
-rw-r--r--perl-install/network/isdn.pm2
-rw-r--r--perl-install/network/modem.pm177
-rw-r--r--perl-install/network/network.pm36
-rwxr-xr-xperl-install/standalone/drakconnect5
-rwxr-xr-xperl-install/standalone/drakproxy7
7 files changed, 200 insertions, 199 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 92bda10f8..578d7c465 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -426,176 +426,6 @@ sub inspect {
$h;
}
-#-----modem conf
-sub pppConfig {
- my ($in, $modem, $prefix) = @_;
- $modem or return;
-
- devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
- $in->do_pkgs->install('ppp') if !$::testing;
-
- my %toreplace;
- $toreplace{$_} = $modem->{$_} foreach qw(connection phone login passwd auth domain dns1 dns2);
- $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, }}{$modem->{auth}};
- $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, 'CHAP' => 3 }}{$modem->{auth}};
- $toreplace{phone} =~ s/[a-zA-Z]//g;
- $toreplace{dnsserver} = join ',', map { $modem->{$_} } "dns1", "dns2";
- $toreplace{dnsserver} .= $toreplace{dnsserver} && ',';
-
- #- using peerdns or dns1,dns2 avoid writing a /etc/resolv.conf file.
- $toreplace{peerdns} = "yes";
-
- $toreplace{connection} ||= 'DialupConnection';
- $toreplace{domain} ||= 'localdomain';
- $toreplace{intf} ||= 'ppp0';
- $toreplace{papname} = ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') && $toreplace{login};
-
- #- build ifcfg-ppp0.
- my $various = <<END;
-DEVICE="$toreplace{intf}"
-ONBOOT="no"
-USERCTL="no"
-MODEMPORT="/dev/modem"
-LINESPEED="115200"
-PERSIST="yes"
-DEFABORT="yes"
-DEBUG="yes"
-INITSTRING="ATZ"
-DEFROUTE="yes"
-HARDFLOWCTL="yes"
-ESCAPECHARS="no"
-PPPOPTIONS=""
-PAPNAME="$toreplace{papname}"
-REMIP=""
-NETMASK=""
-IPADDR=""
-MRU=""
-MTU=""
-DISCONNECTTIMEOUT="5"
-RETRYTIMEOUT="60"
-BOOTPROTO="none"
-PEERDNS="$toreplace{peerdns}"
-END
- output("$prefix/etc/sysconfig/network-scripts/ifcfg-ppp0",
- $various,
- map { qq(DNS$_=$toreplace{"dns$_"}\n) } grep { $toreplace{"dns$_"} } 1..2);
-
- #- build chat-ppp0.
- my @chat = <<END;
-'ABORT' 'BUSY'
-'ABORT' 'ERROR'
-'ABORT' 'NO CARRIER'
-'ABORT' 'NO DIALTONE'
-'ABORT' 'Invalid Login'
-'ABORT' 'Login incorrect'
-'' 'ATZ'
-END
- if ($modem->{special_command}) {
- push @chat, <<END;
-'OK' '$modem->{special_command}'
-END
- }
- push @chat, <<END;
-'OK' 'ATDT$toreplace{phone}'
-'CONNECT' ''
-END
- if ($modem->{auth} eq 'Terminal-based' || $modem->{auth} eq 'Script-based') {
- push @chat, <<END;
-'ogin:--ogin:' '$toreplace{login}'
-'ord:' '$toreplace{passwd}'
-END
- }
- push @chat, <<END;
-'TIMEOUT' '5'
-'~--' ''
-END
- my $chat_file = "$prefix/etc/sysconfig/network-scripts/chat-ppp0";
- output_with_perm($chat_file, 0600, @chat);
-
- if ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') {
- #- need to create a secrets file for the connection.
- my $secrets = "$prefix/etc/ppp/" . lc($modem->{auth}) . "-secrets";
- my @l = cat_($secrets);
- my $replaced = 0;
- do { $replaced ||= 1
- if s/^\s*"?$toreplace{login}"?\s+ppp0\s+(\S+)/"$toreplace{login}" ppp0 "$toreplace{passwd}"/ } foreach @l;
- if ($replaced) {
- output($secrets, @l);
- } else {
- append_to_file($secrets, "$toreplace{login} ppp0 \"$toreplace{passwd}\"\n");
- }
- #- restore access right to secrets file, just in case.
- chmod 0600, $secrets;
- }
-
- #- install kppprc file according to used configuration.
- mkdir_p("$prefix/usr/share/config");
-
- output("$prefix/usr/share/config/kppprc", c::to_utf8(<<END));
-# KDE Config File
-[Account0]
-ExDNSDisabled=0
-AutoName=0
-ScriptArguments=
-AccountingEnabled=0
-DialString=ATDT
-Phonenumber=$toreplace{phone}
-IPAddr=0.0.0.0
-Domain=$toreplace{domain}
-Name=$toreplace{connection}
-VolumeAccountingEnabled=0
-pppdArguments=
-Password=$toreplace{passwd}
-BeforeDisconnect=
-Command=
-ScriptCommands=
-Authentication=$toreplace{kpppauth}
-DNS=$toreplace{dnsserver}
-SubnetMask=0.0.0.0
-AccountingFile=
-DefaultRoute=1
-Username=$toreplace{login}
-Gateway=0.0.0.0
-StorePassword=1
-DisconnectCommand=
-[Modem]
-BusyWait=0
-Enter=CR
-FlowControl=CRTSCTS
-Volume=0
-Timeout=60
-UseCDLine=0
-UseLockFile=1
-Device=/dev/modem
-Speed=115200
-[Graph]
-InBytes=0,0,255
-Text=0,0,0
-Background=255,255,255
-Enabled=true
-OutBytes=255,0,0
-[General]
-QuitOnDisconnect=0
-ShowLogWindow=0
-DisconnectOnXServerExit=1
-DefaultAccount=$toreplace{connection}
-iconifyOnConnect=1
-Hint_QuickHelp=0
-AutomaticRedial=0
-PPPDebug=0
-NumberOfAccounts=1
-ShowClock=1
-DockIntoPanel=0
-pppdTimeout=30
-END
- miscellaneousNetwork();
-}
-
-sub miscellaneousNetwork {
- setExportedVarsInSh( "$::prefix/etc/profile.d/proxy.sh", $::o->{miscellaneous}, qw(http_proxy ftp_proxy));
- setExportedVarsInCsh("$::prefix/etc/profile.d/proxy.csh", $::o->{miscellaneous}, qw(http_proxy ftp_proxy));
-}
-
sub load_category {
my ($in, $category, $auto, $at_least_one) = @_;
diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm
index 410b81e13..f9d97e00c 100644
--- a/perl-install/network/ethernet.pm
+++ b/perl-install/network/ethernet.pm
@@ -207,7 +207,7 @@ such as ``mybox.mylab.myco.com''."),
} else {
configureNetworkNet($in, $netc, $last ||= {}, @l) or goto configureNetwork_step_1;
}
- miscellaneousNetwork($in) or goto configureNetwork_step_1;
+ network::network::miscellaneous_choose($in, $::o->{miscellaneous} ||= {}) or goto configureNetwork_step_1;
1;
}
diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm
index 2b747e255..8f7319bf9 100644
--- a/perl-install/network/isdn.pm
+++ b/perl-install/network/isdn.pm
@@ -48,7 +48,7 @@ We recommand the light configuration.
$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;
+ network::modem::ppp_choose($netc, $netcnx->{isdn_external}) or goto isdn_step_1;
}
1;
}
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index fd2f54c50..4a339565e 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -6,13 +6,9 @@ use modules;
use detect_devices;
use mouse;
use network::tools;
-use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix);
use Data::Dumper;
-@ISA = qw(Exporter);
-@EXPORT = qw(pppConfig);
-
sub configure {
my ($netcnx, $mouse, $netc, $intf) = @_;
$netcnx->{type} = 'modem';
@@ -37,7 +33,7 @@ sub configure {
last;
}
}
- pppConfig($modem, $mouse, $netc, $intf) or return;
+ ppp_choose($netc, $modem, $mouse) or return;
write_cnx_script($netc, "modem",
q(
/sbin/route del default
@@ -49,8 +45,173 @@ killall pppd
1;
}
-sub pppConfig {
- my ($modem, $mouse, $netc, $_intf) = @_;
+#-----modem conf
+sub ppp_configure {
+ my ($in, $modem, $prefix) = @_;
+ $modem or return;
+
+ any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
+ $in->do_pkgs->install('ppp') if !$::testing;
+
+ my %toreplace;
+ $toreplace{$_} = $modem->{$_} foreach qw(connection phone login passwd auth domain dns1 dns2);
+ $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, }}{$modem->{auth}};
+ $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, 'CHAP' => 3 }}{$modem->{auth}};
+ $toreplace{phone} =~ s/[a-zA-Z]//g;
+ $toreplace{dnsserver} = join ',', map { $modem->{$_} } "dns1", "dns2";
+ $toreplace{dnsserver} .= $toreplace{dnsserver} && ',';
+
+ #- using peerdns or dns1,dns2 avoid writing a /etc/resolv.conf file.
+ $toreplace{peerdns} = "yes";
+
+ $toreplace{connection} ||= 'DialupConnection';
+ $toreplace{domain} ||= 'localdomain';
+ $toreplace{intf} ||= 'ppp0';
+ $toreplace{papname} = ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') && $toreplace{login};
+
+ #- build ifcfg-ppp0.
+ my $various = <<END;
+DEVICE="$toreplace{intf}"
+ONBOOT="no"
+USERCTL="no"
+MODEMPORT="/dev/modem"
+LINESPEED="115200"
+PERSIST="yes"
+DEFABORT="yes"
+DEBUG="yes"
+INITSTRING="ATZ"
+DEFROUTE="yes"
+HARDFLOWCTL="yes"
+ESCAPECHARS="no"
+PPPOPTIONS=""
+PAPNAME="$toreplace{papname}"
+REMIP=""
+NETMASK=""
+IPADDR=""
+MRU=""
+MTU=""
+DISCONNECTTIMEOUT="5"
+RETRYTIMEOUT="60"
+BOOTPROTO="none"
+PEERDNS="$toreplace{peerdns}"
+END
+ output("$prefix/etc/sysconfig/network-scripts/ifcfg-ppp0",
+ $various,
+ map { qq(DNS$_=$toreplace{"dns$_"}\n) } grep { $toreplace{"dns$_"} } 1..2);
+
+ #- build chat-ppp0.
+ my @chat = <<END;
+'ABORT' 'BUSY'
+'ABORT' 'ERROR'
+'ABORT' 'NO CARRIER'
+'ABORT' 'NO DIALTONE'
+'ABORT' 'Invalid Login'
+'ABORT' 'Login incorrect'
+'' 'ATZ'
+END
+ if ($modem->{special_command}) {
+ push @chat, <<END;
+'OK' '$modem->{special_command}'
+END
+ }
+ push @chat, <<END;
+'OK' 'ATDT$toreplace{phone}'
+'CONNECT' ''
+END
+ if ($modem->{auth} eq 'Terminal-based' || $modem->{auth} eq 'Script-based') {
+ push @chat, <<END;
+'ogin:--ogin:' '$toreplace{login}'
+'ord:' '$toreplace{passwd}'
+END
+ }
+ push @chat, <<END;
+'TIMEOUT' '5'
+'~--' ''
+END
+ my $chat_file = "$prefix/etc/sysconfig/network-scripts/chat-ppp0";
+ output_with_perm($chat_file, 0600, @chat);
+
+ if ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') {
+ #- need to create a secrets file for the connection.
+ my $secrets = "$prefix/etc/ppp/" . lc($modem->{auth}) . "-secrets";
+ my @l = cat_($secrets);
+ my $replaced = 0;
+ do { $replaced ||= 1
+ if s/^\s*"?$toreplace{login}"?\s+ppp0\s+(\S+)/"$toreplace{login}" ppp0 "$toreplace{passwd}"/ } foreach @l;
+ if ($replaced) {
+ output($secrets, @l);
+ } else {
+ append_to_file($secrets, "$toreplace{login} ppp0 \"$toreplace{passwd}\"\n");
+ }
+ #- restore access right to secrets file, just in case.
+ chmod 0600, $secrets;
+ }
+
+ #- install kppprc file according to used configuration.
+ mkdir_p("$prefix/usr/share/config");
+
+ output("$prefix/usr/share/config/kppprc", c::to_utf8(<<END));
+# KDE Config File
+[Account0]
+ExDNSDisabled=0
+AutoName=0
+ScriptArguments=
+AccountingEnabled=0
+DialString=ATDT
+Phonenumber=$toreplace{phone}
+IPAddr=0.0.0.0
+Domain=$toreplace{domain}
+Name=$toreplace{connection}
+VolumeAccountingEnabled=0
+pppdArguments=
+Password=$toreplace{passwd}
+BeforeDisconnect=
+Command=
+ScriptCommands=
+Authentication=$toreplace{kpppauth}
+DNS=$toreplace{dnsserver}
+SubnetMask=0.0.0.0
+AccountingFile=
+DefaultRoute=1
+Username=$toreplace{login}
+Gateway=0.0.0.0
+StorePassword=1
+DisconnectCommand=
+[Modem]
+BusyWait=0
+Enter=CR
+FlowControl=CRTSCTS
+Volume=0
+Timeout=60
+UseCDLine=0
+UseLockFile=1
+Device=/dev/modem
+Speed=115200
+[Graph]
+InBytes=0,0,255
+Text=0,0,0
+Background=255,255,255
+Enabled=true
+OutBytes=255,0,0
+[General]
+QuitOnDisconnect=0
+ShowLogWindow=0
+DisconnectOnXServerExit=1
+DefaultAccount=$toreplace{connection}
+iconifyOnConnect=1
+Hint_QuickHelp=0
+AutomaticRedial=0
+PPPDebug=0
+NumberOfAccounts=1
+ShowClock=1
+DockIntoPanel=0
+pppdTimeout=30
+END
+ network::network::proxy_configure($::o->{miscellaneous});
+}
+
+sub ppp_choose {
+ my ($netc, $modem, $mouse) = @_;
$mouse ||= {};
$mouse->{device} ||= readlink "$prefix/dev/mouse";
@@ -76,7 +237,7 @@ sub pppConfig {
{ label => N("Second DNS Server (optional)"), val => \$modem->{dns2} },
]) or return;
$netc->{DOMAINNAME2} = $modem->{domain};
- any::pppConfig($in, $modem, $prefix);
+ ppp_configure($in, $modem, $prefix);
$netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
1;
}
diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm
index 12085f636..888630b3d 100644
--- a/perl-install/network/network.pm
+++ b/perl-install/network/network.pm
@@ -13,7 +13,7 @@ use log;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
-@EXPORT = qw(resolv configureNetworkIntf netmask dns is_ip masked_ip findIntf addDefaultRoute write_interface_conf read_all_conf dnsServers guessHostname configureNetworkNet read_resolv_conf read_interface_conf add2hosts gateway configureNetwork2 write_conf sethostname miscellaneousNetwork down_it read_conf write_resolv_conf up_it);
+@EXPORT = qw(resolv configureNetworkIntf netmask dns is_ip masked_ip findIntf addDefaultRoute read_all_conf dnsServers guessHostname configureNetworkNet read_resolv_conf read_interface_conf add2hosts gateway configureNetwork2 write_conf sethostname down_it read_conf write_resolv_conf up_it);
#-######################################################################################
#- Functions
@@ -121,17 +121,20 @@ sub write_resolv_conf {
sub write_interface_conf {
my ($file, $intf, $prefix) = @_;
+ if ($::o->{miscellaneous}{track_network_id} && -e "$prefix/sbin/ip") {
+ $intf->{HWADDR} = undef;
+ if (my $s = `LC_ALL= LANG= $prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`) {
+ if ($s =~ m|.*link/ether\s([0-9a-z:]+)\s|) {
+ $intf->{HWADDR} = $1;
+ }
+ }
+ }
my @ip = split '\.', $intf->{IPADDR};
my @mask = split '\.', $intf->{NETMASK};
- my $hwaddr;
- $::o->{miscellaneous}{track_network_id} and $hwaddr = -e "$prefix/sbin/ip" && `LC_ALL= LANG= $prefix/sbin/ip -o link show $intf->{DEVICE} 2>/dev/null`;
- if ($hwaddr) { chomp $hwaddr; $hwaddr =~ s/.*link\/ether\s([0-9a-z:]+)\s.*/$1/ }
- $hwaddr and $intf->{HWADDR} = undef;
add2hash($intf, {
BROADCAST => join('.', mapn { int($_[0]) | ((~int($_[1])) & 255) } \@ip, \@mask),
NETWORK => join('.', mapn { int($_[0]) & $_[1] } \@ip, \@mask),
ONBOOT => bool2yesno(!member($intf->{DEVICE}, map { $_->{device} } detect_devices::probeall())),
- if_($::o->{miscellaneous}{track_network_id}, HWADDR => $hwaddr)
});
setVarsInSh($file, $intf, qw(DEVICE BOOTPROTO IPADDR NETMASK NETWORK BROADCAST ONBOOT HWADDR), if_($intf->{wireless_eth}, qw(WIRELESS_MODE WIRELESS_ESSID WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_ENC_KEY WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY WIRELESS_IWPRIV)));
}
@@ -372,12 +375,13 @@ You may also enter the IP address of the gateway if you have one"),
);
}
-sub miscellaneousNetwork {
- my ($in, $clicked, $no_track_net) = @_;
- my $u = $::o->{miscellaneous} ||= {};
- $::isInstall and $in->set_help('configureNetworkProxy');
+sub miscellaneous_choose {
+ my ($in, $u, $clicked, $no_track_net) = @_;
+ $in->set_help('configureNetworkProxy') if $::isInstall;
+
$u->{track_network_id} = detect_devices::isLaptop();
- $::expert || $clicked and ($in->ask_from('',
+
+ $in->ask_from('',
N("Proxies configuration"),
[ { label => N("HTTP proxy"), val => \$u->{http_proxy} },
{ label => N("FTP proxy"), val => \$u->{ftp_proxy} },
@@ -388,10 +392,16 @@ sub miscellaneousNetwork {
$u->{ftp_proxy} =~ m,^($|ftp://|http://), or $in->ask_warn('', N("Url should begin with 'ftp:' or 'http:'")), return 1,1;
0;
}
- ) or return);
+ ) or return if $::expert || $clicked;
1;
}
+sub proxy_configure {
+ my ($u) = @_;
+ setExportedVarsInSh( "$::prefix/etc/profile.d/proxy.sh", $u, qw(http_proxy ftp_proxy));
+ setExportedVarsInCsh("$::prefix/etc/profile.d/proxy.csh", $u, qw(http_proxy ftp_proxy));
+}
+
sub read_all_conf {
my ($prefix, $netc, $intf) = @_;
$netc ||= {}; $intf ||= {};
@@ -447,7 +457,7 @@ sub configureNetwork2 {
}
#-res_init(); #- reinit the resolver so DNS changes take affect
- any::miscellaneousNetwork();
+ proxy_configure($::o->{miscellaneous});
}
diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect
index d428bcae6..a54775f02 100755
--- a/perl-install/standalone/drakconnect
+++ b/perl-install/standalone/drakconnect
@@ -27,6 +27,7 @@ use common;
use network::netconnect;
use network::ethernet;
use network::tools;
+use network::modem;
use network;
use c;
use any;
@@ -341,9 +342,9 @@ sub apply {
$old_profile = $netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default";
network::netconnect::save_conf($netcnx, $netc, $intf);
- $netcnx->{type} eq 'modem' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
+ $netcnx->{type} eq 'modem' and network::modem::ppp_configure($in, $netcnx->{$netcnx->{type}}, '');
$netcnx->{type} eq 'isdn_internal' and network::isdn::isdn_write_config_backend($netcnx->{$netcnx->{type}}, 1, $netc, $netcnx); #$light
- $netcnx->{type} eq 'isdn_external' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
+ $netcnx->{type} eq 'isdn_external' and network::modem::ppp_configure($in, $netcnx->{$netcnx->{type}}, '');
my $a = $netcnx->{type};
$a =~ s/adsl_//;
$netcnx->{type} =~ /adsl/ and network::adsl::adsl_conf_backend($netcnx->{$netcnx->{type}}, $netc, $a, $netcnx);
diff --git a/perl-install/standalone/drakproxy b/perl-install/standalone/drakproxy
index f09d86199..0b50f23d2 100755
--- a/perl-install/standalone/drakproxy
+++ b/perl-install/standalone/drakproxy
@@ -25,9 +25,8 @@ use interactive;
use network::network;
use any;
-$::o->{miscellaneous} ||= {};
-$::o->{miscellaneous} = { getVarsFromSh('/etc/profile.d/proxy.sh') };
+my $u = { getVarsFromSh('/etc/profile.d/proxy.sh') };
my $in = 'interactive'->vnew('su', 'network');
-network::network::miscellaneousNetwork($in, 1, 1);
-any::miscellaneousNetwork('');
+network::network::miscellaneous_choose($in, $u, 1, 1);
+network::network::proxy_configure($u);
$in->exit(0);