forked from extern/shorewall_code
Preserve shell variables when converting tos->mangle
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
c5b393a074
commit
d105da3964
@ -2150,41 +2150,14 @@ sub process_secmark_rule() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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' ) {
|
||||
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;
|
||||
sub convert_one_tos( $ ) {
|
||||
my ( $mangle ) = @_;
|
||||
|
||||
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 } );
|
||||
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';
|
||||
|
||||
@ -2219,7 +2192,59 @@ sub convert_tos($$) {
|
||||
$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($$) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ( $have_tos ) {
|
||||
|
Loading…
Reference in New Issue
Block a user