forked from extern/shorewall_code
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
63d7580219 | ||
|
1d1068ac74 | ||
|
5bc724c268 | ||
|
c6fab61c3d | ||
|
03a9b92a14 | ||
|
b3b637d663 | ||
|
363679bb4c | ||
|
458c26c2d6 | ||
|
e229849c5b | ||
|
e98abac706 | ||
|
5ea78b8078 | ||
|
036a6e5a83 | ||
|
192486eb0a | ||
|
e4804e1900 | ||
|
f537e3e15c | ||
|
4949569383 | ||
|
a1981823f4 | ||
|
ff81980552 | ||
|
8a6dcc469b | ||
|
ccab75e69a | ||
|
9eb390403b | ||
|
ab9f340c55 | ||
|
88284ed568 | ||
|
481afef2c3 | ||
|
6b38b3a515 | ||
|
80951d23c2 | ||
|
1e7f63834c | ||
|
74b94f71f8 | ||
|
ef4ab62dd3 | ||
|
42c1c2a205 | ||
|
6095d05af9 | ||
|
d989241712 | ||
|
652bc75448 | ||
|
d105da3964 | ||
|
c5b393a074 | ||
|
1b82dedb77 | ||
|
6398756647 | ||
|
daa2440d9a |
@@ -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"
|
||||||
setkey -DP
|
$IP -s xfrm policy | spd_filter
|
||||||
heading "PFKEY SAD"
|
heading "PFKEY SAD"
|
||||||
setkey -D | grep -Ev '^[[:space:]](A:|E:)' # Don't divulge the keys
|
$IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # 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,6 +4011,7 @@ get_config() {
|
|||||||
|
|
||||||
g_loopback=$(find_loopback_interfaces)
|
g_loopback=$(find_loopback_interfaces)
|
||||||
|
|
||||||
|
if [ -z "$g_nopager" ]; then
|
||||||
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
||||||
|
|
||||||
if [ -n "$PAGER" -a -t 1 ]; then
|
if [ -n "$PAGER" -a -t 1 ]; then
|
||||||
@@ -4010,6 +4030,7 @@ get_config() {
|
|||||||
|
|
||||||
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=
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -3736,6 +3759,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 +3814,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 +3846,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:]]/;
|
||||||
|
@@ -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"
|
||||||
#
|
#
|
||||||
@@ -395,6 +408,7 @@ sub convert_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;
|
||||||
|
@@ -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,7 +249,6 @@ 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
|
# User-defined address variable
|
||||||
@@ -276,7 +275,6 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
|
|
||||||
$addrlist .= '--to-source ' . $addr;
|
$addrlist .= '--to-source ' . $addr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} elsif ( $family == F_IPV4 ) {
|
} elsif ( $family == F_IPV4 ) {
|
||||||
if ( $addr =~ /^.*\..*\..*\./ ) {
|
if ( $addr =~ /^.*\..*\..*\./ ) {
|
||||||
$target = 'SNAT ';
|
$target = 'SNAT ';
|
||||||
@@ -362,7 +360,6 @@ 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 ,
|
||||||
@@ -400,10 +397,88 @@ 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,6 +507,25 @@ sub process_one_masq( $ )
|
|||||||
{
|
{
|
||||||
my ( $snat ) = @_;
|
my ( $snat ) = @_;
|
||||||
|
|
||||||
|
if ( $snat ) {
|
||||||
|
unless ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
|
||||||
|
#
|
||||||
|
# Line was not blank or all comment
|
||||||
|
#
|
||||||
|
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
|
||||||
|
|
||||||
|
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 ) =
|
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
|
||||||
split_line2( 'masq file',
|
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 },
|
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
|
||||||
@@ -442,7 +536,8 @@ sub process_one_masq( $ )
|
|||||||
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
|
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
|
||||||
|
|
||||||
for my $proto ( split_list $protos, 'Protocol' ) {
|
for my $proto ( split_list $protos, 'Protocol' ) {
|
||||||
process_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
|
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";
|
||||||
|
@@ -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' );
|
||||||
|
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
|
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' );
|
||||||
|
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
|
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',
|
||||||
|
@@ -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;
|
||||||
|
@@ -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 );
|
||||||
|
|
||||||
@@ -763,26 +764,29 @@ 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 '-';
|
||||||
|
|
||||||
|
if ( $clientlist || $serverlist ) {
|
||||||
for my $client ( split_list( $clients, 'zone' ) ) {
|
for my $client ( split_list( $clients, 'zone' ) ) {
|
||||||
for my $server ( split_list( $servers, '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 +2915,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 +2928,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 +4499,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 +4515,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,7 +5143,7 @@ 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,
|
||||||
@@ -5162,7 +5166,7 @@ sub process_tc_rule( ) {
|
|||||||
$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,
|
||||||
|
@@ -2150,41 +2150,14 @@ sub process_secmark_rule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub convert_one_tos( $ ) {
|
||||||
sub convert_tos($$) {
|
my ( $mangle ) = @_;
|
||||||
my ( $mangle, $fn1 ) = @_;
|
|
||||||
|
|
||||||
my $have_tos = 0;
|
|
||||||
|
|
||||||
sub unlink_tos( $ ) {
|
|
||||||
my $fn = shift;
|
|
||||||
|
|
||||||
if ( unlink $fn ) {
|
|
||||||
warning_message "Empty tos file ($fn) removed";
|
|
||||||
} else {
|
|
||||||
warning_message "Unable to remove empty tos file $fn: $!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( my $fn = open_file 'tos' ) {
|
|
||||||
first_entry(
|
|
||||||
sub {
|
|
||||||
my $date = compiletime;
|
|
||||||
progress_message2 "Converting $fn...";
|
|
||||||
print( $mangle
|
|
||||||
"#\n" ,
|
|
||||||
"# Rules generated from tos file $fn by Shorewall $globals{VERSION} - $date\n" ,
|
|
||||||
"#\n" );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
while ( read_a_line( NORMAL_READ ) ) {
|
|
||||||
|
|
||||||
$have_tos = 1;
|
|
||||||
|
|
||||||
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
|
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
|
||||||
split_line( 'tos file entry',
|
split_rawline2( 'tos file entry',
|
||||||
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } );
|
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 },
|
||||||
|
undef,
|
||||||
|
7 );
|
||||||
|
|
||||||
my $chain_designator = 'P';
|
my $chain_designator = 'P';
|
||||||
|
|
||||||
@@ -2219,8 +2192,62 @@ sub convert_tos($$) {
|
|||||||
$mark = '-' unless supplied $mark;
|
$mark = '-' unless supplied $mark;
|
||||||
|
|
||||||
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
|
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub convert_tos($$) {
|
||||||
|
my ( $mangle, $fn1 ) = @_;
|
||||||
|
|
||||||
|
my $have_tos = 0;
|
||||||
|
|
||||||
|
sub unlink_tos( $ ) {
|
||||||
|
my $fn = shift;
|
||||||
|
|
||||||
|
if ( unlink $fn ) {
|
||||||
|
warning_message "Empty tos file ($fn) removed";
|
||||||
|
} else {
|
||||||
|
warning_message "Unable to remove empty tos file $fn: $!";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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(
|
||||||
|
sub {
|
||||||
|
my $date = compiletime;
|
||||||
|
progress_message2 "Converting $fn...";
|
||||||
|
print( $mangle
|
||||||
|
"#\n" ,
|
||||||
|
"# Rules generated from tos file $fn by Shorewall $globals{VERSION} - $date\n" ,
|
||||||
|
"#\n" );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
|
|
||||||
|
convert_one_tos( $mangle );
|
||||||
|
$have_tos = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
directive_callback(0);
|
||||||
|
|
||||||
if ( $have_tos ) {
|
if ( $have_tos ) {
|
||||||
progress_message2 "Converted $fn to $fn1";
|
progress_message2 "Converted $fn to $fn1";
|
||||||
@@ -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 {
|
||||||
|
@@ -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)
|
||||||
#
|
#
|
||||||
|
@@ -318,6 +318,7 @@ get_config() {
|
|||||||
|
|
||||||
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
||||||
|
|
||||||
|
if [ -z "$g_nopager" ]; then
|
||||||
if [ -n "$PAGER" -a -t 1 ]; then
|
if [ -n "$PAGER" -a -t 1 ]; then
|
||||||
case $PAGER in
|
case $PAGER in
|
||||||
/*)
|
/*)
|
||||||
@@ -334,6 +335,7 @@ get_config() {
|
|||||||
|
|
||||||
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
|
||||||
@@ -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
|
||||||
|
@@ -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
|
||||||
|
@@ -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>-><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>
|
||||||
|
|
||||||
|
@@ -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
|
||||||
{
|
{
|
||||||
|
14
Shorewall6/Macros/macro.mDNSbi
Normal file
14
Shorewall6/Macros/macro.mDNSbi
Normal 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
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
@@ -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>-><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>
|
||||||
|
|
||||||
|
@@ -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>
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user