Compare commits

...

13 Commits

Author SHA1 Message Date
Tom Eastep
ad91501e79
Correct two-interface sample snat file
- s/92/192/

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-16 08:14:20 -07:00
Tom Eastep
395ea90cd7
Clear the firewall on Debian during systemd stop
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 13:01:24 -07:00
Tom Eastep
ce861dd0a3
Correctly handle expansion of option names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 11:47:54 -07:00
Tom Eastep
8fca17a0ef
Correct all+ handling in the policy file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 11:36:47 -07:00
Tom Eastep
63d7580219
Allow compact IPv6 addresses in IP6TABLES() rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-07 16:20:38 -08:00
Tom Eastep
1d1068ac74
Correct splitting of IP(6)TABLES options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-07 16:20:26 -08:00
Tom Eastep
5bc724c268
Correct handling of safe-restart with SAVE_IPSETS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-27 16:35:58 -08:00
Tom Eastep
c6fab61c3d
Remove redundent test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 14:42:20 -08:00
Tom Eastep
03a9b92a14
Use 'ip -s xfrm' to dump the SPD and SAD
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 09:30:49 -08:00
Matt Darfeuille
b3b637d663
shorewall: Correct displaying of shorewall version
Add the Product name variable to properly display the product name
when the '-v' option is passed to the script.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 09:30:16 -08:00
Tom Eastep
363679bb4c
Correct merge compatibility change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 09:29:50 -08:00
Tom Eastep
458c26c2d6
Exercise care when merging rules including -m multiport
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 09:29:36 -08:00
Tom Eastep
e229849c5b
Correct intra-zone handling in policies
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 09:12:14 -08:00
12 changed files with 73 additions and 49 deletions

View File

@ -1583,6 +1583,19 @@ show_status() {
}
#
# Don't dump empty SPD entries
#
spd_filter()
{
awk \
'BEGIN { skip=0; }; \
/^src/ { skip=0; }; \
/^src 0.0.0.0\/0/ { skip=1; }; \
/^src ::\/0/ { skip=1; }; \
{ if ( skip == 0 ) print; };'
}
#
# Dump Command Executor
#
@ -1733,12 +1746,10 @@ do_dump_command() {
heading "Events"
show_events
if qt mywhich setkey; then
heading "PFKEY SPD"
setkey -DP
$IP -s xfrm policy | spd_filter
heading "PFKEY SAD"
setkey -D | grep -Ev '^[[:space:]](A:|E:)' # Don't divulge the keys
fi
$IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # Don't divulge the keys
heading "/proc"
show_proc /proc/version

View File

@ -16,7 +16,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-lite
StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop
ExecStop=/sbin/shorewall-lite $OPTIONS clear
ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS
[Install]

View File

@ -1195,9 +1195,16 @@ sub compatible( $$ ) {
}
}
#
# Don't combine chains where each specifies '-m policy'
# Don't combine chains where each specifies
# -m policy
# or when one specifies
# -m multiport
# and the other specifies
# --dport or --sport or -m multiport
#
return ! ( $ref1->{policy} && $ref2->{policy} );
return ! ( $ref1->{policy} && $ref2->{policy} ||
( ( $ref1->{multiport} && ( $ref2->{dport} || $ref2->{sport} || $ref2->{multiport} ) ) ||
( $ref2->{multiport} && ( $ref1->{dport} || $ref1->{sport} ) ) ) );
}
#

View File

