diff options
Diffstat (limited to 'lib/network')
-rw-r--r-- | lib/network/connection/cellular.pm | 4 | ||||
-rw-r--r-- | lib/network/connection/cellular_card.pm | 12 | ||||
-rw-r--r-- | lib/network/connection/ethernet.pm | 9 | ||||
-rw-r--r-- | lib/network/connection/isdn.pm | 1 | ||||
-rw-r--r-- | lib/network/connection/ppp.pm | 9 | ||||
-rw-r--r-- | lib/network/connection/wireless.pm | 4 | ||||
-rw-r--r-- | lib/network/connection_manager.pm | 20 | ||||
-rw-r--r-- | lib/network/drakfirewall.pm | 2 | ||||
-rwxr-xr-x | lib/network/drakroam.pm | 6 | ||||
-rw-r--r-- | lib/network/ifw.pm | 2 | ||||
-rw-r--r-- | lib/network/ipsec.pm | 3 | ||||
-rw-r--r-- | lib/network/monitor.pm | 2 | ||||
-rw-r--r-- | lib/network/ndiswrapper.pm | 4 | ||||
-rwxr-xr-x | lib/network/netcenter.pm | 6 | ||||
-rw-r--r-- | lib/network/netconnect.pm | 6 | ||||
-rw-r--r-- | lib/network/network.pm | 71 | ||||
-rw-r--r-- | lib/network/nfs.pm | 22 | ||||
-rw-r--r-- | lib/network/shorewall.pm | 4 | ||||
-rw-r--r-- | lib/network/vpn/openvpn.pm | 2 |
19 files changed, 88 insertions, 101 deletions
diff --git a/lib/network/connection/cellular.pm b/lib/network/connection/cellular.pm index 5bb2259..3084480 100644 --- a/lib/network/connection/cellular.pm +++ b/lib/network/connection/cellular.pm @@ -16,7 +16,7 @@ sub get_providers { # filtering out CDMA-only providers which we do not support for now my %providers = ( %network::connection::providers::cellular::data, - grep_each{!$::b->{cdma} } %network::connection::providers::cellular_extra::data + grep_each { !$::b->{cdma} } %network::connection::providers::cellular_extra::data ); (\%providers, '|'); } @@ -48,7 +48,7 @@ sub write_cellular_settings { sub guess_apn_from_chat { my ($self) = @_; my $chat = cat_($::prefix . $self->get_chat_file); - my $chat_apn = $chat =~ /\bAT\+CGDCONT=\d+,"IP","([^"]+)"/ && $1; + $chat =~ /\bAT\+CGDCONT=\d+,"IP","([^"]+)"/ && $1; } sub guess_provider_settings { diff --git a/lib/network/connection/cellular_card.pm b/lib/network/connection/cellular_card.pm index 0fc3fbf..c68b3a2 100644 --- a/lib/network/connection/cellular_card.pm +++ b/lib/network/connection/cellular_card.pm @@ -68,11 +68,11 @@ sub get_tty_device { my %udev_env = map { if_(/^([^=]*)=(.*)$/, $1 => $2) } chomp_(run_program::get_stdout("udevadm info --query=property --path=$self->{device}{sysfs_device}")); if ($udev_env{USB_MODEM_INTERFACE}) { - my $dev_sys_path = $self->{device}->{sysfs_device}; + my $dev_sys_path = $self->{device}{sysfs_device}; my $cfg = chomp_(cat_($dev_sys_path . "/bConfigurationValue")); my $tty_usb = basename(glob_("$dev_sys_path/" . - $self->{device}->{pci_bus} . "-" . - ($self->{device}->{usb_port} + 1) . ":$cfg." . + $self->{device}{pci_bus} . "-" . + ($self->{device}{usb_port} + 1) . ":$cfg." . $udev_env{USB_MODEM_INTERFACE} . "/ttyUSB*")); if ($tty_usb) { $tty_usb =~ s/ttyUSB//; @@ -81,8 +81,8 @@ sub get_tty_device { } else { # if no usb interface for tty port given, use first one my @intfs = glob_("$self->{device}->{sysfs_device}/" . - $self->{device}->{pci_bus} . "-" . - ($self->{device}->{usb_port} + 1) . ":*"); + $self->{device}{pci_bus} . "-" . + ($self->{device}{usb_port} + 1) . ":*"); foreach (@intfs) { my $tty_usb = basename(glob_("$_/tty*")); if ($tty_usb) { @@ -108,7 +108,7 @@ sub get_control_device { my ($self) = @_; my $tty_device = $self->get_tty_device; if ($tty_device eq "/dev/ttyUSB0") { - for my $id (2, 1) { + foreach my $id (2, 1) { my $usb_control_device = "/dev/ttyUSB" . $id; return $usb_control_device if -e $usb_control_device; } diff --git a/lib/network/connection/ethernet.pm b/lib/network/connection/ethernet.pm index 7b76396..c2f9718 100644 --- a/lib/network/connection/ethernet.pm +++ b/lib/network/connection/ethernet.pm @@ -188,7 +188,7 @@ sub check_address_settings { return 0; } #- test if IP address is already used - if (my $conflict = find { text2bool($_->{ONBOOT}) && $_->{DEVICE} ne $self->get_interface && $_->{IPADDR} eq $self->{address}{ip_address} } values %{$net->{ifcfg}} ) { + if (my $conflict = find { text2bool($_->{ONBOOT}) && $_->{DEVICE} ne $self->get_interface && $_->{IPADDR} eq $self->{address}{ip_address} } values %{$net->{ifcfg}}) { # find out what connection we are conflicting with my $conflict_device = $conflict->{DEVICE}; @@ -216,14 +216,14 @@ sub get_hostname_settings { my ($self) = @_; my $auto_hostname = sub { $self->{protocol} eq 'dhcp' && $self->{address}{needhostname} }; # configure the default hostname so the hostname setting should be more obvious to the users - $self->{address}{hostname} = 'localhost.localdomain' unless $self->{address}{hostname}; + $self->{address}{hostname} ||= 'localhost.localdomain'; [ if_($self->{protocol} eq 'dhcp', { text => N("Assign host name from DHCP server (or generate a unique one)"), val => \$self->{address}{needhostname}, type => "bool", - help => N("This will allow the server to attribute a name for this machine. If the server does not provides a valid host name, it will be generated automatically.")}, + help => N("This will allow the server to attribute a name for this machine. If the server does not provides a valid host name, it will be generated automatically.") }, ), { label => N("Host name"), val => \$self->{address}{hostname}, disabled => $auto_hostname, - help => N("You should define a hostname for this machine, which will identify this PC. Note that this hostname will be shared among all network connections. If left blank, 'localhost.localdomain' will be used.")}, + help => N("You should define a hostname for this machine, which will identify this PC. Note that this hostname will be shared among all network connections. If left blank, 'localhost.localdomain' will be used.") }, ]; } @@ -508,7 +508,6 @@ sub update_iftab() { } sub update_udev_net_config() { - my $lib = arch() =~ /x86_64/ ? "lib64" : "lib"; my $net_name_helper = "/lib/udev/write_net_rules"; my $udev_net_config = "$::prefix/etc/udev/rules.d/70-persistent-net.rules"; my @old_config = cat_($udev_net_config); diff --git a/lib/network/connection/isdn.pm b/lib/network/connection/isdn.pm index 1b8debc..7187aed 100644 --- a/lib/network/connection/isdn.pm +++ b/lib/network/connection/isdn.pm @@ -23,6 +23,7 @@ use run_program; use log; use network::tools; use services; +use network::connection::isdn::consts; # for @isdndata sub apply_config { my ($in, $isdn) = @_; diff --git a/lib/network/connection/ppp.pm b/lib/network/connection/ppp.pm index 287d7bb..277971f 100644 --- a/lib/network/connection/ppp.pm +++ b/lib/network/connection/ppp.pm @@ -5,15 +5,6 @@ use common; use base qw(network::connection); -my %authentication_methods = ( - script => N_("Script-based"), - pap => N_("PAP"), - terminal_ => N_("Terminal-based"), - chap => N_("CHAP"), - pap_chap => N_("PAP/CHAP"), -); - -my @kppp_authentication_methods = qw(script pap terminal chap pap_chap); my @secrets_files = qw(pap-secrets chap-secrets); sub get_access_settings { diff --git a/lib/network/connection/wireless.pm b/lib/network/connection/wireless.pm index 4f86f17..89d57dd 100644 --- a/lib/network/connection/wireless.pm +++ b/lib/network/connection/wireless.pm @@ -388,7 +388,7 @@ sub load_interface_settings { $self->{hide_passwords} = 1; # override ifcfg with network-specific settings if available my $network = $self->get_selected_network; - $self->{ifcfg}= $network ? + $self->{ifcfg} = $network ? get_network_ifcfg($network->{ap}) || get_network_ifcfg($network->{essid}) : $self->{ifcfg}; @@ -970,7 +970,7 @@ sub wpa_supplicant_read_conf() { if ($network) { #- in a "network = {}" block # value is either the string with "quotes" - or a full-length string - if (/^\s*(\w+)=\s*(?|([^"].*)|("[^"]*")).*$/) { + if (/^\s*(\w+)=\s*(?|([^"].*)|("[^"]*"))/) { $network->{$1} = $2; } elsif (/^\}/) { #- end of network block diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm index 3efb2c1..3bbac97 100644 --- a/lib/network/connection_manager.pm +++ b/lib/network/connection_manager.pm @@ -81,7 +81,7 @@ sub setup_connection { auto_window_size => 1, }, $cmanager->{connection}->get_hardware_settings) or return; if ($cmanager->{connection}->can("check_hardware_settings") && !$cmanager->{connection}->check_hardware_settings) { - $cmanager->{in}->ask_warn(N("Error"), $cmanager->{connection}->{hardware}{error}); + $cmanager->{in}->ask_warn(N("Error"), $cmanager->{connection}{hardware}{error}); return; } } @@ -225,7 +225,7 @@ sub start_connection { } undef; }); - }; + } } sub stop_connection { @@ -293,31 +293,31 @@ sub create_networks_list { }); $cmanager->{gui}{networks_list}->set_has_tooltip(1); $cmanager->{gui}{networks_list}->get_column(1)->set_sort_column_id(1); - $cmanager->{gui}{networks_list}->get_model->set_sort_func (1, sub { + $cmanager->{gui}{networks_list}->get_model->set_sort_func(1, sub { my ($sortable, $iter_left, $iter_right) = @_; my $s1 = $sortable->get($iter_left, 2); my $s2 = $sortable->get($iter_right, 2); return $s1 cmp $s2; }); $cmanager->{gui}{networks_list}->get_column(2)->set_sort_column_id(2); - $cmanager->{gui}{networks_list}->get_model->set_sort_func (2, sub { + $cmanager->{gui}{networks_list}->get_model->set_sort_func(2, sub { my ($sortable, $iter_left, $iter_right) = @_; - my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}->{signal_strength}; - my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}->{signal_strength}; + my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}{signal_strength}; + my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}{signal_strength}; return $s1 <=> $s2; }); $cmanager->{gui}{networks_list}->get_column(3)->set_sort_column_id(3); - $cmanager->{gui}{networks_list}->get_model->set_sort_func (3, sub { + $cmanager->{gui}{networks_list}->get_model->set_sort_func(3, sub { my ($sortable, $iter_left, $iter_right) = @_; - my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}->{flags}; - my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}->{flags}; + my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}{flags}; + my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}{flags}; #FIXME Should define an explicit order OPEN < WEP < WPA return $s1 cmp $s2; }); $cmanager->{gui}{networks_list}->set_enable_search(1); $cmanager->{gui}{networks_list}->set_search_column(1); $cmanager->{gui}{networks_list}->set_search_equal_func(sub { - my ($model, $column, $key, $iter, $data) = @_; + my ($model, $_column, $key, $iter) = @_; return $model->get($iter, 2) !~ /^\Q$key/i; }); # Sort by signal level by default diff --git a/lib/network/drakfirewall.pm b/lib/network/drakfirewall.pm index 9c5f0f5..6ce6b13 100644 --- a/lib/network/drakfirewall.pm +++ b/lib/network/drakfirewall.pm @@ -57,7 +57,7 @@ my @all_servers = pkg => 'nfs-utils nfs-utils-clients', ports => '111/tcp 111/udp 2049/tcp 2049/udp ' . network::nfs::list_nfs_ports(), hide => 1, - prepare => sub { network::nfs::write_nfs_ports(network::nfs::read_nfs_ports()); }, + prepare => sub { network::nfs::write_nfs_ports(network::nfs::read_nfs_ports()) }, restart => 'nfs-common nfs-server', }, { diff --git a/lib/network/drakroam.pm b/lib/network/drakroam.pm index 9ff8189..f6c28d0 100755 --- a/lib/network/drakroam.pm +++ b/lib/network/drakroam.pm @@ -41,7 +41,7 @@ sub select_connection { my ($droam) = @_; $droam->set_connection(get_connection($droam)); - $droam->check_setup || $droam->setup_connection if $droam->{connection}; + $droam->check_setup or $droam->setup_connection if $droam->{connection}; update_on_connection_change($droam); } @@ -54,7 +54,7 @@ sub update_on_connection_change { } sub create_drakroam_gui { - my ($droam, $dbus, $title, $icon) = @_; + my ($droam, $_dbus, $title, $icon) = @_; $droam->{gui}{model} = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String'); $droam->{gui}{connections_combo} = Gtk2::ComboBox->new($droam->{gui}{model}); @@ -77,7 +77,7 @@ sub create_drakroam_gui { Glib::Timeout->add(20000, sub { $status_bar->remove($status_bar_cid, $m_id); 0 }); }; - (undef, my $rootwin_height) = gtkroot()->get_size(); + (undef, my $rootwin_height) = gtkroot()->get_size; my $scrolled_height = $rootwin_height > 480 ? 300 : 225; gtkadd($droam->{gui}{w}{window}, gtknew('VBox', spacing => 5, children => [ diff --git a/lib/network/ifw.pm b/lib/network/ifw.pm index 2509b93..94ea851 100644 --- a/lib/network/ifw.pm +++ b/lib/network/ifw.pm @@ -113,7 +113,7 @@ sub resolve_address { eval { local $SIG{ALRM} = sub { die "ALARM" }; alarm 2; - $hostname = gethostbyaddr(inet_aton($ip_addr), AF_INET); + $hostname = gethostbyaddr(inet_aton($ip_addr), Socket::AF_INET); alarm 0; }; $hostname || $ip_addr; diff --git a/lib/network/ipsec.pm b/lib/network/ipsec.pm index 846b07a..bf30b3d 100644 --- a/lib/network/ipsec.pm +++ b/lib/network/ipsec.pm @@ -465,10 +465,7 @@ sub read_ipsec_conf { my ($ipsec_conf) = @_; my %conf; my $nb = 0; #total number - my $i = 0; #nb within a connexion my $in_a_conn = "n"; - my $line = ""; - my @line1; local $_; my @mylist; my $myline = ""; diff --git a/lib/network/monitor.pm b/lib/network/monitor.pm index d8fb258..b1dc9ac 100644 --- a/lib/network/monitor.pm +++ b/lib/network/monitor.pm @@ -28,7 +28,7 @@ sub list_wireless { if (!$has_roaming && !$>) { $results = `$::prefix/usr/sbin/wpa_cli scan_results 2>/dev/null`; $list = `$::prefix/usr/sbin/wpa_cli list_networks 2>/dev/null`; - $_ =~ s/^Selected interface (.*)\n//g foreach $results, $list; + s/^Selected interface (.*)\n//g foreach $results, $list; } if ($results && $list) { #- bssid / frequency / signal level / flags / ssid diff --git a/lib/network/ndiswrapper.pm b/lib/network/ndiswrapper.pm index 22af6d6..d626770 100644 --- a/lib/network/ndiswrapper.pm +++ b/lib/network/ndiswrapper.pm @@ -79,7 +79,7 @@ sub find_matching_devices { #- add original driver push @devices, { interface => undef, drivers => [ $device->{driver} ] } - if !$is_driver_listed->($device->{driver}) && any { $_ eq $device->{driver} } modules::loaded_modules(); + if !$is_driver_listed->($device->{driver}) && member($device->{driver}, modules::loaded_modules()); @devices; } @@ -101,7 +101,7 @@ sub setup_device { my @conflicts = find_conflicting_devices($device); if (@conflicts) { $in->ask_yesorno(N("Warning"), N("The selected device has already been configured with the %s driver. -Do you really want to use a ndiswrapper driver?", $conflicts[0]->{drivers}[0])) or return; +Do you really want to use a ndiswrapper driver?", $conflicts[0]{drivers}[0])) or return; #- stop old interfaces network::tools::stop_interface($_->{interface}, 0) foreach grep { defined $_->{interface} } @conflicts; #- unload old modules before trying to load ndiswrapper diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm index 10d156d..fa65a33 100755 --- a/lib/network/netcenter.pm +++ b/lib/network/netcenter.pm @@ -51,7 +51,7 @@ sub build_cmanager_box { ($cmanager->{connection}->can('get_networks') ? ( $cmanager->{gui}{show_unique_network} ? ( $cmanager->{gui}{networks_list}, - ): ( + ) : ( gtknew('Label', text => N("Please select your network:"), alignment => [ 0, 0 ]), gtknew('ScrolledWindow', height => 160, child => $cmanager->{gui}{networks_list}) ), @@ -168,7 +168,7 @@ sub main { gtkadd($w->{window}, gtknew('VBox', spacing => 5, children => [ $::isEmbedded ? () : (0, Gtk2::Banner->new($icon, $title)), - if_($net->{PROFILE} && network::network::netprofile_count() > 0, 0, gtknew('Label', text_markup => N("You are currently using the network profile <b>%s</b>", $net->{PROFILE})) ), + if_($net->{PROFILE} && network::network::netprofile_count() > 0, 0, gtknew('Label', text_markup => N("You are currently using the network profile <b>%s</b>", $net->{PROFILE}))), 1, gtknew('ScrolledWindow', width => 600, height => $scrolled_height, shadow_type => 'none', child => $managers_box = gtknew('VBox', spacing => 5, children_tight => [ map_index { build_cmanager_box($_, $::i == 0) } @cmanagers, @@ -195,7 +195,7 @@ sub main { push @connections, $connection; push @cmanagers, $cmanager; my $box = build_cmanager_box($cmanager, @connections == 0); - $managers_box ->add($box); + $managers_box->add($box); $box->show_all; } $cmanager->{parent_box}->show; diff --git a/lib/network/netconnect.pm b/lib/network/netconnect.pm index abe94c7..adb048a 100644 --- a/lib/network/netconnect.pm +++ b/lib/network/netconnect.pm @@ -124,7 +124,7 @@ sub real_main { welcome => { pre => sub { undef $net->{type} }, if_(!$::isInstall, no_back => 1), - name => N("Choose the connection you want to configure") . if_($net->{PROFILE} && network::network::netprofile_count() > 0, "\n".N("Those settings will be saved for the network profile <b>%s</b>", $net->{PROFILE}) ), + name => N("Choose the connection you want to configure") . if_($net->{PROFILE} && network::network::netprofile_count() > 0, "\n" . N("Those settings will be saved for the network profile <b>%s</b>", $net->{PROFILE})), if_(!$::isInstall, interactive_help_id => 'configureNetwork'), data => [ { list => [ network::connection::get_types ], type => 'list', val => \$net->{type}, format => sub { $_[0] && $_[0]->get_type_description }, @@ -148,7 +148,7 @@ sub real_main { select_connection => { name => sub { $net->{type}->get_type_name . "\n\n" . N("Select the network interface to configure:") }, data => [ { val => \$connection, type => 'list', list => \@connections_list, - format => sub { $_[0] && N("%s: %s", $_[0]->get_interface, $_[0]->get_description) }, allow_empty_list => !text2bool($global_settings{AUTOMATIC_IFACE_CHOICE})} ], + format => sub { $_[0] && N("%s: %s", $_[0]->get_interface, $_[0]->get_description) }, allow_empty_list => !text2bool($global_settings{AUTOMATIC_IFACE_CHOICE}) } ], complete => sub { $connection->setup_thirdparty($in) or return 1; $connection->prepare_device; @@ -322,7 +322,7 @@ If you do not know it, keep the preselected protocol.") }, sleep 1; } } - $success = $connection->get_status(); + $success = $connection->get_status; # try to resolve the network address for some time my $timeout = 3; while ($timeout--) { 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($>); diff --git a/lib/network/nfs.pm b/lib/network/nfs.pm index 93df7ab..fb716ed 100644 --- a/lib/network/nfs.pm +++ b/lib/network/nfs.pm @@ -3,25 +3,25 @@ package network::nfs; use strict; use common; -sub read_nfs_ports { +sub read_nfs_ports() { my $statd_port = 4001; - my $statd_outgoing_port = undef; + my $statd_outgoing_port; my $lockd_tcp_port = 4002; my $lockd_udp_port = 4002; my $rpc_mountd_port = 4003; my $rpc_rquotad_port = 4004; if (-f "$::prefix/etc/sysconfig/nfs-common") { foreach (cat_("$::prefix/etc/sysconfig/nfs-common")) { - $_ =~ /^STATD_OPTIONS=.*(--port|-p) (\d+).*$/ and $statd_port = $2; - $_ =~ /^STATD_OPTIONS=.*(--outgoing-port|-o) (\d+).*$/ and $statd_outgoing_port = $2; - $_ =~ /^LOCKD_TCPPORT=(\d+)/ and $lockd_tcp_port = $1; - $_ =~ /^LOCKD_UDPPORT=(\d+)/ and $lockd_udp_port = $1; + /^STATD_OPTIONS=.*(--port|-p) (\d+)/ and $statd_port = $2; + /^STATD_OPTIONS=.*(--outgoing-port|-o) (\d+)/ and $statd_outgoing_port = $2; + /^LOCKD_TCPPORT=(\d+)/ and $lockd_tcp_port = $1; + /^LOCKD_UDPPORT=(\d+)/ and $lockd_udp_port = $1; } } if (-f "$::prefix/etc/sysconfig/nfs-server") { foreach (cat_("$::prefix/etc/sysconfig/nfs-server")) { - $_ =~ /^RPCMOUNTD_OPTIONS=.*(--port|-p) (\d+).*$/ and $rpc_mountd_port = $2; - $_ =~ /^RPCRQUOTAD_OPTIONS=.*(--port|-p) (\d+).*$/ and $rpc_rquotad_port = $2; + /^RPCMOUNTD_OPTIONS=.*(--port|-p) (\d+)/ and $rpc_mountd_port = $2; + /^RPCRQUOTAD_OPTIONS=.*(--port|-p) (\d+)/ and $rpc_rquotad_port = $2; } } @@ -37,11 +37,11 @@ sub read_nfs_ports { $ports; } -sub list_nfs_ports { +sub list_nfs_ports() { my $ports = read_nfs_ports(); - my $portlist = $ports->{lockd_tcp_port}. "/tcp " . $ports->{lockd_udp_port} . "/udp"; - if (defined $ports->{statd_outgoing_port} and $ports->{statd_outgoing_port} ne $ports->{statd_port}) { + my $portlist = $ports->{lockd_tcp_port} . "/tcp " . $ports->{lockd_udp_port} . "/udp"; + if (defined $ports->{statd_outgoing_port} && $ports->{statd_outgoing_port} ne $ports->{statd_port}) { $portlist .= " " . $ports->{statd_outgoing_port} . "/tcp " . $ports->{statd_outgoing_port} . "/udp"; } foreach (qw(statd_port rpc_mountd_port rpc_rquotad_port)) { diff --git a/lib/network/shorewall.pm b/lib/network/shorewall.pm index 83442ba..49cf01a 100644 --- a/lib/network/shorewall.pm +++ b/lib/network/shorewall.pm @@ -29,7 +29,7 @@ sub set_config_file { $done = 1; } else { $_ = '' unless - /^#/ or $file eq 'rules' && /^SECTION/; + /^#/ || $file eq 'rules' && /^SECTION/; } } "$::prefix${shorewall_root}/$file"; } @@ -206,7 +206,7 @@ What do you want to do?"), if_($use_pptp, [ 'ACCEPT', 'fw', 'loc:10.0.0.138', 'gre' ]), (map_each { [ 'ACCEPT', 'net', 'fw', $::a, join(',', @$::b), '-' ] } %$ports_by_proto), (map_each { - if_($::b, map { [ 'ACCEPT+', 'fw', 'net', 'tcp', $::a, '-', '-', '-', $_ ] } @{$::b}); + if_($::b, map { [ 'ACCEPT+', 'fw', 'net', 'tcp', $::a, '-', '-', '-', $_ ] } @$::b); } %{$conf->{accept_local_users}}), (map { my $proto = $_; diff --git a/lib/network/vpn/openvpn.pm b/lib/network/vpn/openvpn.pm index 68e1b3f..05f68f3 100644 --- a/lib/network/vpn/openvpn.pm +++ b/lib/network/vpn/openvpn.pm @@ -294,7 +294,7 @@ sub cache_pkcs11_tokens { } } } - foreach $slot_id (keys %{$pkcs11_tokens->{slots}}) { + foreach my $slot_id (keys %{$pkcs11_tokens->{slots}}) { my ($type, $label); my @stdout; #- do rooted_get_stdout manually because pkcs11-tool may exit with non-zero code with proprietary modules run_program::rooted($::prefix, '/usr/bin/pkcs11-tool', '>', \@stdout, '--module', $openvpn_default_pkcs11_provider, '-O', '--slot', $slot_id); |