summaryrefslogtreecommitdiffstats
path: root/lib/network/network.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/network/network.pm')
-rw-r--r--lib/network/network.pm71
1 files changed, 35 insertions, 36 deletions
diff --git a/lib/network/network.pm b/lib/network/network.pm
index 1f7e79f..62824d8 100644
--- a/lib/network/network.pm
+++ b/lib/network/network.pm
@@ -248,21 +248,21 @@ sub add2hosts {
my $file = "$::prefix/etc/hosts";
my @l;
- push(@l, [$_, $hostname, if_($sub_hostname, $sub_hostname)]) foreach(@ips);
+ push @l, [ $_, $hostname, if_($sub_hostname, $sub_hostname) ] foreach @ips;
foreach (cat_($file)) {
# strip our own comments
- next if ($_ =~ /# generated by drak.*/);
+ next if /# generated by drak/;
my ($ip, $aliases) = /^\s*(\S+)\s+(\S+.*)$/ or next;
my @hosts = difference2([ split /\s+/, $aliases ], [ $hostname, $sub_hostname ]);
if (@hosts) {
- push (@l, [$ip, @hosts]);
+ push @l, [ $ip, @hosts ];
}
- };
+ }
log::explanations("writing host information to $file");
output($file, "# generated by drakconnect\n");
foreach (@l) {
- append_to_file($file, join(" ", @{$_}) . "\n");
+ append_to_file($file, join(" ", @$_) . "\n");
}
}
@@ -409,13 +409,13 @@ sub gateway {
sub netprofile_modules() {
my @m = split('\n', `/sbin/netprofile modules`);
- my @modules = ();
+ my @modules;
foreach my $module (@m) {
my @params = split('\t', $module);
my $vals = {
module => @params[0],
- enabled => @params[1] eq '+' ? 1 : 0,
+ enabled => $params[1] eq '+' ? 1 : 0,
name => @params[2],
description => @params[3],
};
@@ -466,26 +466,26 @@ sub netprofile_read {
$net->{PROFILE} = $profile || 'default';
}
-sub advanced_settings_read {
+sub advanced_settings_read() {
my $modprobe = "$::prefix/etc/modprobe.conf";
my $sysctl = "$::prefix/etc/sysctl.conf";
my $msecconf = "$::prefix/etc/security/msec/security.conf";
- my $ipv6_disabled = grep { /^options ipv6 disable=1$/ } cat_($modprobe);
- my $disable_window_scaling = grep { /^net\.ipv4\.tcp_window_scaling\s*=\s*0$/ } cat_($sysctl);
- my $disable_tcp_timestamps = grep { /^net\.ipv4\.tcp_timestamps\s*=\s*0$/ } cat_($sysctl);
- my $log_martians = grep { /^net\.ipv4\.conf\.all\.log_martians\s*=\s*1$/ } cat_($sysctl);
- my $disable_icmp = grep { /^net\.ipv4\.icmp_echo_ignore_all\s*=\s*1$/ } cat_($sysctl);
- my $disable_icmp_broadcasts = grep { /^net\.ipv4\.icmp_echo_ignore_broadcasts\s*=\s*1$/ } cat_($sysctl);
- my $disable_bogus_error_responses = grep { /^net\.ipv4\.icmp_ignore_bogus_error_responses\s*=\s*1$/ } cat_($sysctl);
- my $msec = grep { /^BASE_LEVEL=/ } cat_($msecconf);
+ my $ipv6_disabled = find { /^options ipv6 disable=1$/ } cat_($modprobe);
+ my $disable_window_scaling = find { /^net\.ipv4\.tcp_window_scaling\s*=\s*0$/ } cat_($sysctl);
+ my $disable_tcp_timestamps = find { /^net\.ipv4\.tcp_timestamps\s*=\s*0$/ } cat_($sysctl);
+ my $log_martians = find { /^net\.ipv4\.conf\.all\.log_martians\s*=\s*1$/ } cat_($sysctl);
+ my $disable_icmp = find { /^net\.ipv4\.icmp_echo_ignore_all\s*=\s*1$/ } cat_($sysctl);
+ my $disable_icmp_broadcasts = find { /^net\.ipv4\.icmp_echo_ignore_broadcasts\s*=\s*1$/ } cat_($sysctl);
+ my $disable_bogus_error_responses = find { /^net\.ipv4\.icmp_ignore_bogus_error_responses\s*=\s*1$/ } cat_($sysctl);
+ my $msec = find { /^BASE_LEVEL=/ } cat_($msecconf);
{ ipv6_disabled => $ipv6_disabled, disable_window_scaling => $disable_window_scaling,
disable_tcp_timestamps => $disable_tcp_timestamps, log_martians => $log_martians,
disable_icmp => $disable_icmp, disable_icmp_broadcasts => $disable_icmp_broadcasts,
disable_bogus_error_responses => $disable_bogus_error_responses,
msec => $msec,
- }
+ };
}
sub advanced_settings_write {
@@ -493,22 +493,22 @@ sub advanced_settings_write {
# ipv6
substInFile {
/^(options ipv6 .*|install ipv6 .*|alias net-pf-10 off)/ and $_="";
- if (eof and $u->{ipv6_disabled}) {
+ if (eof && $u->{ipv6_disabled}) {
$_ .= "options ipv6 disable=1\n";
}
} "$::prefix/etc/modprobe.conf";
# sysctl
substInFile {
# remove old entries
- /^net\.ipv4\.(tcp_window_scaling|tcp_timestamps|conf\.all\.log_martians|icmp_echo_ignore_all|icmp_echo_ignore_broadcasts|icmp_ignore_bogus_error_responses).*/ and $_="";
+ /^net\.ipv4\.(tcp_window_scaling|tcp_timestamps|conf\.all\.log_martians|icmp_echo_ignore_all|icmp_echo_ignore_broadcasts|icmp_ignore_bogus_error_responses)/ and $_="";
if (eof) {
# add new values
- my $window_scaling = ($u->{disable_window_scaling}) ? "0" : "1";
- my $tcp_timestamps = ($u->{disable_tcp_timestamps}) ? "0" : "1";
- my $log_martians = ($u->{log_martians}) ? "1" : "0"; # this is inversed property
- my $disable_icmp = ($u->{disable_icmp}) ? "1" : "0"; # this is inversed property
- my $disable_icmp_broadcasts = ($u->{disable_icmp_broadcasts}) ? "1" : "0"; # this is inversed property
- my $disable_bogus_error_responses = ($u->{disable_bogus_error_responses}) ? "1" : "0"; # this is inversed property
+ my $window_scaling = $u->{disable_window_scaling} ? "0" : "1";
+ my $tcp_timestamps = $u->{disable_tcp_timestamps} ? "0" : "1";
+ my $log_martians = $u->{log_martians} ? "1" : "0"; # this is inversed property
+ my $disable_icmp = $u->{disable_icmp} ? "1" : "0"; # this is inversed property
+ my $disable_icmp_broadcasts = $u->{disable_icmp_broadcasts} ? "1" : "0"; # this is inversed property
+ my $disable_bogus_error_responses = $u->{disable_bogus_error_responses} ? "1" : "0"; # this is inversed property
$_ .= "net.ipv4.tcp_window_scaling=$window_scaling\n";
$_ .= "net.ipv4.tcp_timestamps=$tcp_timestamps\n";
$_ .= "net.ipv4.conf.all.log_martians=$log_martians\n";
@@ -522,20 +522,19 @@ sub advanced_settings_write {
sub advanced_choose {
my ($in, $net, $u) = @_;
- my $use_http_for_https = $u->{https_proxy} eq $u->{http_proxy};
$in->ask_from(N("Advanced network settings"),
N("Here you can configure advanced network settings. Please note that you have to reboot the machine for changes to take effect."),
[
{ label => N("Wireless regulatory domain"), val => \$net->{network}{CRDA_DOMAIN}, sort => 1, list => \@crda_domains },
- { label => "<b>".N("TCP/IP settings")."</b>"},
+ { label => "<b>" . N("TCP/IP settings") . "</b>" },
{ text => N("Disable IPv6"), val => \$u->{ipv6_disabled}, type => "bool" },
- { text => N("Disable TCP Window Scaling"), val => \$u->{disable_window_scaling}, type => "bool"},
- { text => N("Disable TCP Timestamps"), val => \$u->{disable_tcp_timestamps}, type => "bool"},
- { label => "<b>".N("Security settings (defined by MSEC policy)")."</b>"},
- { text => N("Disable ICMP echo"), val => \$u->{disable_icmp}, type => "bool", disabled => sub { $u->{msec} }},
- { text => N("Disable ICMP echo for broadcasting messages"), val => \$u->{disable_icmp_broadcasts}, type => "bool", disabled => sub { $u->{msec} }},
- { text => N("Disable invalid ICMP error responses"), val => \$u->{disable_bogus_error_responses}, type => "bool", disabled => sub { $u->{msec} }},
- { text => N("Log strange packets"), val => \$u->{log_martians}, type => "bool", disabled => sub { $u->{msec} }},
+ { text => N("Disable TCP Window Scaling"), val => \$u->{disable_window_scaling}, type => "bool" },
+ { text => N("Disable TCP Timestamps"), val => \$u->{disable_tcp_timestamps}, type => "bool" },
+ { label => "<b>" . N("Security settings (defined by MSEC policy)") . "</b>" },
+ { text => N("Disable ICMP echo"), val => \$u->{disable_icmp}, type => "bool", disabled => sub { $u->{msec} } },
+ { text => N("Disable ICMP echo for broadcasting messages"), val => \$u->{disable_icmp_broadcasts}, type => "bool", disabled => sub { $u->{msec} } },
+ { text => N("Disable invalid ICMP error responses"), val => \$u->{disable_bogus_error_responses}, type => "bool", disabled => sub { $u->{msec} } },
+ { text => N("Log strange packets"), val => \$u->{log_martians}, type => "bool", disabled => sub { $u->{msec} } },
]
) or return;
1;
@@ -549,7 +548,7 @@ sub miscellaneous_choose {
my $use_http_for_https = $u->{https_proxy} eq $u->{http_proxy};
$in->ask_from(N("Proxies configuration"),
- N("Here you can set up your proxies configuration (eg: http://my_caching_server:8080)") . if_($net->{PROFILE} && netprofile_count() > 0, "\n".N("Those settings will be saved for the network profile <b>%s</b>", $net->{PROFILE})),
+ N("Here you can set up your proxies configuration (eg: http://my_caching_server:8080)") . if_($net->{PROFILE} && netprofile_count() > 0, "\n" . N("Those settings will be saved for the network profile <b>%s</b>", $net->{PROFILE})),
[ { label => N("HTTP proxy"), val => \$u->{http_proxy} },
{ text => N("Use HTTP proxy for HTTPS connections"), val => \$use_http_for_https, type => "bool" },
{ label => N("HTTPS proxy"), val => \$u->{https_proxy}, disabled => sub { $use_http_for_https } },
@@ -719,7 +718,7 @@ sub proxy_configure {
proxy_configure_mozilla_firefox($proxy);
}
-sub detect_crda_domain {
+sub detect_crda_domain() {
my $crda = { getVarsFromSh($::prefix . $network_file) }->{CRDA_DOMAIN};
if (!$crda) {
my $locale = lang::read($>);