Compare commits

...

44 Commits

Author SHA1 Message Date
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
Tom Eastep
e98abac706 Define MYNET in the QOS example
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-12 09:35:03 -08:00
Tom Eastep
5ea78b8078 Correct typo in the snat manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-11 14:36:04 -08:00
Michele Baldessari
036a6e5a83 Add an IPv6 bidirectional mDNS macro
Add the missing corresponding IPv6 bidirectional mDNSbi macro.

Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1295844

Signed-off-by: Michele Baldessari <michele@acksyn.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-10 14:44:10 -08:00
Tom Eastep
192486eb0a Bring shorewall6-actions(5) up to date
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 09:47:14 -08:00
Tom Eastep
e4804e1900 NFQUEUE should be non-terminating
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 08:46:39 -08:00
Tom Eastep
f537e3e15c Fix optimization bug in merge_rules()
- Reset the simple member if a unique option is merged

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-02 14:47:03 -08:00
Tom Eastep
4949569383 Correct 'restore' exit status
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-02 09:33:16 -08:00
Tom Eastep
a1981823f4 Correct typo (syntax error!)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-01 15:21:25 -08:00
Tom Eastep
ff81980552 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2016-11-21 15:16:30 -08:00
Roberto C. Sánchez
8a6dcc469b Fix typo 2016-11-21 11:59:57 -05:00
Tom Eastep
ccab75e69a Avoid unnecessary change in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-20 09:17:39 -08:00
Tom Eastep
9eb390403b Implement -p option to disable PAGER
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-17 10:58:10 -08:00
Tom Eastep
ab9f340c55 use $PAGER in the 'show macro' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-17 10:57:39 -08:00
Tom Eastep
88284ed568 Delete version from the heading of compiler.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-16 13:03:00 -08:00
Tom Eastep
481afef2c3 Don't insist that route deletion succeeds
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-12 08:38:09 -08:00
Tom Eastep
6b38b3a515 Revert "More IPv6 routing cleanup"
This reverts commit 1e7f63834c.
2016-11-12 08:25:38 -08:00
Tom Eastep
80951d23c2 add/delete multi-nexthop IPv6 routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-12 08:24:46 -08:00
Tom Eastep
1e7f63834c More IPv6 routing cleanup
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 10:34:19 -08:00
Tom Eastep
74b94f71f8 Always return $omitting from process_compiler_directive()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 08:07:17 -08:00
Tom Eastep
ef4ab62dd3 Disable directive callbacks after file conversion.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 07:47:19 -08:00
Tom Eastep
42c1c2a205 Don't copy link-level address routes into provider tables.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-08 14:42:44 -08:00
Tom Eastep
6095d05af9 Update manpages for 'update' improvements
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 13:50:11 -08:00
Tom Eastep
d989241712 Retain shell variables during routestopped and blacklist conversions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 11:26:17 -08:00
Tom Eastep
652bc75448 Omit Shorewall version from converted files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 11:12:36 -08:00
Tom Eastep
d105da3964 Preserve shell variables when converting tos->mangle
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 17:25:35 -08:00
Tom Eastep
c5b393a074 Preserve shell variables when converting tcrules->mangle
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 17:25:01 -08:00
Tom Eastep
1b82dedb77 Preserve shell variables when converting masq -> snat
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 13:53:05 -08:00
Tom Eastep
6398756647 Add a routine to split the raw current line image
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 08:44:24 -08:00
Tom Eastep
daa2440d9a Ensure that $directive_callback->() gets an unaltered image
- pass omitted lines to that function as well

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 08:03:31 -08:00
Tom Eastep
6a89fd1367 Merge branch 'master' into 5.0.14 2016-11-04 08:37:55 -07:00
Tom Eastep
ffe1e1d335 Fix typo in the two-interface sample snat file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-04 08:36:24 -07:00
Tom Eastep
cecfe54ef6 Avoid shell errors when /proc/net/xt_recent/ is empty.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-03 21:29:01 -07:00
25 changed files with 633 additions and 259 deletions

View File

