From 2cbf1e86ad72c9dfa8ced3d8d3275e8bffb93101 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 7 May 2012 11:59:47 -0700 Subject: [PATCH] Allow synonyms for column names in alternate specification formats - gateway and gateways in the tunnels file - mark and action in the tcrules file Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Config.pm | 10 ++++++---- Shorewall/Perl/Shorewall/Tc.pm | 4 ++-- Shorewall/Perl/Shorewall/Tunnels.pm | 3 +-- docs/configuration_file_basics.xml | 9 ++++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 97337581b..f3c8785eb 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -1468,11 +1468,13 @@ sub supplied( $ ) { # supply '-' in omitted trailing columns. # Handles all of the supported forms of column/pair specification # -sub split_line1( $$;$ ) { - my ( $description, $columnsref, $nopad) = @_; +sub split_line1( $$;$$ ) { + my ( $description, $columnsref, $nopad, $maxcolumns ) = @_; - my @maxcolumns = ( sort { $a <=> $b } values %$columnsref ); - my $maxcolumns = ( $maxcolumns[-1] || 0 ) + 1; + unless ( defined $maxcolumns ) { + my @maxcolumns = ( keys %$columnsref ); + $maxcolumns = @maxcolumns; + } # # First see if there is a semicolon on the line; what follows will be column/value paris # diff --git a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm index 2ffa6515f..d50b57b84 100644 --- a/Shorewall/Perl/Shorewall/Tc.pm +++ b/Shorewall/Perl/Shorewall/Tc.pm @@ -197,11 +197,11 @@ sub process_tc_rule( ) { my ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp ); if ( $family == F_IPV4 ) { ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp ) = - split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, probability => 12 , dscp => 13 }; + split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, probability => 12 , dscp => 13 }, undef , 14; $headers = '-'; } else { ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp ) = - split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, headers => 12, probability => 13 , dscp => 14 }; + split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, headers => 12, probability => 13 , dscp => 14 }, undef, 15; } our @tccmd; diff --git a/Shorewall/Perl/Shorewall/Tunnels.pm b/Shorewall/Perl/Shorewall/Tunnels.pm index 8b2a37115..efb6e2ac3 100644 --- a/Shorewall/Perl/Shorewall/Tunnels.pm +++ b/Shorewall/Perl/Shorewall/Tunnels.pm @@ -292,10 +292,9 @@ sub setup_tunnels() { while ( read_a_line( NORMAL_READ ) ) { - my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 'tunnels file', { type => 0, zone => 1, gateway => 2, gateways => 2, gateway_zone => 3 }; + my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 'tunnels file', { type => 0, zone => 1, gateway => 2, gateways => 2, gateway_zone => 3 }, undef, 4; fatal_error 'TYPE must be specified' if $kind eq '-'; - fatal_error 'ZONE must be specified' if $zone eq '-'; if ( $kind eq 'COMMENT' ) { process_comment; diff --git a/docs/configuration_file_basics.xml b/docs/configuration_file_basics.xml index 3d000ca42..ec5a85b2e 100644 --- a/docs/configuration_file_basics.xml +++ b/docs/configuration_file_basics.xml @@ -18,7 +18,7 @@ - 2001-2011 + 2001-2012 Thomas M. Eastep @@ -705,7 +705,9 @@ ACCEPT net:\ tcrules - mark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers + mark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers. + Beginning with Shorewall 4.5.3, 'action' is a synonym for + 'mark'. @@ -717,7 +719,8 @@ ACCEPT net:\ tunnels - type,zone,gateway,gateway_zone + type,zone,gateway,gateway_zone. Beginning with Shorewall + 4.5.3, 'gateways' is a synonym for 'gateway'.