summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-05-26 11:35:10 +0000
committerOlivier Blin <oblin@mandriva.org>2005-05-26 11:35:10 +0000
commitcdf2d31b82ac6571a6e937a576f266c68fe224d7 (patch)
tree1d9fbb5a26d28f4afe5c15a93b2f95541f990947 /perl-install
parent4ce49518550d25b5fbedaedc56d671deaf61560f (diff)
downloaddrakx-cdf2d31b82ac6571a6e937a576f266c68fe224d7.tar
drakx-cdf2d31b82ac6571a6e937a576f266c68fe224d7.tar.gz
drakx-cdf2d31b82ac6571a6e937a576f266c68fe224d7.tar.bz2
drakx-cdf2d31b82ac6571a6e937a576f266c68fe224d7.tar.xz
drakx-cdf2d31b82ac6571a6e937a576f266c68fe224d7.zip
better way to handle squid ports (read shorewall REDIRECT rules in network::shorewall::read to avoid tricks in network::shorewall::write)
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/network/shorewall.pm13
-rwxr-xr-xperl-install/standalone/drakgw30
2 files changed, 22 insertions, 21 deletions
diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm
index e6c96e897..d1e908700 100644
--- a/perl-install/network/shorewall.pm
+++ b/perl-install/network/shorewall.pm
@@ -83,12 +83,14 @@ sub read_default_interfaces {
sub read {
my ($o_in) = @_;
+ my @rules = get_config_file('rules');
my %conf = (disabled => !glob_("$::prefix/etc/rc3.d/S*shorewall"),
ports => join(' ', map {
my $e = $_;
map { "$_/$e->[3]" } split(',', $e->[4]);
- } grep { $_->[0] eq 'ACCEPT' && $_->[1] eq 'net' } get_config_file('rules'))
+ } grep { $_->[0] eq 'ACCEPT' && $_->[1] eq 'net' } @rules),
);
+ $conf{redirects}{$_->[3]}{$_->[2]} = $_->[4] foreach grep { $_->[0] eq 'REDIRECT' } @rules;
if (my ($e) = get_config_file('masq')) {
$conf{masquerade}{subnet} = $e->[1] if $e->[1];
@@ -101,7 +103,6 @@ sub write {
my ($conf) = @_;
my $default_intf = get_ifcfg_interface();
my $use_pptp = $default_intf =~ /^ppp/ && cat_("$::prefix/etc/ppp/peers/$default_intf") =~ /pptp/;
- my $squid_port = network::squid::read_squid_conf()->{http_port}[0];
my %ports_by_proto;
foreach (split ' ', $conf->{ports}) {
@@ -129,12 +130,10 @@ sub write {
(map {
map_each { [ 'ACCEPT', $_, 'fw', $::a, join(',', @$::b), '-' ] } %ports_by_proto;
} ('net', if_($conf->{loc_interface}[0], 'loc'))),
+ (map {
+ map_each { [ 'REDIRECT', 'loc', $::a, $_, $::b, '-' ] } %{$conf->{redirects}{$_}};
+ } keys %{$conf->{redirects}}),
);
- if (cat_("/etc/shorewall/rules") !~ /^\s*REDIRECT\s*loc\s*$squid_port\s+(\S+)/mg && $squid_port && -f "/var/run/squid.pid" && grep { /Loc/i } cat_("/etc/shorewall/zones")) {
- substInFile {
- s/#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/REDIRECT\tloc\t$squid_port\ttcp\twww\t-\nACCEPT\tfw\tnet\ttcp\twww\n#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/;
- } "/etc/shorewall/rules";
-}
set_config_file('masq', if_($conf->{masquerade}, [ $conf->{net_interface}, $conf->{masquerade}{subnet} ]));
services::set_status('shorewall', !$conf->{disabled}, $::isInstall);
diff --git a/perl-install/standalone/drakgw b/perl-install/standalone/drakgw
index 109bbcac4..4a74914b2 100755
--- a/perl-install/standalone/drakgw
+++ b/perl-install/standalone/drakgw
@@ -279,6 +279,11 @@ If you do not know the meaning of an option, simply leave it as it is."),
post => sub {
network::squid::write_squid_conf($squid_conf, $lan_intf, $internal_domain_name) if $use_caching_proxy;
services::set_status("squid", $use_caching_proxy);
+ if ($use_caching_proxy) {
+ set_proxy_port($squid_conf->{http_port}[0]);
+ } else {
+ delete_proxy_ports();
+ }
-f $cups_conf ? "cups" : end_step();
},
},
@@ -350,26 +355,25 @@ sub end_step() {
"end";
}
-sub proxy_enable() {
- substInFile {
- s/#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/REDIRECT\tloc\t$squid_conf->{http_port}[0]\ttcp\twww\t-\nACCEPT\tfw\tnet\ttcp\twww\n#LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE/;
- } $rules_file;
+sub delete_proxy_ports() {
+ my $r = $shorewall->{redirects}{tcp};
+ use Data::Dumper;
+ my @ports = grep { $r->{$_} eq 'www' } keys %$r;
+ print Dumper($r, \@ports);
+ delete $r->{$_} foreach @ports;
}
-sub proxy_disable() {
- substInFile {
- s/REDIRECT\tmasq\t$squid_conf->{http_port}[0]\ttcp\twww\t\-\n//;
- s/REDIRECT\tloc\t$squid_conf->{http_port}[0]\ttcp\twww\t\-\n//;
- s/ACCEPT\tfw\tnet\ttcp\twww\n//;
- } $rules_file;
+sub set_proxy_port {
+ my ($port) = @_;
+ $shorewall->{redirects}{tcp}{$port} = 'www';
}
-
sub gw_disable() {
my $_wait_disabl = $in->wait_message('', N("Disabling servers..."));
return if $::testing;
services::set_status($_, 0) foreach qw(dhcpd squid named);
- proxy_disable();
+ delete_proxy_ports();
+ network::shorewall::write($shorewall);
foreach ($network::dhcpd::dhcpd_conf_file, $network::squid::squid_conf_file, $masq_file) {
if (-f $_) { rename($_, "$_.drakgwdisable") or die "Could not rename $_ to $_.drakgwdisable" }
}
@@ -398,8 +402,6 @@ sub gw_configure() {
log::explanations("Enabling IPV4 forwarding");
substInFile { s/^FORWARD_IPV4.*\n//; $_ .= "FORWARD_IPV4=true\n" if eof } $sysconf_network if !$::testing;
services::restart("network");
-
- proxy_enable();
}
sub update_cups() {