mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-29 08:59:15 +01:00
Give all config files access to shorewallrc variables.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
bb6e17fd3e
commit
85fce606dc
@ -2101,7 +2101,7 @@ sub set_action_param( $$ ) {
|
|||||||
#
|
#
|
||||||
# Expand Shell Variables in the passed buffer using %params and @actparms
|
# Expand Shell Variables in the passed buffer using %params and @actparms
|
||||||
#
|
#
|
||||||
sub expand_variables( \$;$ ) {
|
sub expand_variables( \$ ) {
|
||||||
my ( $lineref, $count ) = ( $_[0], 0 );
|
my ( $lineref, $count ) = ( $_[0], 0 );
|
||||||
# $1 $2 $3 - $4
|
# $1 $2 $3 - $4
|
||||||
while ( $$lineref =~ m( ^(.*?) \$({)? (\w+) (?(2)}) (.*)$ )x ) {
|
while ( $$lineref =~ m( ^(.*?) \$({)? (\w+) (?(2)}) (.*)$ )x ) {
|
||||||
@ -2115,7 +2115,7 @@ sub expand_variables( \$;$ ) {
|
|||||||
$val = $actparms[$var];
|
$val = $actparms[$var];
|
||||||
} elsif ( exists $params{$var} ) {
|
} elsif ( exists $params{$var} ) {
|
||||||
$val = $params{$var};
|
$val = $params{$var};
|
||||||
} elsif ( $_[1] && exists $shorewallrc{$var} ) {
|
} elsif ( exists $shorewallrc{$var} ) {
|
||||||
$val = $shorewallrc{$var}
|
$val = $shorewallrc{$var}
|
||||||
} else {
|
} else {
|
||||||
fatal_error "Undefined shell variable (\$$var)" unless exists $config{$var};
|
fatal_error "Undefined shell variable (\$$var)" unless exists $config{$var};
|
||||||
@ -2288,7 +2288,7 @@ sub process_shorewallrc( $ ) {
|
|||||||
if ( $currentline =~ /^([a-zA-Z]\w*)=(.*)$/ ) {
|
if ( $currentline =~ /^([a-zA-Z]\w*)=(.*)$/ ) {
|
||||||
my ($var, $val) = ($1, $2);
|
my ($var, $val) = ($1, $2);
|
||||||
$val = $1 if $val =~ /^\"([^\"]*)\"$/;
|
$val = $1 if $val =~ /^\"([^\"]*)\"$/;
|
||||||
expand_variables($val, 1 ) if supplied $val;
|
expand_variables($val) if supplied $val;
|
||||||
$shorewallrc{$var} = $val;
|
$shorewallrc{$var} = $val;
|
||||||
} else {
|
} else {
|
||||||
fatal_error "Unrecognized shorewallrc entry";
|
fatal_error "Unrecognized shorewallrc entry";
|
||||||
@ -3473,7 +3473,7 @@ sub process_shorewall_conf( $$ ) {
|
|||||||
#
|
#
|
||||||
for ( values %config ) {
|
for ( values %config ) {
|
||||||
if ( supplied $_ ) {
|
if ( supplied $_ ) {
|
||||||
expand_variables( $_, 1) unless /^'(.+)'$/;
|
expand_variables( $_ ) unless /^'(.+)'$/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@
|
|||||||
<member><command>./install.sh</command></member>
|
<member><command>./install.sh</command></member>
|
||||||
</simplelist>
|
</simplelist>
|
||||||
|
|
||||||
<section>
|
<section id="shorewallrc">
|
||||||
<title>Settings in a shorewallrc file</title>
|
<title>Settings in a shorewallrc file</title>
|
||||||
|
|
||||||
<para>A shorewallrc file contains a number of lines of the form
|
<para>A shorewallrc file contains a number of lines of the form
|
||||||
@ -342,7 +342,7 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>Top-level directory under which most Shorewall components
|
<para>Top-level directory under which most Shorewall components
|
||||||
are installed. All standard shorewallrc files define this as
|
are installed. All standard shorewallrc files define this as
|
||||||
<emphasis role="bold">\usr</emphasis>. </para>
|
<emphasis role="bold">\usr</emphasis>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -1252,11 +1252,15 @@ SHELL cat /etc/shorewall/rules.d/*.rules 2> /dev/null || true</programlisting
|
|||||||
</listitem>
|
</listitem>
|
||||||
</orderedlist>
|
</orderedlist>
|
||||||
|
|
||||||
<para id="Rvariables">Given that shell variables are expanded at compile
|
<para id="Rvariables">Beginning with Shorewall 4.5.2, configuration files
|
||||||
time, there is no way to cause such variables to be expended at run time.
|
can access variables defined in the <ulink
|
||||||
Prior to Shorewall 4.4.17, this made it difficult (to impossible) to
|
url="Install.htm#shorewallrc">shorewallrc file</ulink>.</para>
|
||||||
include dynamic IP addresses in a <ulink
|
|
||||||
url="Shorewall-Lite.html">Shorewall-lite</ulink> configuration.</para>
|
<para>Given that shell variables are expanded at compile time, there is no
|
||||||
|
way to cause such variables to be expended at run time. Prior to Shorewall
|
||||||
|
4.4.17, this made it difficult (to impossible) to include dynamic IP
|
||||||
|
addresses in a <ulink url="Shorewall-Lite.html">Shorewall-lite</ulink>
|
||||||
|
configuration.</para>
|
||||||
|
|
||||||
<para>Version 4.4.17 implemented <firstterm>Run-time address
|
<para>Version 4.4.17 implemented <firstterm>Run-time address
|
||||||
variables</firstterm>. In configuration files, these variables are
|
variables</firstterm>. In configuration files, these variables are
|
||||||
|
Loading…
Reference in New Issue
Block a user