@@ -949,7 +949,7 @@ show_events() {
for file in /proc/net/xt_recent/*; do for file in /proc/net/xt_recent/*; do
base=$(basename $file) base=$(basename $file)
if [ $base != %CURRENTTIME ]; then if [ "$base" != %CURRENTTIME -a "$base" != "*" ]; then
echo $base echo $base
show_event $base show_event $base
echo echo
@@ -1161,6 +1161,11 @@ show_macros() {
done done
} }
show_a_macro() {
echo "Shorewall $SHOREWALL_VERSION Macro $1 at $g_hostname - $(date)"
cat ${directory}/macro.$1
}
# #
# Show Command Executor # Show Command Executor
# #
@@ -1441,8 +1446,7 @@ show_command() {
[ $# -ne 2 ] && too_many_arguments $2 [ $# -ne 2 ] && too_many_arguments $2
for directory in $(split $CONFIG_PATH); do for directory in $(split $CONFIG_PATH); do
if [ -f ${directory}/macro.$2 ]; then if [ -f ${directory}/macro.$2 ]; then
echo "Shorewall $SHOREWALL_VERSION Macro $2 at $g_hostname - $(date)" eval show_a_macro $2 $g_pager
cat ${directory}/macro.$2
return return
fi fi
done done
@@ -1579,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 # Dump Command Executor
# #
@@ -1729,12 +1746,10 @@ do_dump_command() {
heading "Events" heading "Events"
show_events show_events
if qt mywhich setkey; then heading "PFKEY SPD"
heading "PFKEY SPD" $IP -s xfrm policy | spd_filter
setkey -DP heading "PFKEY SAD"
heading "PFKEY SAD" $IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # Don't divulge the keys
setkey -D | grep -Ev '^[[:space:]](A:|E:)' # Don't divulge the keys
fi
heading "/proc" heading "/proc"
show_proc /proc/version show_proc /proc/version
@@ -1805,6 +1820,7 @@ dump_command() {
restore_command() { restore_command() {
local finished local finished
finished=0 finished=0
local result
while [ $finished -eq 0 -a $# -gt 0 ]; do while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1 option=$1
@@ -1869,8 +1885,11 @@ restore_command() {
progress_message3 "Restoring $g_product..." progress_message3 "Restoring $g_product..."
run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE" run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE"
result=$?
[ -n "$g_nolock" ] || mutex_off [ -n "$g_nolock" ] || mutex_off
exit $result
else else
echo "File $g_restorepath: file not found" echo "File $g_restorepath: file not found"
[ -n "$g_nolock" ] || mutex_off [ -n "$g_nolock" ] || mutex_off
@@ -3992,24 +4011,26 @@ get_config() {
g_loopback=$(find_loopback_interfaces) g_loopback=$(find_loopback_interfaces)
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER if [ -z "$g_nopager" ]; then
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then if [ -n "$PAGER" -a -t 1 ]; then
case $PAGER in case $PAGER in
/*) /*)
g_pager="$PAGER" g_pager="$PAGER"
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
*) *)
g_pager=$(mywhich $PAGER 2> /dev/null) g_pager=$(mywhich $PAGER 2> /dev/null)
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
esac esac
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
g_pager="| $g_pager" g_pager="| $g_pager"
fi fi
fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then if [ -n "$DYNAMIC_BLACKLIST" ]; then
setup_dbl setup_dbl
@@ -4357,6 +4378,7 @@ shorewall_cli() {
g_loopback= g_loopback=
g_compiled= g_compiled=
g_pager= g_pager=
g_nopager=
g_blacklistipset= g_blacklistipset=
g_disconnect= g_disconnect=
@@ -4453,6 +4475,11 @@ shorewall_cli() {
g_timestamp=Yes g_timestamp=Yes
option=${option#t} option=${option#t}
;; ;;
p*)
g_nopager=Yes
option=${option#p}
;;
-) -)
finished=1 finished=1
option= option=

View File

@@ -16,7 +16,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-lite EnvironmentFile=-/etc/default/shorewall-lite
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS 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 ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS
[Install] [Install]

View File

@@ -810,7 +810,6 @@ sub initialize( $$$ ) {
DNAT => 1, DNAT => 1,
MASQUERADE => 1, MASQUERADE => 1,
NETMAP => 1, NETMAP => 1,
NFQUEUE => 1,
NOTRACK => 1, NOTRACK => 1,
RAWDNAT => 1, RAWDNAT => 1,
REDIRECT => 1, REDIRECT => 1,
@@ -1196,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} ) ) ) );
} }
# #
@@ -1218,6 +1224,7 @@ sub merge_rules( $$$ ) {
if ( exists $fromref->{$option} ) { if ( exists $fromref->{$option} ) {
push( @{$toref->{matches}}, $option ) unless exists $toref->{$option}; push( @{$toref->{matches}}, $option ) unless exists $toref->{$option};
$toref->{$option} = $fromref->{$option}; $toref->{$option} = $fromref->{$option};
$toref->{simple} = 0;
} }
} }

View File

@@ -133,6 +133,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
split_line split_line
split_line1 split_line1
split_line2 split_line2
split_rawline2
first_entry first_entry
open_file open_file
close_file close_file
@@ -174,6 +175,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
$doing $doing
$done $done
$currentline $currentline
$rawcurrentline
$currentfilename $currentfilename
$debug $debug
$file_format $file_format
@@ -564,6 +566,7 @@ our $usedcaller;
our $inline_matches; our $inline_matches;
our $currentline; # Current config file line image our $currentline; # Current config file line image
our $rawcurrentline; # Current config file line with no variable expansion
our $currentfile; # File handle reference our $currentfile; # File handle reference
our $currentfilename; # File NAME our $currentfilename; # File NAME
our $currentlinenumber; # Line number our $currentlinenumber; # Line number
@@ -1997,6 +2000,21 @@ sub find_writable_file($) {
"$config_path[0]$filename"; "$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 # Split a comma-separated list into a Perl array
# #
@@ -2055,7 +2073,7 @@ sub split_list1( $$;$ ) {
sub split_list2( $$ ) { sub split_list2( $$ ) {
my ($list, $type ) = @_; my ($list, $type ) = @_;
fatal_error "Invalid $type ($list)" if $list =~ /^:|::/; fatal_error "Invalid $type ($list)" if $list =~ /^:/;
my @list1 = split /:/, $list; my @list1 = split /:/, $list;
my @list2; my @list2;
@@ -2092,6 +2110,7 @@ sub split_list2( $$ ) {
fatal_error "Invalid $type ($list)" if $opencount < 0; fatal_error "Invalid $type ($list)" if $opencount < 0;
} }
} elsif ( $element eq '' ) { } elsif ( $element eq '' ) {
fatal_error "Invalid $type ($list)" unless supplied $_;
push @list2 , $_; push @list2 , $_;
} else { } else {
$element = join ':', $element , $_; $element = join ':', $element , $_;
@@ -2257,21 +2276,6 @@ sub split_columns( $ ) {
@list2; @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(); sub clear_comment();
# #
@@ -2442,6 +2446,25 @@ sub split_line2( $$;$$$ ) {
@line; @line;
} }
#
# Same as above, only it splits the raw current line
#
sub split_rawline2( $$;$$$ ) {
my $savecurrentline = $currentline;
$currentline = $rawcurrentline;
#
# Delete trailing comment
#
$currentline =~ s/\s*#.*//;
my @result = &split_line2( @_ );
$currentline = $savecurrentline;
@result;
}
sub split_line1( $$;$$ ) { sub split_line1( $$;$$ ) {
&split_line2( @_, undef ); &split_line2( @_, undef );
} }
@@ -3026,9 +3049,9 @@ sub process_compiler_directive( $$$$ ) {
if ( $directive_callback ) { if ( $directive_callback ) {
$directive_callback->( $keyword, $line ) $directive_callback->( $keyword, $line )
} else {
$omitting;
} }
$omitting;
} }
# #
@@ -3644,6 +3667,7 @@ sub expand_variables( \$ ) {
$usedcaller = USEDCALLER if $var eq 'caller'; $usedcaller = USEDCALLER if $var eq 'caller';
} else { } else {
fatal_error "Undefined shell variable (\$$var)" unless $config{IGNOREUNKNOWNVARIABLES} || exists $config{$var}; fatal_error "Undefined shell variable (\$$var)" unless $config{IGNOREUNKNOWNVARIABLES} || exists $config{$var};
$val = $config{$var};
} }
$val = '' unless defined $val; $val = '' unless defined $val;
@@ -3736,6 +3760,7 @@ sub read_a_line($) {
if ( $omitting ) { if ( $omitting ) {
print "OMIT=> $_\n" if $debug; print "OMIT=> $_\n" if $debug;
$directive_callback->( 'OMITTED', $_ ) if ( $directive_callback );
next; next;
} }
@@ -3790,6 +3815,10 @@ sub read_a_line($) {
# #
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
# #
# Save Raw Image
#
$rawcurrentline = $currentline;
#
# Expand Shell Variables using %params and %actparams # Expand Shell Variables using %params and %actparams
# #
expand_variables( $currentline ) if $options & EXPAND_VARIABLES; expand_variables( $currentline ) if $options & EXPAND_VARIABLES;
@@ -3818,7 +3847,7 @@ sub read_a_line($) {
fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/; fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/;
fatal_error "This file does not allow ?SECTION" unless $section_function; fatal_error "This file does not allow ?SECTION" unless $section_function;
$section_function->($sectionname); $section_function->($sectionname);
$directive_callback->( 'SECTION', $currentline ) if $directive_callback; $directive_callback->( 'SECTION', $rawcurrentline ) if $directive_callback;
next LINE; next LINE;
} else { } else {
fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/; fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/;

View File

@@ -216,6 +216,7 @@ sub convert_blacklist() {
my $audit = $disposition =~ /^A_/; my $audit = $disposition =~ /^A_/;
my $target = $disposition; my $target = $disposition;
my $orig_target = $target; my $orig_target = $target;
my $warnings = 0;
my @rules; my @rules;
if ( @$zones || @$zones1 ) { if ( @$zones || @$zones1 ) {
@@ -237,12 +238,22 @@ sub convert_blacklist() {
return 0; return 0;
} }
directive_callback(
sub ()
{
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
}
);
first_entry "Converting $fn..."; first_entry "Converting $fn...";
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $networks, $protocol, $ports, $options ) = my ( $networks, $protocol, $ports, $options ) =
split_line( 'blacklist file', split_rawline2( 'blacklist file',
{ networks => 0, proto => 1, port => 2, options => 3 } ); { networks => 0, proto => 1, port => 2, options => 3 },
{},
4,
);
if ( $options eq '-' ) { if ( $options eq '-' ) {
$options = 'src'; $options = 'src';
@@ -300,6 +311,8 @@ sub convert_blacklist() {
} }
} }
directive_callback(0);
if ( @rules ) { if ( @rules ) {
my $fn1 = find_writable_file( 'blrules' ); my $fn1 = find_writable_file( 'blrules' );
my $blrules; my $blrules;
@@ -312,7 +325,7 @@ sub convert_blacklist() {
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
print $blrules <<'EOF'; print $blrules <<'EOF';
# #
# Shorewall version 5.0 - Blacklist Rules File # Shorewall - Blacklist Rules File
# #
# For information about entries in this file, type "man shorewall-blrules" # For information about entries in this file, type "man shorewall-blrules"
# #
@@ -394,7 +407,8 @@ sub convert_routestopped() {
if ( my $fn = open_file 'routestopped' ) { if ( my $fn = open_file 'routestopped' ) {
my ( @allhosts, %source, %dest , %notrack, @rule ); my ( @allhosts, %source, %dest , %notrack, @rule );
my $seq = 0; my $seq = 0;
my $warnings = 0;
my $date = compiletime; my $date = compiletime;
my ( $stoppedrules, $fn1 ); my ( $stoppedrules, $fn1 );
@@ -406,7 +420,7 @@ sub convert_routestopped() {
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
print $stoppedrules <<'EOF'; print $stoppedrules <<'EOF';
# #
# Shorewall version 5 - Stopped Rules File # Shorewall - Stopped Rules File
# #
# For information about entries in this file, type "man shorewall-stoppedrules" # For information about entries in this file, type "man shorewall-stoppedrules"
# #
@@ -422,6 +436,13 @@ sub convert_routestopped() {
EOF EOF
} }
directive_callback(
sub ()
{
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
}
);
first_entry( first_entry(
sub { sub {
my $date = compiletime; my $date = compiletime;
@@ -436,13 +457,16 @@ EOF
while ( read_a_line ( NORMAL_READ ) ) { while ( read_a_line ( NORMAL_READ ) ) {
my ($interface, $hosts, $options , $proto, $ports, $sports ) = my ($interface, $hosts, $options , $proto, $ports, $sports ) =
split_line( 'routestopped file', split_rawline2( 'routestopped file',
{ interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 } ); { interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 },
{},
6,
0,
);
my $interfaceref; my $interfaceref;
fatal_error 'INTERFACE must be specified' if $interface eq '-'; fatal_error 'INTERFACE must be specified' if $interface eq '-';
fatal_error "Unknown interface ($interface)" unless $interfaceref = known_interface $interface;
$hosts = ALLIP unless $hosts && $hosts ne '-'; $hosts = ALLIP unless $hosts && $hosts ne '-';
my $routeback = 0; my $routeback = 0;
@@ -456,8 +480,6 @@ EOF
$hosts = ALLIP if $hosts eq '-'; $hosts = ALLIP if $hosts eq '-';
for my $host ( split /,/, $hosts ) { for my $host ( split /,/, $hosts ) {
fatal_error "Ipsets not allowed with SAVE_IPSETS=Yes" if $host =~ /^!?\+/ && $config{SAVE_IPSETS};
validate_host $host, 1;
push @hosts, "$interface|$host|$seq"; push @hosts, "$interface|$host|$seq";
push @rule, $rule; push @rule, $rule;
} }
@@ -501,6 +523,8 @@ EOF
push @allhosts, @hosts; push @allhosts, @hosts;
} }
directive_callback(0);
for my $host ( @allhosts ) { for my $host ( @allhosts ) {
my ( $interface, $h, $seq ) = split /\|/, $host; my ( $interface, $h, $seq ) = split /\|/, $host;
my $rule = shift @rule; my $rule = shift @rule;

View File

@@ -60,12 +60,12 @@ sub initialize($) {
# #
# Process a single rule from the the masq file # Process a single rule from the the masq file
# #
sub process_one_masq1( $$$$$$$$$$$$ ) sub process_one_masq1( $$$$$$$$$$$ )
{ {
my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_; my ( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $pre_nat; my $pre_nat;
my $add_snat_aliases = ! $snat && $family == F_IPV4 && $config{ADD_SNAT_ALIASES}; my $add_snat_aliases = $family == F_IPV4 && $config{ADD_SNAT_ALIASES};
my $destnets = ''; my $destnets = '';
my $baserule = ''; my $baserule = '';
my $inlinematches = ''; my $inlinematches = '';
@@ -226,7 +226,7 @@ sub process_one_masq1( $$$$$$$$$$$$ )
} elsif ( $addresses eq 'NONAT' ) { } elsif ( $addresses eq 'NONAT' ) {
fatal_error "'persistent' may not be specified with 'NONAT'" if $persistent; fatal_error "'persistent' may not be specified with 'NONAT'" if $persistent;
fatal_error "'random' may not be specified with 'NONAT'" if $randomize; fatal_error "'random' may not be specified with 'NONAT'" if $randomize;
$target = $snat ? 'CONTINUE' : 'RETURN'; $target = 'RETURN';
$add_snat_aliases = 0; $add_snat_aliases = 0;
} elsif ( $addresses ) { } elsif ( $addresses ) {
my $addrlist = ''; my $addrlist = '';
@@ -249,33 +249,31 @@ sub process_one_masq1( $$$$$$$$$$$$ )
# #
$target = 'SNAT '; $target = 'SNAT ';
unless ( $snat ) { if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) { #
# User-defined address variable
#
$conditional = conditional_rule( $chainref, $addr );
$addrlist .= '--to-source ' . "\$${1}${ports} ";
} else {
if ( $conditional = conditional_rule( $chainref, $addr ) ) {
# #
# User-defined address variable # Optional Interface -- rule is conditional
# #
$conditional = conditional_rule( $chainref, $addr ); $addr = get_interface_address $interface;
$addrlist .= '--to-source ' . "\$${1}${ports} ";
} else { } else {
if ( $conditional = conditional_rule( $chainref, $addr ) ) { #
# # Interface is not optional
# Optional Interface -- rule is conditional #
# $addr = record_runtime_address( $type, $interface );
$addr = get_interface_address $interface;
} else {
#
# Interface is not optional
#
$addr = record_runtime_address( $type, $interface );
}
if ( $ports ) {
$addr =~ s/ $//;
$addr = $family == F_IPV4 ? "${addr}${ports} " : "[$addr]$ports ";
}
$addrlist .= '--to-source ' . $addr;
} }
if ( $ports ) {
$addr =~ s/ $//;
$addr = $family == F_IPV4 ? "${addr}${ports} " : "[$addr]$ports ";
}
$addrlist .= '--to-source ' . $addr;
} }
} elsif ( $family == F_IPV4 ) { } elsif ( $family == F_IPV4 ) {
if ( $addr =~ /^.*\..*\..*\./ ) { if ( $addr =~ /^.*\..*\..*\./ ) {
@@ -362,39 +360,37 @@ sub process_one_masq1( $$$$$$$$$$$$ )
# #
# And Generate the Rule(s) # And Generate the Rule(s)
# #
unless ( $snat ) { expand_rule( $chainref ,
expand_rule( $chainref , POSTROUTE_RESTRICT ,
POSTROUTE_RESTRICT , $prerule ,
$prerule , $baserule . $inlinematches . $rule ,
$baserule . $inlinematches . $rule , $networks ,
$networks , $destnets ,
$destnets , $origdest ,
$origdest , $target ,
$target , '' ,
'' , '' ,
'' , $exceptionrule ,
$exceptionrule , '' )
'' ) unless unreachable_warning( 0, $chainref );
unless unreachable_warning( 0, $chainref );
conditional_rule_end( $chainref ) if $detectaddress || $conditional; conditional_rule_end( $chainref ) if $detectaddress || $conditional;
if ( $add_snat_aliases ) { if ( $add_snat_aliases ) {
my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 ); my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 );
fatal_error "Invalid alias ($alias:$remainder)" if defined $remainder; fatal_error "Invalid alias ($alias:$remainder)" if defined $remainder;
for my $address ( split_list $addresses, 'address' ) { for my $address ( split_list $addresses, 'address' ) {
my ( $addrs, $port ) = split /:/, $address; my ( $addrs, $port ) = split /:/, $address;
next unless $addrs; next unless $addrs;
next if $addrs eq 'detect'; next if $addrs eq 'detect';
for my $addr ( ip_range_explicit $addrs ) { for my $addr ( ip_range_explicit $addrs ) {
unless ( $addresses_to_add{$addr} ) { unless ( $addresses_to_add{$addr} ) {
$addresses_to_add{$addr} = 1; $addresses_to_add{$addr} = 1;
if ( defined $alias ) { if ( defined $alias ) {
push @addresses_to_add, $addr, "$interface:$alias"; push @addresses_to_add, $addr, "$interface:$alias";
$alias++; $alias++;
} else { } else {
push @addresses_to_add, $addr, $interface; push @addresses_to_add, $addr, $interface;
}
} }
} }
} }
@@ -402,8 +398,87 @@ sub process_one_masq1( $$$$$$$$$$$$ )
} }
} }
progress_message " Masq record \"$currentline\" $done";
}
sub convert_one_masq1( $$$$$$$$$$$$ )
{
my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $pre_nat;
my $destnets = '';
my $savelist;
#
# Leading '+'
#
$pre_nat = ( $interfacelist =~ s/^\+// );
#
# Check for INLINE
#
if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) {
$interfacelist = $1;
}
$savelist = $interfacelist;
#
# Parse the remaining part of the INTERFACE column
#
if ( $family == F_IPV4 ) {
if ( $interfacelist =~ /^([^:]+)::([^:]*)$/ ) {
$destnets = $2;
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+:[^:]+):([^:]+)$/ ) {
$destnets = $2;
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+):$/ ) {
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+):([^:]*)$/ ) {
my ( $one, $two ) = ( $1, $2 );
if ( $2 =~ /\./ || $2 =~ /^%/ ) {
$interfacelist = $one;
$destnets = $two;
}
}
} elsif ( $interfacelist =~ /^(.+?):(.+)$/ ) {
$interfacelist = $1;
$destnets = $2;
}
#
# If there is no source or destination then allow all addresses
#
$networks = ALLIP if $networks eq '-';
$destnets = ALLIP if $destnets eq '-';
my $target;
#
# Parse the ADDRESSES column
#
if ( $addresses ne '-' ) {
my $saveaddresses = $addresses;
if ( $addresses ne 'random' ) {
$addresses =~ s/:persistent$//;
$addresses =~ s/:random$//;
if ( $addresses eq 'detect' ) {
$target = 'SNAT';
} elsif ( $addresses eq 'NONAT' ) {
$target = 'CONTINUE';
} elsif ( $addresses ) {
if ( $addresses =~ /^:/ ) {
$target = 'MASQUERADE';
} else {
$target = 'SNAT';
}
}
}
$addresses = $saveaddresses;
} else {
$target = 'MASQUERADE';
}
if ( $snat ) { if ( $snat ) {
$target =~ s/ .*//;
$target .= '+' if $pre_nat; $target .= '+' if $pre_nat;
if ( $addresses ne '-' && $addresses ne 'NONAT' ) { if ( $addresses ne '-' && $addresses ne 'NONAT' ) {
@@ -424,7 +499,7 @@ sub process_one_masq1( $$$$$$$$$$$$ )
print $snat "$line\n"; print $snat "$line\n";
} }
progress_message " Masq record \"$currentline\" $done"; progress_message " Masq record \"$rawcurrentline\" Converted";
} }
@@ -432,17 +507,37 @@ sub process_one_masq( $ )
{ {
my ( $snat ) = @_; my ( $snat ) = @_;
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = if ( $snat ) {
split_line2( 'masq file', unless ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 }, #
{}, #Nopad # Line was not blank or all comment
undef, #Columns #
1 ); #Allow inline matches my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_rawline2( 'masq file',
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
1 ); #Allow inline matches
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-'; if ( $interfacelist ne '-' ) {
for my $proto ( split_list $protos, 'Protocol' ) {
convert_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
}
}
}
} else {
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'masq file',
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
1 ); #Allow inline matches
for my $proto ( split_list $protos, 'Protocol' ) { fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
process_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
for my $proto ( split_list $protos, 'Protocol' ) {
process_one_masq1( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
}
} }
} }
@@ -497,7 +592,19 @@ sub convert_masq() {
my $have_masq_rules; my $have_masq_rules;
directive_callback( sub () { print $snat "$_[1]\n"; 0; } ); directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
process_one_masq( $snat) if $snat;
} else {
print $snat "$_[1]\n"; 0;
}
}
);
first_entry( first_entry(
sub { sub {
@@ -510,7 +617,18 @@ sub convert_masq() {
} }
); );
process_one_masq($snat), $have_masq_rules++ while read_a_line( NORMAL_READ ); while ( read_a_line( NORMAL_READ ) ) {
#
# Process the file normally
#
process_one_masq(0);
#
# Now Convert it
#
process_one_masq($snat);
$have_masq_rules++;
}
if ( $have_masq_rules ) { if ( $have_masq_rules ) {
progress_message2 "Converted $fn to $fn1"; progress_message2 "Converted $fn to $fn1";

View File

@@ -220,7 +220,14 @@ sub copy_table( $$$ ) {
' esac', ' esac',
); );
} else { } else {
emit ( " run_ip route add table $number \$net \$route $realm" ); emit ( ' case $net in',
' fe80:*)',
' ;;',
' *)',
" run_ip route add table $number \$net \$route $realm",
' ;;',
' esac',
);
} }
emit ( ' ;;', emit ( ' ;;',
@@ -291,7 +298,14 @@ sub copy_and_edit_table( $$$$$ ) {
' esac', ' esac',
); );
} else { } else {
emit ( " run_ip route add table $id \$net \$route $realm" ); emit ( ' case $net in',
' fe80:*)',
' ;;',
' *)',
" run_ip route add table $id \$net \$route $realm",
' ;;',
' esac',
);
} }
emit ( ' ;;', emit ( ' ;;',
@@ -1496,7 +1510,18 @@ sub finish_providers() {
if ( $balancing ) { if ( $balancing ) {
emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' ); emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' );
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
if ( $family == F_IPV4 ) {
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
} else {
emit ( " if echo \$DEFAULT_ROUTE | grep -q 'nexthop.+nexthop'; then",
" qt \$IP -6 route delete default scope global table $table \$DEFAULT_ROUTE",
" run_ip -6 route add default scope global table $table \$DEFAULT_ROUTE",
' else',
" run_ip -6 route replace default scope global table $table \$DEFAULT_ROUTE",
' fi',
'' );
}
if ( $config{USE_DEFAULT_RT} ) { if ( $config{USE_DEFAULT_RT} ) {
emit ( " while qt \$IP -$family route del default table $main; do", emit ( " while qt \$IP -$family route del default table $main; do",
@@ -1549,7 +1574,13 @@ sub finish_providers() {
if ( $fallback ) { if ( $fallback ) {
emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' ); emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' );
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
if ( $family == F_IPV4 ) {
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
} else {
emit( " run_ip route delete default scope global table $default \$FALLBACK_ROUTE" );
emit( " run_ip route add default scope global table $default \$FALLBACK_ROUTE" );
}
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"", emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
'else', 'else',

View File

@@ -122,7 +122,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1; 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}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; 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; 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 ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ ); my $clientwild = ( "\L$client" =~ /^all(\+)?$/ );
$intrazone = $clientwild && $1;
$intrazone ||= $clientwild && $1;
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client ); fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
@@ -730,22 +731,21 @@ sub process_a_policy1($$$$$$$) {
if ( $serverwild ) { if ( $serverwild ) {
for my $zone ( @zonelist ) { for my $zone ( @zonelist ) {
for my $zone1 ( @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; print_policy $zone, $zone1, $originalpolicy, $chain;
} }
} }
} else { } else {
for my $zone ( all_zones ) { 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; print_policy $zone, $server, $originalpolicy, $chain;
} }
} }
} elsif ( $serverwild ) { } elsif ( $serverwild ) {
for my $zone ( @zonelist ) { 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; print_policy $client, $zone, $originalpolicy, $chain;
} }
} else { } else {
print_policy $client, $server, $originalpolicy, $chain; print_policy $client, $server, $originalpolicy, $chain;
} }
@@ -763,25 +763,28 @@ sub process_a_policy() {
$synparams = '' if $synparams eq '-'; $synparams = '' if $synparams eq '-';
$connlimit = '' if $connlimit eq '-'; $connlimit = '' if $connlimit eq '-';
my $intrazone; my ( $intrazone, $clientlist, $serverlist );
if ( $intrazone = $clients =~ /.*,.*\+$/) { if ( $clientlist = ( $clients =~ /,/ ) ) {
$clients =~ s/\+$//; $intrazone = ( $clients =~ s/\+$// );
} }
if ( $servers =~ /.*,.*\+$/ ) { if ( $serverlist = ( $servers =~ /,/ ) ) {
$servers =~ s/\+$//; $intrazone ||= ( $servers =~ s/\+$// );
$intrazone = 1;
} }
fatal_error 'SOURCE must be specified' if $clients eq '-'; fatal_error 'SOURCE must be specified' if $clients eq '-';
fatal_error 'DEST must be specified' if $servers eq '-'; fatal_error 'DEST must be specified' if $servers eq '-';
fatal_error 'POLICY must be specified' if $policy eq '-'; fatal_error 'POLICY must be specified' if $policy eq '-';
for my $client ( split_list( $clients, 'zone' ) ) { if ( $clientlist || $serverlist ) {
for my $server ( split_list( $servers, 'zone' ) ) { for my $client ( split_list( $clients, 'zone' ) ) {
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone ); for my $server ( split_list( $servers, 'zone' ) ) {
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 { IPTABLES => sub {
if ( $param ) { if ( $param ) {
fatal_error "Unknown ACTION (IPTABLES)" unless $family == F_IPV4; 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}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; 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; 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 { IP6TABLES => sub {
if ( $param ) { if ( $param ) {
fatal_error "Unknown ACTION (IP6TABLES)" unless $family == F_IPV6; 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}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; 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; 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, maxparams => 1,
function => sub () { function => sub () {
fatal_error "Invalid ACTION (IPTABLES)" unless $family == F_IPV4; 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}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; 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; 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, maxparams => 1,
function => sub () { function => sub () {
fatal_error "Invalid ACTION (IP6TABLES)" unless $family == F_IPV6; 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}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; 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; fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
@@ -5139,50 +5142,50 @@ sub process_tc_rule( ) {
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state ); my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state );
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state ) = ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state ) =
split_line2( 'tcrules file', split_rawline2( 'tcrules file',
{ mark => 0, { mark => 0,
action => 0, action => 0,
source => 1, source => 1,
dest => 2, dest => 2,
proto => 3, proto => 3,
dport => 4, dport => 4,
sport => 5, sport => 5,
user => 6, user => 6,
test => 7, test => 7,
length => 8, length => 8,
tos => 9, tos => 9,
connbytes => 10, connbytes => 10,
helper => 11, helper => 11,
probability => 12 , probability => 12 ,
scp => 13, scp => 13,
state => 14 }, state => 14 },
{}, {},
15, 15,
1 ); 1 );
$headers = '-'; $headers = '-';
} else { } else {
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state ) = ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state ) =
split_line2( 'tcrules file', split_rawline2( 'tcrules file',
{ mark => 0, { mark => 0,
action => 0, action => 0,
source => 1, source => 1,
dest => 2, dest => 2,
proto => 3, proto => 3,
dport => 4, dport => 4,
sport => 5, sport => 5,
user => 6, user => 6,
test => 7, test => 7,
length => 8, length => 8,
tos => 9, tos => 9,
connbytes => 10, connbytes => 10,
helper => 11, helper => 11,
headers => 12, headers => 12,
probability => 13, probability => 13,
dscp => 14, dscp => 14,
state => 15 }, state => 15 },
{}, {},
16, 16,
1 ); 1 );
} }
for my $proto (split_list( $protos, 'Protocol' ) ) { for my $proto (split_list( $protos, 'Protocol' ) ) {

View File

@@ -2150,6 +2150,50 @@ sub process_secmark_rule() {
} }
} }
sub convert_one_tos( $ ) {
my ( $mangle ) = @_;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_rawline2( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 },
undef,
7 );
my $chain_designator = 'P';
decode_tos($tos, 1);
my ( $srczone , $source , $remainder );
if ( $family == F_IPV4 ) {
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
fatal_error 'Invalid SOURCE' if defined $remainder;
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
$srczone = $1;
$source = $2;
} else {
$srczone = $src;
}
if ( $srczone eq firewall_zone ) {
$chain_designator = 'O';
$src = $source || '-';
} else {
$src =~ s/^all:?//;
}
$dst =~ s/^all:?//;
$src = '-' unless supplied $src;
$dst = '-' unless supplied $dst;
$proto = '-' unless supplied $proto;
$ports = '-' unless supplied $ports;
$sports = '-' unless supplied $sports;
$mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
}
sub convert_tos($$) { sub convert_tos($$) {
my ( $mangle, $fn1 ) = @_; my ( $mangle, $fn1 ) = @_;
@@ -2167,6 +2211,25 @@ sub convert_tos($$) {
} }
if ( my $fn = open_file 'tos' ) { if ( my $fn = open_file 'tos' ) {
directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
print $mangle "$_[1]\n";
} else {
convert_one_tos( $mangle );
$have_tos = 1;
}
} else {
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
}
}
);
first_entry( first_entry(
sub { sub {
my $date = compiletime; my $date = compiletime;
@@ -2180,48 +2243,12 @@ sub convert_tos($$) {
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
convert_one_tos( $mangle );
$have_tos = 1; $have_tos = 1;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_line( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } );
my $chain_designator = 'P';
decode_tos($tos, 1);
my ( $srczone , $source , $remainder );
if ( $family == F_IPV4 ) {
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
fatal_error 'Invalid SOURCE' if defined $remainder;
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
$srczone = $1;
$source = $2;
} else {
$srczone = $src;
}
if ( $srczone eq firewall_zone ) {
$chain_designator = 'O';
$src = $source || '-';
} else {
$src =~ s/^all:?//;
}
$dst =~ s/^all:?//;
$src = '-' unless supplied $src;
$dst = '-' unless supplied $dst;
$proto = '-' unless supplied $proto;
$ports = '-' unless supplied $ports;
$sports = '-' unless supplied $sports;
$mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
} }
directive_callback(0);
if ( $have_tos ) { if ( $have_tos ) {
progress_message2 "Converted $fn to $fn1"; progress_message2 "Converted $fn to $fn1";
if ( rename $fn, "$fn.bak" ) { if ( rename $fn, "$fn.bak" ) {
@@ -2337,7 +2364,24 @@ sub setup_tc( $ ) {
# #
( $mangle, $fn1 ) = open_mangle_for_output( $fn ); ( $mangle, $fn1 ) = open_mangle_for_output( $fn );
directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } ); directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
print $mangle "$_[1]\n";
} else {
process_tc_rule;
$have_tcrules++;
}
} else {
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
}
}
);
first_entry( first_entry(
sub { sub {

View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
# #
# The Shoreline Firewall Packet Filtering Firewall Compiler - V4.4 # The Shoreline Firewall Packet Filtering Firewall Compiler
# #
# (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net) # (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
# #

View File

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

View File

@@ -318,21 +318,23 @@ get_config() {
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER [ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then if [ -z "$g_nopager" ]; then
case $PAGER in if [ -n "$PAGER" -a -t 1 ]; then
/*) case $PAGER in
g_pager="$PAGER" /*)
[ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist" g_pager="$PAGER"
;; [ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist"
*) ;;
g_pager=$(mywhich $PAGER 2> /dev/null) *)
[ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found" g_pager=$(mywhich $PAGER 2> /dev/null)
;; [ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found"
esac ;;
esac
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
g_pager="| $g_pager" g_pager="| $g_pager"
fi
fi fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then if [ -n "$DYNAMIC_BLACKLIST" ]; then
@@ -1233,7 +1235,7 @@ safe_commands() {
echo "New configuration has been accepted" echo "New configuration has been accepted"
else else
if [ "$command" = "restart" -o "$command" = "reload" ]; then if [ "$command" = "restart" -o "$command" = "reload" ]; then
run_it ${VARDIR}/.safe restore run_it ${VARDIR}/.safe -r restore
else else
run_it ${VARDIR}/.$command clear run_it ${VARDIR}/.$command clear
fi fi

View File

@@ -171,7 +171,7 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">SOURCE</emphasis> (Optional) - <term><emphasis role="bold">SOURCE</emphasis> (Optional) -
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis [<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>address</emphasis>][<emphasis>exclusion</emphasis>]]</term> role="bold">,</emphasis><emphasis>address</emphasis>...][<emphasis>exclusion</emphasis>]]</term>
<listitem> <listitem>
<para>Set of hosts that you wish to masquerade. You can specify this <para>Set of hosts that you wish to masquerade. You can specify this

View File

@@ -2602,8 +2602,10 @@
</listitem> </listitem>
<listitem> <listitem>
<para>INCLUDEd files will be expanded inline in the output <para>With the exception of the
file.</para> <filename>notrack</filename>-&gt;<filename>conntrack</filename>
conversion, INCLUDEd files will be expanded inline in the
output file.</para>
</listitem> </listitem>
<listitem> <listitem>
@@ -2611,6 +2613,26 @@
tab character; there is no attempt made to otherwise align the tab character; there is no attempt made to otherwise align the
columns.</para> columns.</para>
</listitem> </listitem>
<listitem>
<para>Prior to Shorewall 5.0.15, shell variables will be
expanded in the output file.</para>
</listitem>
<listitem>
<para>Prior to Shorewall 5.0.15, lines omitted by compiler
directives (?if ...., etc.) will not appear in the output
file.</para>
<important>
<para>Because the translation of the 'blacklist' and
'routestopped' files is not 1:1, omitted lines and compiler
directives are not transferred to the converted files. If
either are present, the compiler issues a warning: </para>
<programlisting> WARNING: "Omitted rules and compiler directives were not translated</programlisting>
</important>
</listitem>
</orderedlist> </orderedlist>
</important> </important>

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,14 @@
#
# Shorewall6 -- /usr/share/shorewall6/macro.mDNSbi
#
# This macro handles bidirectional multicast DNS traffic.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT
PARAM - [ff02::fb] udp 5353
PARAM - - udp 1024: 5353
PARAM - [ff02::fb] 2
PARAM DEST SOURCE:[ff02::fb] udp 5353
PARAM DEST SOURCE udp 1024: 5353
PARAM DEST SOURCE:[ff02::fb] 2

View File

@@ -131,6 +131,18 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>logjump</option></term>
<listitem>
<para>Added in Shorewall 5.0.8. Performs the same function as
<option>nolog</option> (below), with the addition that the
jump to the actions chain is logged if a log level is
specified on the action invocation. For inline actions, this
option is identical to <option>nolog</option>.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>mangle</option></term> <term><option>mangle</option></term>
@@ -143,6 +155,20 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>nat</option></term>
<listitem>
<para>Added in Shorewall 5.0.13. Specifies that this action is
to be used in <ulink
url="shorewall6-snat.html">shorewall6-snat(5)</ulink> rather
than <ulink
url="shorewall6-rules.html">shorewall6-rules(5)</ulink>. The
<option>mangle</option> and <option>nat</option> options are
mutually exclusive.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>noinline</option></term> <term><option>noinline</option></term>

View File

@@ -170,7 +170,7 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">SOURCE</emphasis> (Optional) - <term><emphasis role="bold">SOURCE</emphasis> (Optional) -
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis [<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>address</emphasis>][<emphasis>exclusion</emphasis>]]</term> role="bold">,</emphasis><emphasis>address</emphasis>...][<emphasis>exclusion</emphasis>]]</term>
<listitem> <listitem>
<para>Set of hosts that you wish to SNAT; one or more host or <para>Set of hosts that you wish to SNAT; one or more host or

View File

@@ -2480,8 +2480,10 @@
</listitem> </listitem>
<listitem> <listitem>
<para>INCLUDEd files will be expanded inline in the output <para>With the exception of the
file.</para> <filename>notrack</filename>-&gt;<filename>conntrack</filename>
conversion, INCLUDEd files will be expanded inline in the
output file.</para>
</listitem> </listitem>
<listitem> <listitem>
@@ -2489,6 +2491,26 @@
tab character; there is no attempt made to otherwise align the tab character; there is no attempt made to otherwise align the
columns.</para> columns.</para>
</listitem> </listitem>
<listitem>
<para>Prior to Shorewall 5.0.15, shell variables will be
expanded in the output file.</para>
</listitem>
<listitem>
<para>Prior to Shorewall 5.0.15, lines omitted by compiler
directives (?if ...., etc.) will not appear in the output
file.</para>
<important>
<para>Because the translation of the 'blacklist' and
'routestopped' files is not 1:1, omitted lines and compiler
directives are not transferred to the converted files. If
either are present, the compiler issues a warning:</para>
<programlisting> WARNING: "Omitted rules and compiler directives were not translated</programlisting>
</important>
</listitem>
</orderedlist> </orderedlist>
</important> </important>

View File

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

View File

@@ -44,7 +44,7 @@
</caution> </caution>
<important> <important>
<para>/etc/shorewall/mangle superseded /etc/shorewall/tcruels in Shorewall <para>/etc/shorewall/mangle superseded /etc/shorewall/tcrules in Shorewall
4.6.0. /etc/shorwall/tcrules is still supported but its use is 4.6.0. /etc/shorwall/tcrules is still supported but its use is
deprecated.</para> deprecated.</para>
</important> </important>

View File

@@ -76,7 +76,11 @@
<para>The shell variables set in the OpenWRT script are set in the <para>The shell variables set in the OpenWRT script are set in the
Shorewall params file:</para> Shorewall params file:</para>
<programlisting>DOWNLOAD=40000 #download speed in kbit. set xx% of real download speed <programlisting># local network
MYNET=192.168.0.0/24
DOWNLOAD=40000 #download speed in kbit. set xx% of real download speed
UPLOAD=7000 # set xx% of real upload speed UPLOAD=7000 # set xx% of real upload speed
# multiports = up to 15 ports # multiports = up to 15 ports