From 83a9d8dd1b03acecd70fc1b27ed5edc9134e6743 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 5 Oct 2009 15:43:29 -0700 Subject: [PATCH] Rename 'object' to 'script' --- Shorewall/Perl/Shorewall/Compiler.pm | 44 ++++---- Shorewall/Perl/Shorewall/Config.pm | 154 +++++++++++++-------------- Shorewall/changelog.txt | 2 + 3 files changed, 101 insertions(+), 99 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index ac7b958a0..b9a777bf8 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -129,7 +129,7 @@ EOF # Generate the 'initialize()' function. # # Note: This function is not called when $command eq 'check'. So it must have no side effects other -# than those related to writing to the object file. +# than those related to writing to the output script file. sub generate_script_2() { @@ -291,7 +291,7 @@ sub generate_script_2() { # Generate the 'define_firewall()' function. # # Note: This function is not called when $command eq 'check'. So it must have no side effects other -# than those related to writing to the object file. +# than those related to writing to the output script file. # sub generate_script_3($) { @@ -524,7 +524,7 @@ EOF # sub compiler { - my ( $objectfile, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity ) = + my ( $scriptfile, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity ) = ( '', '', -1, '', 0, '', '', -1 ); $export = 0; @@ -545,7 +545,7 @@ sub compiler { defined($val) && ($val == F_IPV4 || $val == F_IPV6); } - my %parms = ( object => { store => \$objectfile }, + my %parms = ( object => { store => \$scriptfile }, directory => { store => \$directory }, family => { store => \$family , validate => \&validate_family } , verbosity => { store => \$verbosity , validate => \&validate_verbosity } , @@ -596,9 +596,9 @@ sub compiler { require_capability( 'XCONNMARK' , 'HIGH_ROUTE_MARKS=Yes' , 's' ) if $config{HIGH_ROUTE_MARKS}; require_capability( 'MANGLE_ENABLED' , 'Traffic Shaping' , 's' ) if $config{TC_ENABLED}; - if ( $objectfile ) { + if ( $scriptfile ) { set_command( 'compile', 'Compiling', 'Compiled' ); - create_temp_object( $objectfile , $export ); + create_temp_script( $scriptfile , $export ); } else { set_command( 'check', 'Checking', 'Checked' ); } @@ -644,11 +644,11 @@ sub compiler { # setup_notrack; - enable_object; + enable_script; - if ( $objectfile ) { + if ( $scriptfile ) { # - # Place Header in the object + # Place Header in the script # generate_script_1; # @@ -686,20 +686,20 @@ sub compiler { # setup_zone_mss; - if ( $objectfile ) { + if ( $scriptfile ) { emit 'return 0'; pop_indent; emit '}'; } - disable_object; + disable_script; # # R O U T I N G _ A N D _ T R A F F I C _ S H A P I N G # (Writes the setup_routing_and_traffic_shaping() function to the compiled script) # - enable_object; + enable_script; - if ( $objectfile ) { + if ( $scriptfile ) { emit( "\n#", '# Setup routing and traffic shaping', '#', @@ -717,12 +717,12 @@ sub compiler { # setup_tc; - if ( $objectfile ) { + if ( $scriptfile ) { pop_indent; emit "}\n"; } - disable_object; + disable_script; # # N E T F I L T E R # (Produces no output to the compiled script -- rules are stored in the chain table) @@ -778,13 +778,13 @@ sub compiler { # setup_accounting; - if ( $objectfile ) { + if ( $scriptfile ) { # # Generate the zone by zone matrix # generate_matrix; - enable_object; + enable_script; # # I N I T I A L I Z E # (Writes the initialize() function to the compiled script) @@ -807,7 +807,7 @@ sub compiler { # compile_stop_firewall( $test ); # - # Copy the footer to the object + # Copy the footer to the script # unless ( $test ) { if ( $family == F_IPV4 ) { @@ -817,15 +817,15 @@ sub compiler { } } - disable_object; + disable_script; # - # Close, rename and secure the object + # Close, rename and secure the script # - finalize_object ( $export ); + finalize_script ( $export ); # # And generate the auxilary config file # - enable_object, generate_aux_config if $export; + enable_script, generate_aux_config if $export; } else { # # Re-initialize the chain table so that process_routestopped() has the same diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index a0b5a9990..f55f98a91 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -24,7 +24,7 @@ # It also exports functions for generating warning and error messages. # The get_configuration function parses the shorewall.conf, capabilities and # modules files during compiler startup. The module also provides the basic -# output file services such as creation of temporary 'object' files, writing +# output file services such as creation of temporary 'script' files, writing # into those files (emitters) and finalizing those files (renaming # them to their final name and setting their mode appropriately). # @@ -54,10 +54,10 @@ our @EXPORT = qw( our @EXPORT_OK = qw( $shorewall_dir initialize read_a_line1 set_config_path shorewall); -our %EXPORT_TAGS = ( internal => [ qw( create_temp_object - finalize_object - enable_object - disable_object +our %EXPORT_TAGS = ( internal => [ qw( create_temp_script + finalize_script + enable_script + disable_script numeric_value numeric_value1 hex_value @@ -146,13 +146,13 @@ our ( $log, $log_verbosity ); # our $timestamp; # -# Object file handle +# Script (output) file handle # -our $object; +our $script; # -# When 'true', writes to the object are enabled. Used to catch code emission between functions +# When 'true', writes to the script are enabled. Used to catch code emission between functions # -our $object_enabled; +our $script_enabled; # # True, if last line emitted is blank # @@ -170,7 +170,7 @@ our $indent2; # our $indent; # -# Object's Directory and File +# Script's Directory and File # our ( $dir, $file ); # @@ -186,7 +186,7 @@ our %globals; # our %config; # -# Config options and global settings that are to be copied to object script +# Config options and global settings that are to be copied to output script # our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOGFORMAT SUBSYSLOCK LOCKFILE /; our @propagateenv = qw/ LOGLIMIT LOGTAGONLY LOGRULENUMBERS /; @@ -262,8 +262,8 @@ our $currentline; # Current config file line image our $currentfile; # File handle reference our $currentfilename; # File NAME our $currentlinenumber; # Line number -our $scriptfile; # File Handle Reference to current temporary file being written by an in-line Perl script -our $scriptfilename; # Name of that file. +our $perlscript; # File Handle Reference to current temporary file being written by an in-line Perl script +our $perlscriptname; # Name of that file. our @tempfiles; # Files that need unlinking at END our $first_entry; # Message to output or function to call on first non-blank line of a file @@ -308,13 +308,13 @@ sub initialize( $ ) { $log = undef; # File reference for log file $log_verbosity = -1; # Verbosity of log. $timestamp = ''; # If true, we are to timestamp each progress message - $object = 0; # Object (script) file Handle Reference - $object_enabled = 0; # Object (script) file Handle Reference + $script = 0; # Script (output) file Handle Reference + $script_enabled = 0; # Writing to output file is disabled initially $lastlineblank = 0; # Avoid extra blank lines in the output $indent1 = ''; # Current indentation tabs $indent2 = ''; # Current indentation spaces $indent = ''; # Current total indentation - ( $dir, $file ) = ('',''); # Object's Directory and File + ( $dir, $file ) = ('',''); # Script's Directory and Filename $tempfile = ''; # Temporary File Name # @@ -685,14 +685,14 @@ sub cleanup() { # # Close files first in case we're running under Cygwin # - close $object, $object = undef if $object; - close $scriptfile, $scriptfile = undef if $scriptfile; + close $script, $script = undef if $script; + close $perlscript, $perlscript = undef if $perlscript; close $log, $log = undef if $log; # # Unlink temporary files # unlink ( $tempfile ), $tempfile = undef if $tempfile; - unlink ( $scriptfilename ), $scriptfilename = undef if $scriptfilename; + unlink ( $perlscriptname ), $perlscriptname = undef if $perlscriptname; unlink ( @tempfiles ), @tempfiles = () if @tempfiles; } @@ -815,14 +815,14 @@ sub in_hexp( $ ) { } # -# Write the arguments to the object file (if any) with the current indentation. +# Write the arguments to the script file (if any) with the current indentation. # # Replaces leading spaces with tabs as appropriate and suppresses consecutive blank lines. # sub emit { - assert( $object_enabled ); + assert( $script_enabled ); - if ( $object ) { + if ( $script ) { # # 'compile' as opposed to 'check' # @@ -832,10 +832,10 @@ sub emit { $line =~ s/^\n// if $lastlineblank; $line =~ s/^/$indent/gm if $indent; $line =~ s/ /\t/gm; - print $object "$line\n"; + print $script "$line\n"; $lastlineblank = ( substr( $line, -1, 1 ) eq "\n" ); } else { - print $object "\n" unless $lastlineblank; + print $script "\n" unless $lastlineblank; $lastlineblank = 1; } } @@ -843,26 +843,26 @@ sub emit { } # -# Write passed message to the object with newline but no indentation. +# Write passed message to the script with newline but no indentation. # sub emit_unindented( $ ) { - assert( $object_enabled ); + assert( $script_enabled ); - print $object "$_[0]\n" if $object; + print $script "$_[0]\n" if $script; } # # Write a progress_message2 command with surrounding blank lines to the output file. # sub save_progress_message( $ ) { - emit "\nprogress_message2 @_\n" if $object; + emit "\nprogress_message2 @_\n" if $script; } # # Write a progress_message command to the output file. # sub save_progress_message_short( $ ) { - emit "progress_message $_[0]" if $object; + emit "progress_message $_[0]" if $script; } # @@ -1036,12 +1036,12 @@ sub pop_indent() { } # -# Functions for copying files into the object +# Functions for copying files into the script # sub copy( $ ) { - assert( $object_enabled ); + assert( $script_enabled ); - if ( $object ) { + if ( $script ) { my $file = $_[0]; open IF , $file or fatal_error "Unable to open $file: $!"; @@ -1049,7 +1049,7 @@ sub copy( $ ) { while ( ) { chomp; if ( /^\s*$/ ) { - print $object "\n" unless $lastlineblank; + print $script "\n" unless $lastlineblank; $lastlineblank = 1; } else { if ( $indent ) { @@ -1057,8 +1057,8 @@ sub copy( $ ) { s/ /\t/ if $indent2; } - print $object $_; - print $object "\n"; + print $script $_; + print $script "\n"; $lastlineblank = 0; } } @@ -1071,11 +1071,11 @@ sub copy( $ ) { # This one handles line continuation and 'here documents' sub copy1( $ ) { - assert( $object_enabled ); + assert( $script_enabled ); my $result = 0; - if ( $object ) { + if ( $script ) { my $file = $_[0]; open IF , $file or fatal_error "Unable to open $file: $!"; @@ -1086,8 +1086,8 @@ sub copy1( $ ) { chomp; if ( /^${here_documents}\s*$/ ) { - print $object $here_documents if $here_documents; - print $object "\n"; + print $script $here_documents if $here_documents; + print $script "\n"; $do_indent = 1; $here_documents = ''; next; @@ -1098,8 +1098,8 @@ sub copy1( $ ) { s/^(\s*)/$indent1$1$indent2/; s/ /\t/ if $indent2; $do_indent = 0; - print $object $_; - print $object "\n"; + print $script $_; + print $script "\n"; $result = 1; next; } @@ -1109,8 +1109,8 @@ sub copy1( $ ) { s/ /\t/ if $indent2; } - print $object $_; - print $object "\n"; + print $script $_; + print $script "\n"; $do_indent = ! ( $here_documents || /\\$/ ); $result = 1 unless $result || /^\s*$/ || /^\s*#/; @@ -1125,23 +1125,23 @@ sub copy1( $ ) { } # -# Create the temporary object file -- the passed file name is the name of the final file. +# Create the temporary script file -- the passed file name is the name of the final file. # We create a temporary file in the same directory so that we can use rename to finalize it. # -sub create_temp_object( $$ ) { - my ( $objectfile, $export ) = @_; +sub create_temp_script( $$ ) { + my ( $scriptfile, $export ) = @_; my $suffix; - if ( $objectfile eq '-' ) { + if ( $scriptfile eq '-' ) { $verbosity = -1; - $object = undef; - open( $object, '>&STDOUT' ) or fatal_error "Open of STDOUT failed"; + $script = undef; + open( $script, '>&STDOUT' ) or fatal_error "Open of STDOUT failed"; $file = '-'; return 1; } eval { - ( $file, $dir, $suffix ) = fileparse( $objectfile ); + ( $file, $dir, $suffix ) = fileparse( $scriptfile ); }; cleanup, die if $@; @@ -1149,14 +1149,14 @@ sub create_temp_object( $$ ) { fatal_error "$dir is a Symbolic Link" if -l $dir; fatal_error "Directory $dir does not exist" unless -d _; fatal_error "Directory $dir is not writable" unless -w _; - fatal_error "$objectfile is a Symbolic Link" if -l $objectfile; - fatal_error "$objectfile is a Directory" if -d _; - fatal_error "$objectfile exists and is not a compiled script" if -e _ && ! -x _; + fatal_error "$scriptfile is a Symbolic Link" if -l $scriptfile; + fatal_error "$scriptfile is a Directory" if -d _; + fatal_error "$scriptfile exists and is not a compiled script" if -e _ && ! -x _; fatal_error "An exported \u$globals{PRODUCT} compiled script may not be named '$globals{PRODUCT}'" if $export && "$file" eq $globals{PRODUCT} && $suffix eq ''; eval { $dir = abs_path $dir unless $dir =~ m|^/|; # Work around http://rt.cpan.org/Public/Bug/Display.html?id=13851 - ( $object, $tempfile ) = tempfile ( 'tempfileXXXX' , DIR => $dir ); + ( $script, $tempfile ) = tempfile ( 'tempfileXXXX' , DIR => $dir ); }; fatal_error "Unable to create temporary file in directory $dir" if $@; @@ -1168,12 +1168,12 @@ sub create_temp_object( $$ ) { } # -# Finalize the object file +# Finalize the script file # -sub finalize_object( $ ) { +sub finalize_script( $ ) { my $export = $_[0]; - close $object; - $object = 0; + close $script; + $script = 0; if ( $file ne '-' ) { rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!"; @@ -1187,7 +1187,7 @@ sub finalize_object( $ ) { # sub create_temp_aux_config() { eval { - ( $object, $tempfile ) = tempfile ( 'tempfileXXXX' , DIR => $dir ); + ( $script, $tempfile ) = tempfile ( 'tempfileXXXX' , DIR => $dir ); }; cleanup, die if $@; @@ -1197,24 +1197,24 @@ sub create_temp_aux_config() { # Finalize the aux config file. # sub finalize_aux_config() { - close $object; - $object = 0; + close $script; + $script = 0; rename $tempfile, "$file.conf" or fatal_error "Cannot Rename $tempfile to $file.conf: $!"; progress_message3 "Shorewall configuration compiled to $file"; } # -# Enable writes to the object file +# Enable writes to the script file # -sub enable_object() { - $object_enabled = 1; +sub enable_script() { + $script_enabled = 1; } # -# Disable writes to the object file +# Disable writes to the script file # -sub disable_object() { - $object_enabled = 0; +sub disable_script() { + $script_enabled = 0; } # @@ -1431,19 +1431,19 @@ sub pop_open() { # processed as regular file input. # sub shorewall { - unless ( $scriptfile ) { + unless ( $perlscript ) { fatal_error "shorewall() may not be called in this context" unless $currentfile; $dir ||= '/tmp/'; eval { - ( $scriptfile, $scriptfilename ) = tempfile ( 'scriptfileXXXX' , DIR => $dir ); + ( $perlscript, $perlscriptname ) = tempfile ( 'perlscriptXXXX' , DIR => $dir ); }; fatal_error "Unable to create temporary file in directory $dir" if $@; } - print $scriptfile "@_\n"; + print $perlscript "@_\n"; } # @@ -1545,21 +1545,21 @@ sub embedded_perl( $ ) { fatal_error "Perl Script Returned False"; } - if ( $scriptfile ) { + if ( $perlscript ) { fatal_error "INCLUDEs nested too deeply" if @includestack >= 4; - close $scriptfile or assert(0); + close $perlscript or assert(0); - $scriptfile = undef; + $perlscript = undef; push @includestack, [ $currentfile, $currentfilename, $currentlinenumber ]; $currentfile = undef; - open $currentfile, '<', $scriptfilename or fatal_error "Unable to open Perl Script $scriptfilename"; + open $currentfile, '<', $perlscriptname or fatal_error "Unable to open Perl Script $perlscriptname"; - push @tempfiles, $scriptfilename unless unlink $scriptfilename; #unlink fails on Cygwin + push @tempfiles, $perlscriptname unless unlink $perlscriptname; #unlink fails on Cygwin - $scriptfilename = ''; + $perlscriptname = ''; $currentfilename = "PERL\@$currentfilename:$linenumber"; $currentline = ''; @@ -2532,7 +2532,7 @@ sub get_configuration( $ ) { } # -# The values of the options in @propagateconfig are copied to the object file in OPTION= format. +# The values of the options in @propagateconfig are copied to the script file in OPTION= format. # sub propagateconfig() { for my $option ( @propagateconfig ) { diff --git a/Shorewall/changelog.txt b/Shorewall/changelog.txt index 5191bd3df..7cb003637 100644 --- a/Shorewall/changelog.txt +++ b/Shorewall/changelog.txt @@ -4,6 +4,8 @@ Changes in Shorewall 4.4.3 2) Fix 'routeback' in /etc/shorewall/routestopped. +3) Rename 'object' to 'script' in compiler and config modules. + Changes in Shorewall 4.4.2 1) BUGFIX: Correct detection of Persistent SNAT support