mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-23 14:48:51 +01:00
Better ACCOUNT(...) parsing
This commit is contained in:
parent
f8e6c80ca0
commit
4e7f656a5b
@ -102,17 +102,21 @@ sub process_accounting_rule( ) {
|
||||
unless ( $action eq 'COUNT' ) {
|
||||
if ( $action eq 'DONE' ) {
|
||||
$target = 'RETURN';
|
||||
} elsif ( $action =~ /^ACCOUNT\((.+)\)$/ ) {
|
||||
require_capability 'ACCOUNT_TARGET' , 'ACCOUNT Rules' , '';
|
||||
my ( $table, $net, $rest ) = split/,/, $1;
|
||||
fatal_error "Invalid Network Address (${net}${rest})" if defined $rest;
|
||||
fatal_error "Missing Table Name" unless defined $table && $table ne '';;
|
||||
fatal_error "Invalid Table Name ($table)" unless $table =~ /^([-\w.]+)$/;
|
||||
fatal_error "Missing Network Address" unless defined $net;
|
||||
fatal_error "Invalid Network Address ($net)" unless defined $net && $net =~ '/(\d+)$';
|
||||
fatal_error "Netmask ($1) out of range" unless $1 >= 8;
|
||||
validate_net $net, 0;
|
||||
$target = "ACCOUNT --addr $net --tname $table";
|
||||
} elsif ( $action =~ /^ACCOUNT\(/ ) {
|
||||
if ( $action =~ /^ACCOUNT\((.+)\)$/ ) {
|
||||
require_capability 'ACCOUNT_TARGET' , 'ACCOUNT Rules' , '';
|
||||
my ( $table, $net, $rest ) = split/,/, $1;
|
||||
fatal_error "Invalid Network Address (${net},${rest})" if defined $rest;
|
||||
fatal_error "Missing Table Name" unless defined $table && $table ne '';;
|
||||
fatal_error "Invalid Table Name ($table)" unless $table =~ /^([-\w.]+)$/;
|
||||
fatal_error "Missing Network Address" unless defined $net;
|
||||
fatal_error "Invalid Network Address ($net)" unless defined $net && $net =~ '/(\d+)$';
|
||||
fatal_error "Netmask ($1) out of range" unless $1 >= 8;
|
||||
validate_net $net, 0;
|
||||
$target = "ACCOUNT --addr $net --tname $table";
|
||||
} else {
|
||||
fatal_error "Invalid ACCOUNT Action";
|
||||
}
|
||||
} else {
|
||||
( $action, my $cmd ) = split /:/, $action;
|
||||
if ( $cmd ) {
|
||||
|
@ -1262,6 +1262,7 @@ sub ensure_accounting_chain( $$ )
|
||||
fatal_error "Non-accounting chain ($chain) used in an accounting rule" unless $chainref->{accounting};
|
||||
} else {
|
||||
fatal_error "Chain name ($chain) too long" if length $chain > 29;
|
||||
fatal_error "Invalid Chain name ($chain)" unless $chain =~ /^[-\w.]+$/;
|
||||
$chainref = new_chain 'filter' , $chain;
|
||||
$chainref->{accounting} = 1;
|
||||
$chainref->{referenced} = 1;
|
||||
@ -1350,6 +1351,7 @@ sub new_nat_chain($) {
|
||||
sub new_manual_chain($) {
|
||||
my $chain = $_[0];
|
||||
fatal_error "Chain name ($chain) too long" if length $chain > 29;
|
||||
fatal_error "Invalid Chain name ($chain)" unless $chain =~ /^[-\w.]+$/;
|
||||
fatal_error "Duplicate Chain Name ($chain)" if $targets{$chain} || $filter_table->{$chain};
|
||||
$targets{$chain} = CHAIN;
|
||||
( my $chainref = ensure_filter_chain( $chain, 0) )->{manual} = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user