@ -2000,6 +2000,21 @@ sub find_writable_file($) {
"$config_path[0]$filename";
}
#
# Determine if a value has been supplied
#
sub supplied( $ ) {
my $val = shift;
defined $val && $val ne '';
}
sub passed( $ ) {
my $val = shift;
defined $val && $val ne '' && $val ne '-';
}
#
# Split a comma-separated list into a Perl array
#
@ -2058,7 +2073,7 @@ sub split_list1( $$;$ ) {
sub split_list2( $$ ) {
my ($list, $type ) = @_;
fatal_error "Invalid $type ($list)" if $list =~ /^:|::/;
fatal_error "Invalid $type ($list)" if $list =~ /^:/;
my @list1 = split /:/, $list;
my @list2;
@ -2095,6 +2110,7 @@ sub split_list2( $$ ) {
fatal_error "Invalid $type ($list)" if $opencount < 0;
}
} elsif ( $element eq '' ) {
fatal_error "Invalid $type ($list)" unless supplied $_;
push @list2 , $_;
} else {
$element = join ':', $element , $_;
@ -2260,21 +2276,6 @@ sub split_columns( $ ) {
@list2;
}
#
# Determine if a value has been supplied
#
sub supplied( $ ) {
my $val = shift;
defined $val && $val ne '';
}
sub passed( $ ) {
my $val = shift;
defined $val && $val ne '' && $val ne '-';
}
sub clear_comment();
#
@ -3666,6 +3667,7 @@ sub expand_variables( \$ ) {
$usedcaller = USEDCALLER if $var eq 'caller';
} else {
fatal_error "Undefined shell variable (\$$var)" unless $config{IGNOREUNKNOWNVARIABLES} || exists $config{$var};
$val = $config{$var};
}
$val = '' unless defined $val;

View File

@ -122,7 +122,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1;
}
my ( $tgt, $options ) = split( ' ', $2 );
my ( $tgt, $options ) = split( ' ', $2, 2 );
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;

View File

@ -638,7 +638,8 @@ sub process_a_policy1($$$$$$$) {
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ );
$intrazone = $clientwild && $1;
$intrazone ||= $clientwild && $1;
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
@ -730,22 +731,21 @@ sub process_a_policy1($$$$$$$) {
if ( $serverwild ) {
for my $zone ( @zonelist ) {
for my $zone1 ( @zonelist ) {
set_policy_chain rules_chain( ${zone}, ${zone1} ), $client, $server, $chainref, $policy, $intrazone;
set_policy_chain rules_chain( ${zone}, ${zone1} ), $zone, $zone1, $chainref, $policy, $intrazone;
print_policy $zone, $zone1, $originalpolicy, $chain;
}
}
} else {
for my $zone ( all_zones ) {
set_policy_chain rules_chain( ${zone}, ${server} ), $client, $server, $chainref, $policy, $intrazone;
set_policy_chain rules_chain( ${zone}, ${server} ), $zone, $server, $chainref, $policy, $intrazone;
print_policy $zone, $server, $originalpolicy, $chain;
}
}
} elsif ( $serverwild ) {
for my $zone ( @zonelist ) {
set_policy_chain rules_chain( ${client}, ${zone} ), $client, $server, $chainref, $policy, $intrazone;
set_policy_chain rules_chain( ${client}, ${zone} ), $client, $zone, $chainref, $policy, $intrazone;
print_policy $client, $zone, $originalpolicy, $chain;
}
} else {
print_policy $client, $server, $originalpolicy, $chain;
}
@ -763,26 +763,29 @@ sub process_a_policy() {
$synparams = '' if $synparams eq '-';
$connlimit = '' if $connlimit eq '-';
my $intrazone;
my ( $intrazone, $clientlist, $serverlist );
if ( $intrazone = $clients =~ /.*,.*\+$/) {
$clients =~ s/\+$//;
if ( $clientlist = ( $clients =~ /,/ ) ) {
$intrazone = ( $clients =~ s/\+$// );
}
if ( $servers =~ /.*,.*\+$/ ) {
$servers =~ s/\+$//;
$intrazone = 1;
if ( $serverlist = ( $servers =~ /,/ ) ) {
$intrazone ||= ( $servers =~ s/\+$// );
}
fatal_error 'SOURCE must be specified' if $clients eq '-';
fatal_error 'DEST must be specified' if $servers eq '-';
fatal_error 'POLICY must be specified' if $policy eq '-';
if ( $clientlist || $serverlist ) {
for my $client ( split_list( $clients, 'zone' ) ) {
for my $server ( split_list( $servers, 'zone' ) ) {
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone );
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone ) if $intrazone || $client ne $server;
}
}
} else {
process_a_policy1( $clients, $servers, $policy, $loglevel, $synparams, $connlimit, 0 );
}
}
#
@ -2911,7 +2914,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
IPTABLES => sub {
if ( $param ) {
fatal_error "Unknown ACTION (IPTABLES)" unless $family == F_IPV4;
my ( $tgt, $options ) = split / /, $param;
my ( $tgt, $options ) = split / /, $param, 2;
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
@ -2924,7 +2927,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
IP6TABLES => sub {
if ( $param ) {
fatal_error "Unknown ACTION (IP6TABLES)" unless $family == F_IPV6;
my ( $tgt, $options ) = split / /, $param;
my ( $tgt, $options ) = split / /, $param, 2;
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
@ -4495,7 +4498,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
maxparams => 1,
function => sub () {
fatal_error "Invalid ACTION (IPTABLES)" unless $family == F_IPV4;
my ( $tgt, $options ) = split( ' ', $params );
my ( $tgt, $options ) = split( ' ', $params, 2 );
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
@ -4511,7 +4514,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
maxparams => 1,
function => sub () {
fatal_error "Invalid ACTION (IP6TABLES)" unless $family == F_IPV6;
my ( $tgt, $options ) = split( ' ', $params );
my ( $tgt, $options ) = split( ' ', $params, 2 );
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;

View File

@ -20,4 +20,4 @@
MASQUERADE 10.0.0.0/8,\
169.254.0.0/16,\
172.16.0.0/12,\
92.168.0.0/16 eth0
192.168.0.0/16 eth0

View File

@ -1235,7 +1235,7 @@ safe_commands() {
echo "New configuration has been accepted"
else
if [ "$command" = "restart" -o "$command" = "reload" ]; then
run_it ${VARDIR}/.safe restore
run_it ${VARDIR}/.safe -r restore
else
run_it ${VARDIR}/.$command clear
fi

View File

@ -16,7 +16,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall
StandardOutput=syslog
ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall $OPTIONS stop
ExecStop=/sbin/shorewall $OPTIONS clear
ExecReload=/sbin/shorewall $OPTIONS reload $RELOADOPTIONS
[Install]

View File

@ -28,6 +28,7 @@
VERSION=xxx #The Build script inserts the actual version
PRODUCT=shorewall
Product=Shorewall
usage() # $1 = exit status
{

View File

@ -15,7 +15,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall6-lite
StandardOutput=syslog
ExecStart=/sbin/shorewall6-lite $OPTIONS start
ExecStop=/sbin/shorewall6-lite $OPTIONS stop
ExecStop=/sbin/shorewall6-lite $OPTIONS clear
ExecReload=/sbin/shorewall6-lite $OPTIONS reload
[Install]

View File

@ -16,7 +16,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall6
StandardOutput=syslog
ExecStart=/sbin/shorewall6 $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall6 $OPTIONS stop
ExecStop=/sbin/shorewall6 $OPTIONS clear
ExecReload=/sbin/shorewall6 $OPTIONS reload $RELOADOPTIONS
[Install]