mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-30 14:42:01 +02:00
Declare passed() in Shorewall::User rather than importing it from Config
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
@ -61,7 +61,6 @@ our @EXPORT = qw(
|
|||||||
progress_message3
|
progress_message3
|
||||||
|
|
||||||
supplied
|
supplied
|
||||||
passed
|
|
||||||
split_list
|
split_list
|
||||||
|
|
||||||
shorewall
|
shorewall
|
||||||
@ -87,7 +86,7 @@ our @EXPORT = qw(
|
|||||||
kernel_version
|
kernel_version
|
||||||
);
|
);
|
||||||
|
|
||||||
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall passed);
|
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
|
||||||
|
|
||||||
our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||||
generate_sha1
|
generate_sha1
|
||||||
@ -672,6 +671,8 @@ our %variables; # Symbol table for expanding shell variables
|
|||||||
|
|
||||||
our $section_function; #Function Reference for handling ?section
|
our $section_function; #Function Reference for handling ?section
|
||||||
|
|
||||||
|
our $evals = 0; # Number of times eval() called out of evaluate_expression() or embedded_perl().
|
||||||
|
|
||||||
sub process_shorewallrc($$);
|
sub process_shorewallrc($$);
|
||||||
sub add_variables( \% );
|
sub add_variables( \% );
|
||||||
#
|
#
|
||||||
@ -2513,6 +2514,21 @@ sub join_parts( $$$ ) {
|
|||||||
join( '', $first, $val, $rest );
|
join( '', $first, $val, $rest );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Declare passed() in Shorewall::User
|
||||||
|
#
|
||||||
|
sub declare_passed() {
|
||||||
|
my $result = ( eval q(package Shorewall::User;
|
||||||
|
use strict;
|
||||||
|
sub passed( $ ) {
|
||||||
|
my $val = shift;
|
||||||
|
defined $val && $val ne '' && $val ne '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
1;) );
|
||||||
|
assert( $result, $@ );
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Evaluate an expression in an ?IF, ?ELSIF, ?SET or ?ERROR directive
|
# Evaluate an expression in an ?IF, ?ELSIF, ?SET or ?ERROR directive
|
||||||
#
|
#
|
||||||
@ -2593,9 +2609,11 @@ sub evaluate_expression( $$$$ ) {
|
|||||||
#
|
#
|
||||||
# Not a simple one-term expression -- compile it
|
# Not a simple one-term expression -- compile it
|
||||||
#
|
#
|
||||||
|
|
||||||
|
declare_passed unless $evals++;
|
||||||
|
|
||||||
$val = eval qq(package Shorewall::User;
|
$val = eval qq(package Shorewall::User;
|
||||||
use strict;
|
use strict;
|
||||||
use Shorewall::Config \(qw/supplied/\);
|
|
||||||
# line $linenumber "$filename"
|
# line $linenumber "$filename"
|
||||||
$expression);
|
$expression);
|
||||||
|
|
||||||
@ -3161,7 +3179,7 @@ sub embedded_shell( $ ) {
|
|||||||
sub embedded_perl( $ ) {
|
sub embedded_perl( $ ) {
|
||||||
my $multiline = shift;
|
my $multiline = shift;
|
||||||
|
|
||||||
my ( $command , $linenumber ) = ( qq(package Shorewall::User;\nno strict;\nuse Shorewall::Config (qw/shorewall supplied/);\n# line $currentlinenumber "$currentfilename"\n$currentline), $currentlinenumber );
|
my ( $command , $linenumber ) = ( qq(package Shorewall::User;\nno strict;\n# line $currentlinenumber "$currentfilename"\n$currentline), $currentlinenumber );
|
||||||
|
|
||||||
$directive_callback->( 'PERL', $currentline ) if $directive_callback;
|
$directive_callback->( 'PERL', $currentline ) if $directive_callback;
|
||||||
|
|
||||||
@ -3188,6 +3206,8 @@ sub embedded_perl( $ ) {
|
|||||||
|
|
||||||
$embedded++;
|
$embedded++;
|
||||||
|
|
||||||
|
declare_passed unless $evals++;
|
||||||
|
|
||||||
unless (my $return = eval $command ) {
|
unless (my $return = eval $command ) {
|
||||||
#
|
#
|
||||||
# Perl found the script offensive or the script itself died
|
# Perl found the script offensive or the script itself died
|
||||||
@ -6569,6 +6589,7 @@ sub report_used_capabilities() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
|
print "eval() called $evals times\n" if $debug;
|
||||||
cleanup;
|
cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user