mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-03 03:59:16 +01:00
Implement the -t update option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
3c5975a106
commit
669d15e2cf
@ -3530,6 +3530,7 @@ shorewall_cli() {
|
||||
g_doing="Compiling"
|
||||
g_directives=
|
||||
g_inline=
|
||||
g_tcrules=
|
||||
|
||||
VERBOSE=
|
||||
VERBOSITY=1
|
||||
|
@ -584,8 +584,8 @@ EOF
|
||||
#
|
||||
sub compiler {
|
||||
|
||||
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path, $shorewallrc , $shorewallrc1 , $directives, $inline ) =
|
||||
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '' , '/usr/share/shorewall/shorewallrc', '' , 0 , 0 );
|
||||
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path, $shorewallrc , $shorewallrc1 , $directives, $inline, $tcrules ) =
|
||||
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '' , '/usr/share/shorewall/shorewallrc', '' , 0 , 0 , 0 );
|
||||
|
||||
$export = 0;
|
||||
$test = 0;
|
||||
@ -625,6 +625,7 @@ sub compiler {
|
||||
annotate => { store => \$annotate, validate=> \&validate_boolean } ,
|
||||
inline => { store => \$inline, validate=> \&validate_boolean } ,
|
||||
directives => { store => \$directives, validate=> \&validate_boolean } ,
|
||||
tcrules => { store => \$tcrules, validate=> \&validate_boolean } ,
|
||||
config_path => { store => \$config_path } ,
|
||||
shorewallrc => { store => \$shorewallrc } ,
|
||||
shorewallrc1 => { store => \$shorewallrc1 } ,
|
||||
@ -794,7 +795,7 @@ sub compiler {
|
||||
#
|
||||
# TCRules and Traffic Shaping
|
||||
#
|
||||
setup_tc;
|
||||
setup_tc( $tcrules );
|
||||
|
||||
if ( $scriptfilename || $debug ) {
|
||||
pop_indent;
|
||||
|
@ -4817,7 +4817,9 @@ EOF
|
||||
progress_message3 "No update required to configuration file $configfile";
|
||||
}
|
||||
|
||||
exit 0 unless $directives || -f find_file 'blacklist';
|
||||
exit 0 unless ( $directives ||
|
||||
-f find_file 'blacklist' ||
|
||||
-f find_file 'tcrules' );
|
||||
}
|
||||
} else {
|
||||
fatal_error "$fn does not exist";
|
||||
|
@ -135,6 +135,10 @@ our %restrictions = ( tcpre => PREROUTE_RESTRICT ,
|
||||
|
||||
our $family;
|
||||
|
||||
our $tcrules;
|
||||
|
||||
our $mangle;
|
||||
|
||||
our $divertref; # DIVERT chain
|
||||
|
||||
our %validstates = ( NEW => 0,
|
||||
@ -934,7 +938,18 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tcrules ) {
|
||||
$command = ( $command ? "$command($mark)" : $mark ) . $designator;
|
||||
my $line = ( $family == F_IPV6 ?
|
||||
"$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$headers\t$probability\t$dscp\t$state" :
|
||||
"$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$probability\t$dscp\t$state" );
|
||||
#
|
||||
# Supress superfluous trailinc dashes
|
||||
#
|
||||
$line =~ s/(?:\t-)+$//;
|
||||
|
||||
print $mangle "$line\n";
|
||||
} else {
|
||||
process_mangle_rule1( 'TC',
|
||||
( $command ? "$command($mark)" : $mark ) . $designator ,
|
||||
$source,
|
||||
@ -952,6 +967,7 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
$probability,
|
||||
$dscp,
|
||||
$state );
|
||||
}
|
||||
}
|
||||
|
||||
sub process_tc_rule( ) {
|
||||
@ -3072,7 +3088,8 @@ sub process_secmark_rule() {
|
||||
#
|
||||
# Process the tcrules file and setup traffic shaping
|
||||
#
|
||||
sub setup_tc() {
|
||||
sub setup_tc( $ ) {
|
||||
$tcrules = $_[0];
|
||||
|
||||
if ( $config{MANGLE_ENABLED} ) {
|
||||
ensure_mangle_chain 'tcpre';
|
||||
@ -3126,14 +3143,33 @@ sub setup_tc() {
|
||||
my $fn;
|
||||
|
||||
if ( $fn = open_file( 'tcrules' , 2, 1 ) ) {
|
||||
my $fn1;
|
||||
|
||||
if ( $tcrules ) {
|
||||
#
|
||||
# We are going to convert this tcrules file to the equivalent mangle file
|
||||
#
|
||||
open( $mangle , '>>', $fn1 = find_file('mangle') ) || fatal_error "Unable to open $fn1:$!";
|
||||
}
|
||||
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
process_tc_rule, $have_tcrules++ while read_a_line( NORMAL_READ );
|
||||
|
||||
if ( $have_tcrules ) {
|
||||
warning_message "Non-empty tcrules file ($fn); please move its contents to the mangle file";
|
||||
if ( $mangle ) {
|
||||
progress_message2 "Converted $fn to $fn1";
|
||||
if ( rename $fn, "$fn.bak" ) {
|
||||
progress_message2 "$fn renamed $fn.bak";
|
||||
} else {
|
||||
fatal_error "Cannot Rename $fn to $fn.bak: $!";
|
||||
}
|
||||
} else {
|
||||
warning_message "Non-empty tcrules file ($fn); consider running '$product update -t'";
|
||||
}
|
||||
}
|
||||
|
||||
close $mangle if $tcrules;
|
||||
}
|
||||
|
||||
if ( my $fn = open_file( 'mangle', 1, 1 ) ) {
|
||||
|
@ -41,6 +41,7 @@
|
||||
# --shorewallrc1=<path> # Path to export shorewallrc file.
|
||||
# --config_path=<path-list> # Search path for config files
|
||||
# --inline # Update alternative column specifications
|
||||
# --tcrules # Create mangle from tcrules
|
||||
#
|
||||
use strict;
|
||||
use FindBin;
|
||||
@ -75,6 +76,7 @@ usage: compiler.pl [ <option> ... ] [ <filename> ]
|
||||
[ --shorewallrc1=<pathname> ]
|
||||
[ --config_path=<path-list> ]
|
||||
[ --inline ]
|
||||
[ --tcrules ]
|
||||
_EOF_
|
||||
|
||||
exit shift @_;
|
||||
@ -104,6 +106,7 @@ my $config_path = '';
|
||||
my $shorewallrc = '';
|
||||
my $shorewallrc1 = '';
|
||||
my $inline = 0;
|
||||
my $tcrules = 0;
|
||||
|
||||
Getopt::Long::Configure ('bundling');
|
||||
|
||||
@ -137,6 +140,7 @@ my $result = GetOptions('h' => \$help,
|
||||
'update' => \$update,
|
||||
'convert' => \$convert,
|
||||
'inline' => \$inline,
|
||||
'tcrules' => \$tcrules,
|
||||
'config_path=s' => \$config_path,
|
||||
'shorewallrc=s' => \$shorewallrc,
|
||||
'shorewallrc1=s' => \$shorewallrc1,
|
||||
@ -165,5 +169,6 @@ compiler( script => $ARGV[0] || '',
|
||||
config_path => $config_path,
|
||||
shorewallrc => $shorewallrc,
|
||||
shorewallrc1 => $shorewallrc1,
|
||||
inline => $inline
|
||||
inline => $inline,
|
||||
tcrules => $tcrules,
|
||||
);
|
||||
|
@ -422,6 +422,7 @@ compiler() {
|
||||
[ -n "$g_convert" ] && options="$options --convert"
|
||||
[ -n "$g_annotate" ] && options="$options --annotate"
|
||||
[ -n "$g_directives" ] && options="$options --directives"
|
||||
[ -n "$g_tcrules" ] && options="$options --tcrules"
|
||||
[ -n "$g_inline" ] && options="$options --inline"
|
||||
|
||||
if [ -n "$PERL" ]; then
|
||||
@ -841,6 +842,17 @@ update_command() {
|
||||
g_directives=Yes
|
||||
option=${option#D}
|
||||
;;
|
||||
t*)
|
||||
g_tcrules=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
A*)
|
||||
g_inline=Yes
|
||||
g_convert=Yes
|
||||
g_directives=Yes
|
||||
g_tcrules=Yes
|
||||
option=${option#A}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@ -1686,7 +1698,7 @@ usage() # $1 = exit status
|
||||
echo " status"
|
||||
echo " stop"
|
||||
echo " try <directory> [ <timeout> ]"
|
||||
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [ <directory> ]"
|
||||
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]"
|
||||
echo " version [ -a ]"
|
||||
echo
|
||||
exit $1
|
||||
|
Loading…
Reference in New Issue
Block a user