From fbbcf8129f8c931cea1279ea5589bd657155be4f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 24 Mar 2005 09:59:47 +0000 Subject: - network::shorewall::default_interfaces_silent() does not need any parameter - network::shorewall::read() is simpler with a $o_in - network::drakfirewall::default_from_pkgs() is non interactive, better give it a do_pkgs - cleanup as little as possible --- perl-install/install_steps_interactive.pm | 2 +- perl-install/network/drakfirewall.pm | 15 +++++++-------- perl-install/network/shorewall.pm | 18 +++++++----------- perl-install/standalone/drakgw | 2 +- perl-install/standalone/drakvpn | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) (limited to 'perl-install') diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index c0b1b2d98..9b5fb997e 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -1096,7 +1096,7 @@ sub summary { label => N("Firewall"), val => sub { require network::shorewall; - my $shorewall = network::shorewall::read($o, 'silent'); + my $shorewall = network::shorewall::read(); $shorewall && !$shorewall->{disabled} ? N("activated") : N("disabled"); }, clicked => sub { diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm index b09342752..554f6298f 100644 --- a/perl-install/network/drakfirewall.pm +++ b/perl-install/network/drakfirewall.pm @@ -110,8 +110,8 @@ sub from_ports { } sub default_from_pkgs { - my ($in) = @_; - my @pkgs = $in->do_pkgs->are_installed(map { split ' ', $_->{pkg} } @all_servers); + my ($do_pkgs) = @_; + my @pkgs = $do_pkgs->are_installed(map { split ' ', $_->{pkg} } @all_servers); [ grep { my $s = $_; exists $s->{force_default_selection} ? @@ -120,15 +120,14 @@ sub default_from_pkgs { } @all_servers ]; } -sub get_ports { - my ($in, $_ports) = @_; - my $shorewall = network::shorewall::read($in, 'silent') or return; +sub get_ports() { + my $shorewall = network::shorewall::read() or return; \$shorewall->{ports}; } sub set_ports { my ($in, $disabled, $ports) = @_; - my $shorewall = network::shorewall::read($in, 'not_silent') || network::shorewall::default_interfaces($in) or die N("No network card"); + my $shorewall = network::shorewall::read($in) || network::shorewall::default_interfaces($in) or die N("No network card"); if (!$disabled || -x "$::prefix/sbin/shorewall") { $in->do_pkgs->ensure_binary_is_installed('shorewall', 'shorewall', $::isInstall) or return; @@ -141,12 +140,12 @@ sub set_ports { sub get_conf { my ($in, $disabled, $o_ports) = @_; - my $possible_servers = default_from_pkgs($in); + my $possible_servers = default_from_pkgs($in->do_pkgs); $_->{hide} = 0 foreach @$possible_servers; if ($o_ports) { $disabled, from_ports($o_ports); - } elsif (my $shorewall = network::shorewall::read($in, 'silent')) { + } elsif (my $shorewall = network::shorewall::read()) { $shorewall->{disabled}, from_ports(\$shorewall->{ports}); } else { $in->ask_okcancel('', N("drakfirewall configurator diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm index 563914578..eb3a4e045 100644 --- a/perl-install/network/shorewall.pm +++ b/perl-install/network/shorewall.pm @@ -61,11 +61,10 @@ sub get_net_device() { $default_dev; } -sub default_interfaces_silent { - my ($_in) = @_; - my %conf; - my @l = detect_devices::getNet() or return; - if (@l == 1) { +sub default_interfaces_silent() { + my %conf; + my @l = detect_devices::getNet() or return; + if (@l == 1) { $conf{net_interface} = $l[0]; } else { $conf{net_interface} = get_net_device() || $l[0]; @@ -103,7 +102,7 @@ Examples: } sub read { - my ($in, $mode) = @_; + my ($o_in) = @_; my %conf = (disabled => !glob_("$::prefix/etc/rc3.d/S*shorewall"), ports => join(' ', map { my $e = $_; @@ -114,11 +113,8 @@ sub read { if (my ($e) = get_config_file('masq')) { $conf{masquerade}{subnet} = $e->[1] if $e->[1]; } - if ($mode eq 'silent') { - put_in_hash(\%conf, default_interfaces_silent($in)); - } else { - put_in_hash(\%conf, default_interfaces($in)); - } + put_in_hash(\%conf, $o_in ? default_interfaces($o_in) : default_interfaces_silent()); + $conf{net_interface} && \%conf; } diff --git a/perl-install/standalone/drakgw b/perl-install/standalone/drakgw index 11c982fd5..7f23e964c 100755 --- a/perl-install/standalone/drakgw +++ b/perl-install/standalone/drakgw @@ -53,7 +53,7 @@ my $squid_port = network::network::read_squid_conf()->{http_port}[0] ||= "3128"; my $cups_conf = "/etc/cups/cupsd.conf"; my $in = 'interactive'->vnew('su'); -my $shorewall = network::shorewall::read($in, 'silent'); +my $shorewall = network::shorewall::read(); $::Wizard_title = N("Internet Connection Sharing"); diff --git a/perl-install/standalone/drakvpn b/perl-install/standalone/drakvpn index 7ad344465..a43411055 100644 --- a/perl-install/standalone/drakvpn +++ b/perl-install/standalone/drakvpn @@ -57,7 +57,7 @@ my $proc_version = ""; my $ipsec_package = ""; my $in = interactive->vnew('su'); -my $shorewall = network::shorewall::read($in, 'silent'); +my $shorewall = network::shorewall::read(); my @section_names; if ($kernel_version > 2.5) { -- cgit v1.2.1