mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-24 19:51:40 +02:00
Centralize interface to $ENV{}
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5772 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
272bf85b1e
commit
505f1ba3e0
@ -76,6 +76,8 @@ our ( $command, $doing, $done ) = qw/ compile Compiling Compiled/; #describe the
|
|||||||
|
|
||||||
our $verbose;
|
our $verbose;
|
||||||
|
|
||||||
|
my $timestamp;
|
||||||
|
|
||||||
my $object = 0; # Object file Handle Reference
|
my $object = 0; # Object file Handle Reference
|
||||||
my $lastlineblank = 0; # Avoid extra blank lines in the output
|
my $lastlineblank = 0; # Avoid extra blank lines in the output
|
||||||
my $indent = '';
|
my $indent = '';
|
||||||
@ -83,7 +85,8 @@ my ( $dir, $file ); # Object's Directory and File
|
|||||||
my $tempfile; # Temporary File Name
|
my $tempfile; # Temporary File Name
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
$verbose = $ENV{VERBOSE} || 0;
|
$verbose = $ENV{VERBOSE} || 0;
|
||||||
|
$timestamp = $ENV{TIMESTAMP} || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -180,7 +183,7 @@ sub timestamp() {
|
|||||||
|
|
||||||
sub progress_message {
|
sub progress_message {
|
||||||
if ( $verbose > 1 ) {
|
if ( $verbose > 1 ) {
|
||||||
timestamp if $ENV{TIMESTAMP};
|
timestamp if $timestamp;
|
||||||
my $line = join( ' ', @_ );
|
my $line = join( ' ', @_ );
|
||||||
$line =~ s/\s+/ /g;
|
$line =~ s/\s+/ /g;
|
||||||
print "$line\n";
|
print "$line\n";
|
||||||
@ -189,14 +192,14 @@ sub progress_message {
|
|||||||
|
|
||||||
sub progress_message2 {
|
sub progress_message2 {
|
||||||
if ( $verbose > 0 ) {
|
if ( $verbose > 0 ) {
|
||||||
timestamp if $ENV{TIMESTAMP};
|
timestamp if $timestamp;
|
||||||
print "@_\n";
|
print "@_\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub progress_message3 {
|
sub progress_message3 {
|
||||||
if ( $verbose >= 0 ) {
|
if ( $verbose >= 0 ) {
|
||||||
timestamp if $ENV{TIMESTAMP};
|
timestamp if $timestamp;
|
||||||
print "@_\n";
|
print "@_\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,12 +286,13 @@ sub create_temp_object( $ ) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub finalize_object() {
|
sub finalize_object( $ ) {
|
||||||
|
my $export = $_[0];
|
||||||
close $object;
|
close $object;
|
||||||
$object = 0;
|
$object = 0;
|
||||||
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";
|
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";
|
||||||
chmod 0700, $file;
|
chmod 0700, $file;
|
||||||
progress_message3 "Shorewall configuration compiled to $file" unless $ENV{EXPORT};
|
progress_message3 "Shorewall configuration compiled to $file" unless $export;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub create_temp_aux_config() {
|
sub create_temp_aux_config() {
|
||||||
@ -313,11 +317,6 @@ END {
|
|||||||
unlink $tempfile;
|
unlink $tempfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $exitstatus = $?; #Changed by system()
|
|
||||||
|
|
||||||
system "rm -rf $ENV{TMP_DIR}" if $ENV{TMP_DIR};
|
|
||||||
|
|
||||||
$? = $exitstatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -224,6 +224,11 @@ my @openstack;
|
|||||||
my $currentfile;
|
my $currentfile;
|
||||||
my $currentfilename;
|
my $currentfilename;
|
||||||
my $currentlinenumber = 0;
|
my $currentlinenumber = 0;
|
||||||
|
my $tmp_dir;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$tmp_dir = $ENV{TMP_DIR};
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Issue a Warning Message
|
# Issue a Warning Message
|
||||||
@ -499,7 +504,7 @@ sub get_configuration() {
|
|||||||
fatal_error "$file does not exist!";
|
fatal_error "$file does not exist!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = "$ENV{TMP_DIR}/capabilities";
|
$file = "$tmp_dir/capabilities";
|
||||||
|
|
||||||
if ( -f $file ) {
|
if ( -f $file ) {
|
||||||
if ( -r _ ) {
|
if ( -r _ ) {
|
||||||
@ -764,4 +769,14 @@ sub generate_aux_config() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
if ( $tmp_dir ) {
|
||||||
|
my $exitstatus = $?; #Changed by system()
|
||||||
|
|
||||||
|
system "rm -rf $tmp_dir";
|
||||||
|
|
||||||
|
$? = $exitstatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -60,6 +60,12 @@ use Shorewall::Rules;
|
|||||||
use Shorewall::Proc;
|
use Shorewall::Proc;
|
||||||
use Shorewall::Proxyarp;
|
use Shorewall::Proxyarp;
|
||||||
|
|
||||||
|
my $export;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$export = $ENV{EXPORT};
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# First stage of script generation.
|
# First stage of script generation.
|
||||||
#
|
#
|
||||||
@ -75,7 +81,7 @@ sub generate_script_1 {
|
|||||||
|
|
||||||
emit "#\n# Compiled firewall script generated by Shorewall-perl $env{VERSION} - $date\n#";
|
emit "#\n# Compiled firewall script generated by Shorewall-perl $env{VERSION} - $date\n#";
|
||||||
|
|
||||||
if ( $ENV{EXPORT} ) {
|
if ( $export ) {
|
||||||
emitj ( 'SHAREDIR=/usr/share/shorewall-lite',
|
emitj ( 'SHAREDIR=/usr/share/shorewall-lite',
|
||||||
'CONFDIR=/etc/shorewall-lite',
|
'CONFDIR=/etc/shorewall-lite',
|
||||||
'VARDIR=/var/lib/shorewall-lite',
|
'VARDIR=/var/lib/shorewall-lite',
|
||||||
@ -114,7 +120,7 @@ sub generate_script_1 {
|
|||||||
|
|
||||||
push_indent;
|
push_indent;
|
||||||
|
|
||||||
if ( $ENV{EXPORT} ) {
|
if ( $export ) {
|
||||||
emitj ( '#',
|
emitj ( '#',
|
||||||
'# These variables are required by the library functions called in this script',
|
'# These variables are required by the library functions called in this script',
|
||||||
'#',
|
'#',
|
||||||
@ -158,7 +164,7 @@ sub generate_script_1 {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
append_file 'params' if $config{EXPORTPARAMS};
|
append_file 'params' if $export;
|
||||||
|
|
||||||
emitj ( '',
|
emitj ( '',
|
||||||
"STOPPING=",
|
"STOPPING=",
|
||||||
@ -486,7 +492,7 @@ sub generate_script_2 () {
|
|||||||
|
|
||||||
save_progress_message 'Initializing...';
|
save_progress_message 'Initializing...';
|
||||||
|
|
||||||
if ( $ENV{EXPORT} ) {
|
if ( $export ) {
|
||||||
my $mf = find_file 'modules';
|
my $mf = find_file 'modules';
|
||||||
|
|
||||||
if ( $mf ne "$env{SHAREDIR}/module" && -f $mf ) {
|
if ( $mf ne "$env{SHAREDIR}/module" && -f $mf ) {
|
||||||
@ -635,7 +641,7 @@ sub compiler( $ ) {
|
|||||||
|
|
||||||
my $objectfile = $_[0];
|
my $objectfile = $_[0];
|
||||||
|
|
||||||
report_capabilities if $ENV{VERBOSE} > 1;
|
report_capabilities if $verbose > 1;
|
||||||
|
|
||||||
require_capability( 'MULTIPORT' , "Shorewall-perl $env{VERSION}" );
|
require_capability( 'MULTIPORT' , "Shorewall-perl $env{VERSION}" );
|
||||||
require_capability( 'ADDRTYPE' , "Shorewall-perl $env{VERSION}" );
|
require_capability( 'ADDRTYPE' , "Shorewall-perl $env{VERSION}" );
|
||||||
@ -774,11 +780,11 @@ sub compiler( $ ) {
|
|||||||
#
|
#
|
||||||
# Finish the script.
|
# Finish the script.
|
||||||
#
|
#
|
||||||
finalize_object;
|
finalize_object ( $export );
|
||||||
#
|
#
|
||||||
# And generate the auxilary config file
|
# And generate the auxilary config file
|
||||||
#
|
#
|
||||||
generate_aux_config if $ENV{EXPORT};
|
generate_aux_config if $export;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user