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 <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-05-07 11:59:47 -07:00
parent dd8e9ff09d
commit 2cbf1e86ad
4 changed files with 15 additions and 11 deletions

View File

@ -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
#

View File

@ -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;

View File

@ -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;

View File

@ -18,7 +18,7 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright>
<year>2001-2011</year>
<year>2001-2012</year>
<holder>Thomas M. Eastep</holder>
</copyright>
@ -705,7 +705,9 @@ ACCEPT net:\
<row>
<entry>tcrules</entry>
<entry>mark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers</entry>
<entry>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'.</entry>
</row>
<row>
@ -717,7 +719,8 @@ ACCEPT net:\
<row>
<entry>tunnels</entry>
<entry>type,zone,gateway,gateway_zone</entry>
<entry>type,zone,gateway,gateway_zone. Beginning with Shorewall
4.5.3, 'gateways' is a synonym for 'gateway'.</entry>
</row>
<row>