From 95a269a825a46c9fd89b793e7c1f76fa66fe8143 Mon Sep 17 00:00:00 2001 From: teastep Date: Tue, 5 Jun 2007 16:49:13 +0000 Subject: [PATCH] Convert some lexical variables to globals git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6463 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-perl/Shorewall/Accounting.pm | 5 +- Shorewall-perl/Shorewall/Chains.pm | 6 +- Shorewall-perl/Shorewall/Common.pm | 12 ++-- Shorewall-perl/Shorewall/Config.pm | 78 +++++++++++++------------- Shorewall-perl/Shorewall/Nat.pm | 4 +- Shorewall-perl/Shorewall/Proxyarp.pm | 2 +- Shorewall-perl/Shorewall/Rules.pm | 4 +- Shorewall-perl/Shorewall/Tc.pm | 18 +++--- Shorewall-perl/Shorewall/Zones.pm | 8 +-- Shorewall-perl/compiler.pl | 2 +- 10 files changed, 70 insertions(+), 69 deletions(-) diff --git a/Shorewall-perl/Shorewall/Accounting.pm b/Shorewall-perl/Shorewall/Accounting.pm index 5d9d9d603..b0692be84 100644 --- a/Shorewall-perl/Shorewall/Accounting.pm +++ b/Shorewall-perl/Shorewall/Accounting.pm @@ -40,9 +40,10 @@ our @VERSION = 1.00; # # Accounting # -my $jumpchainref; - sub process_accounting_rule( $$$$$$$$$ ) { + + our $jumpchainref; + my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark ) = @_; sub accounting_error() { diff --git a/Shorewall-perl/Shorewall/Chains.pm b/Shorewall-perl/Shorewall/Chains.pm index 8c086c99e..d48486ff1 100644 --- a/Shorewall-perl/Shorewall/Chains.pm +++ b/Shorewall-perl/Shorewall/Chains.pm @@ -243,15 +243,15 @@ use constant { NO_RESTRICT => 0, # # Used to sequence 'exclusion' chains with names 'excl0', 'excl1', ... # -my $exclseq = 0; +our $exclseq = 0; # # Used to suppress duplicate match specifications. # -my $iprangematch = 0; +our $iprangematch = 0; # # Sequence for naming temporary chains # -my $chainseq; +our $chainseq; # # Add a run-time command to a chain. Arguments are: # diff --git a/Shorewall-perl/Shorewall/Common.pm b/Shorewall-perl/Shorewall/Common.pm index 5eb176515..c38e5c6d1 100644 --- a/Shorewall-perl/Shorewall/Common.pm +++ b/Shorewall-perl/Shorewall/Common.pm @@ -67,12 +67,12 @@ our ( $command, $doing, $done ) = qw/ compile Compiling Compiled/; #describe the our $verbose; # Verbosity setting. 0 = almost silent, 1 = major progress messages only, 2 = all progress messages (very noisy) -my $timestamp; # If true, we are to timestamp each progress message -my $object = 0; # Object (script) file Handle Reference -my $lastlineblank = 0; # Avoid extra blank lines in the output -my $indent = ''; # Current indentation -my ( $dir, $file ); # Object's Directory and File -my $tempfile; # Temporary File Name +our $timestamp; # If true, we are to timestamp each progress message +our $object = 0; # Object (script) file Handle Reference +our $lastlineblank = 0; # Avoid extra blank lines in the output +our $indent = ''; # Current indentation +our ( $dir, $file ); # Object's Directory and File +our $tempfile; # Temporary File Name INIT { $verbose = $ENV{VERBOSE} || 0; diff --git a/Shorewall-perl/Shorewall/Config.pm b/Shorewall-perl/Shorewall/Config.pm index 8370c1447..2c0cce4e7 100644 --- a/Shorewall-perl/Shorewall/Config.pm +++ b/Shorewall-perl/Shorewall/Config.pm @@ -173,8 +173,8 @@ our %config = # # Config options and global settings that are to be copied to object script # -my @propagateconfig = qw/ CLEAR_TC DISABLE_IPV6 ADMINISABSENTMINDED IP_FORWARDING MODULESDIR MODULE_SUFFIX LOGFORMAT SUBSYSLOCK LOCKFILE/; -my @propagateenv = qw/ LOGLIMIT LOGTAGONLY LOGRULENUMBERS /; +our @propagateconfig = qw/ CLEAR_TC DISABLE_IPV6 ADMINISABSENTMINDED IP_FORWARDING MODULESDIR MODULE_SUFFIX LOGFORMAT SUBSYSLOCK LOCKFILE /; +our @propagateenv = qw/ LOGLIMIT LOGTAGONLY LOGRULENUMBERS /; # # From parsing the capabilities file @@ -217,50 +217,50 @@ our %services; # # Capabilities # -my %capdesc = ( NAT_ENABLED => 'NAT', - MANGLE_ENABLED => 'Packet Mangling', - MULTIPORT => 'Multi-port Match' , - XMULTIPORT => 'Extended Multi-port Match', - CONNTRACK_MATCH => 'Connection Tracking Match', - USEPKTTYPE => 'Packet Type Match', - POLICY_MATCH => 'Policy Match', - PHYSDEV_MATCH => 'Physdev Match', - LENGTH_MATCH => 'Packet length Match', - IPRANGE_MATCH => 'IP Range Match', - RECENT_MATCH => 'Recent Match', - OWNER_MATCH => 'Owner Match', - IPSET_MATCH => 'Ipset Match', - CONNMARK => 'CONNMARK Target', - XCONNMARK => 'Extended CONNMARK Target', - CONNMARK_MATCH => 'Connmark Match', - XCONNMARK_MATCH => 'Extended Connmark Match', - RAW_TABLE => 'Raw Table', - IPP2P_MATCH => 'IPP2P Match', - CLASSIFY_TARGET => 'CLASSIFY Target', - ENHANCED_REJECT => 'Extended Reject', - KLUDGEFREE => 'Repeat match', - MARK => 'MARK Target', - XMARK => 'Extended Mark Target', - MANGLE_FORWARD => 'Mangle FORWARD Chain', - COMMENTS => 'Comments', - ADDRTYPE => 'Address Type Match', - ); +our %capdesc = ( NAT_ENABLED => 'NAT', + MANGLE_ENABLED => 'Packet Mangling', + MULTIPORT => 'Multi-port Match' , + XMULTIPORT => 'Extended Multi-port Match', + CONNTRACK_MATCH => 'Connection Tracking Match', + USEPKTTYPE => 'Packet Type Match', + POLICY_MATCH => 'Policy Match', + PHYSDEV_MATCH => 'Physdev Match', + LENGTH_MATCH => 'Packet length Match', + IPRANGE_MATCH => 'IP Range Match', + RECENT_MATCH => 'Recent Match', + OWNER_MATCH => 'Owner Match', + IPSET_MATCH => 'Ipset Match', + CONNMARK => 'CONNMARK Target', + XCONNMARK => 'Extended CONNMARK Target', + CONNMARK_MATCH => 'Connmark Match', + XCONNMARK_MATCH => 'Extended Connmark Match', + RAW_TABLE => 'Raw Table', + IPP2P_MATCH => 'IPP2P Match', + CLASSIFY_TARGET => 'CLASSIFY Target', + ENHANCED_REJECT => 'Extended Reject', + KLUDGEFREE => 'Repeat match', + MARK => 'MARK Target', + XMARK => 'Extended Mark Target', + MANGLE_FORWARD => 'Mangle FORWARD Chain', + COMMENTS => 'Comments', + ADDRTYPE => 'Address Type Match', + ); # # Directories to search for configuration files # -my @config_path; +our @config_path; # # Stash away file references here when we encounter INCLUDE # -my @includestack; +our @includestack; # # Allow nested opens # -my @openstack; +our @openstack; -my $currentfile; # File handle reference -my $currentfilename; # File NAME -my $currentlinenumber = 0; # Line number +our $currentfile; # File handle reference +our $currentfilename; # File NAME +our $currentlinenumber = 0; # Line number # # Issue a Warning Message @@ -1135,15 +1135,15 @@ sub get_configuration( $ ) { } # -# The values of the options in @Shorewall:Config::propagateconfig are copied to the object file in OPTION= format. +# The values of the options in @propagateconfig are copied to the object file in OPTION= format. # sub propagateconfig() { - for my $option ( @Shorewall::Config::propagateconfig ) { + for my $option ( @propagateconfig ) { my $value = $config{$option} || ''; emit "$option=\"$value\""; } - for my $option ( @Shorewall::Config::propagateenv ) { + for my $option ( @propagateenv ) { my $value = $globals{$option} || ''; emit "$option=\"$value\""; } diff --git a/Shorewall-perl/Shorewall/Nat.pm b/Shorewall-perl/Shorewall/Nat.pm index 0c7b195ed..368597498 100644 --- a/Shorewall-perl/Shorewall/Nat.pm +++ b/Shorewall-perl/Shorewall/Nat.pm @@ -40,8 +40,8 @@ our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses ); our @EXPORT_OK = (); our @VERSION = 1.00; -my @addresses_to_add; -my %addresses_to_add; +our @addresses_to_add; +our %addresses_to_add; # # Handle IPSEC Options in a masq record diff --git a/Shorewall-perl/Shorewall/Proxyarp.pm b/Shorewall-perl/Shorewall/Proxyarp.pm index a41b0eecd..6bb862a66 100644 --- a/Shorewall-perl/Shorewall/Proxyarp.pm +++ b/Shorewall-perl/Shorewall/Proxyarp.pm @@ -38,7 +38,7 @@ our @EXPORT = qw( our @EXPORT_OK = qw( ); our @VERSION = 1.00; -my @proxyarp; +our @proxyarp; sub setup_one_proxy_arp( $$$$$ ) { my ( $address, $interface, $external, $haveroute, $persistent) = @_; diff --git a/Shorewall-perl/Shorewall/Rules.pm b/Shorewall-perl/Shorewall/Rules.pm index f7fe49368..5ba1cac5d 100644 --- a/Shorewall-perl/Shorewall/Rules.pm +++ b/Shorewall-perl/Shorewall/Rules.pm @@ -56,11 +56,11 @@ our @VERSION = 1.00; # # Keep track of chains for the /var/lib/shorewall[-lite]/chains file # -my @rule_chains; +our @rule_chains; # # Set to one if we find a SECTION # -my $sectioned = 0; +our $sectioned = 0; use constant { MAX_MACRO_NEST_LEVEL => 5 }; diff --git a/Shorewall-perl/Shorewall/Tc.pm b/Shorewall-perl/Shorewall/Tc.pm index 7320f7ff5..0e13c80be 100644 --- a/Shorewall-perl/Shorewall/Tc.pm +++ b/Shorewall-perl/Shorewall/Tc.pm @@ -43,10 +43,10 @@ our @EXPORT = qw( setup_tc ); our @EXPORT_OK = qw( process_tc_rule ); our @VERSION = 1.00; -my %tcs = ( T => { chain => 'tcpost', - connmark => 0, - fw => 1 - } , +our %tcs = ( T => { chain => 'tcpost', + connmark => 0, + fw => 1 + } , CT => { chain => 'tcpost' , target => 'CONNMARK --set-mark' , connmark => 1 , @@ -93,11 +93,11 @@ use constant { NOMARK => 0 , HIGHMARK => 2 }; -my @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } , - target => 'CONNMARK --save-mark --mask' , - mark => SMALLMARK , - mask => '0xFF' - } , +our @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } , + target => 'CONNMARK --save-mark --mask' , + mark => SMALLMARK , + mask => '0xFF' + } , { match => sub ( $ ) { $_[0] eq 'RESTORE' }, target => 'CONNMARK --restore-mark --mask' , mark => SMALLMARK , diff --git a/Shorewall-perl/Shorewall/Zones.pm b/Shorewall-perl/Shorewall/Zones.pm index fc5287444..7cd901727 100644 --- a/Shorewall-perl/Shorewall/Zones.pm +++ b/Shorewall-perl/Shorewall/Zones.pm @@ -107,10 +107,10 @@ our $firewall_zone; # our %interfaces; -my %reservedName = ( all => 1, - none => 1, - SOURCE => 1, - DEST => 1 ); +our %reservedName = ( all => 1, + none => 1, + SOURCE => 1, + DEST => 1 ); # # Parse the passed option list and return a reference to a hash as follows: diff --git a/Shorewall-perl/compiler.pl b/Shorewall-perl/compiler.pl index d975377c1..d4c4d8c71 100755 --- a/Shorewall-perl/compiler.pl +++ b/Shorewall-perl/compiler.pl @@ -55,7 +55,7 @@ use Shorewall::Rules; use Shorewall::Proc; use Shorewall::Proxyarp; -my $export; +our $export; INIT { $export = $ENV{EXPORT};