From 8ac754caed10d3a525167a39fecb8e68fb876d71 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 21 Jan 2016 17:08:19 -0800 Subject: [PATCH] Add 'origin' member to the interface and hosts tables Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Zones.pm | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Zones.pm b/Shorewall/Perl/Shorewall/Zones.pm index 77ac0a676..ad2b62125 100644 --- a/Shorewall/Perl/Shorewall/Zones.pm +++ b/Shorewall/Perl/Shorewall/Zones.pm @@ -91,6 +91,7 @@ our @EXPORT = ( qw( NOTHING find_interfaces_by_option find_interfaces_by_option1 get_interface_option + get_interface_origin interface_has_option set_interface_option set_interface_provider @@ -149,6 +150,7 @@ use constant { IN_OUT => 1, # } # hosts => [ , , ... ] # exclusions => [ , , ... ] +# origin => # } # => ... # } @@ -196,6 +198,7 @@ our %reservedName = ( all => 1, # provider => # wildcard => undef|1 # Wildcard Name # zones => { zone1 => 1, ... } +# origin => # } # } # @@ -890,7 +893,9 @@ sub add_group_to_zone($$$$$$) push @{$interfaceref}, { options => $options, hosts => \@newnetworks, ipsec => $type & IPSEC ? 'ipsec' : 'none' , - exclusions => \@exclusions }; + exclusions => \@exclusions , + origin => shortlineinfo( '' ) , + }; if ( $type != IPSEC ) { my $optref = $interfaces{$interface}{options}; @@ -1394,6 +1399,7 @@ sub process_interface( $$ ) { zones => {}, origin => shortlineinfo(''), wildcard => $wildcard, + origin => shortlineinfo( '' ), }; if ( $zone ) { @@ -1858,6 +1864,22 @@ sub interface_has_option( $$\$ ) { } # +# Return the origin for an interface +# +sub get_interface_origin( $ ) { + my ( $interface ) = @_; + + my $ref = $interfaces{$interface}; + + return $ref->{origin} if $ref; + + assert( $ref = known_interface( $interface ) ); + + $ref->{origin}; + +} + +## # Set an option for an interface # sub set_interface_option( $$$ ) { @@ -2182,11 +2204,12 @@ sub find_hosts_by_option( $ ) { for my $interface ( sort keys %$interfaceref ) { my $arrayref = $interfaceref->{$interface}; for my $host ( @{$arrayref} ) { - my $ipsec = $host->{ipsec}; + my $ipsec = $host->{ipsec}; + my $origin = $host->{origin}; unless ( $done{$interface} ) { if ( my $value = $host->{options}{$option} ) { for my $net ( @{$host->{hosts}} ) { - push @hosts, [ $interface, $ipsec , $net , $host->{exclusions}, $value ]; + push @hosts, [ $interface, $ipsec , $net , $host->{exclusions}, $value, $origin ]; } } } @@ -2213,7 +2236,7 @@ sub find_zone_hosts_by_option( $$ ) { for my $host ( @{$arrayref} ) { if ( my $value = $host->{options}{$option} ) { for my $net ( @{$host->{hosts}} ) { - push @hosts, [ $interface, $host->{ipsec} , $net , $host->{exclusions}, $value ]; + push @hosts, [ $interface, $host->{ipsec} , $net , $host->{exclusions}, $value, $host->{origin} ]; } } }