From cfd7cd9caa8d26130d8eee9007b56aff805463e4 Mon Sep 17 00:00:00 2001 From: Tom Weber Date: Wed, 18 Oct 2017 22:24:02 +0200 Subject: [PATCH] make $pve_std_chains a copy of $pve_std_chains_conf create a new $pve_std_chains with $pve_std_chains_conf as template on every compilation of the rules. This avoids persitant changes to the $pve_std_chains and makes it easier to read the std_chains configuration from external config files (later to implement). Signed-off-by: Tom Weber --- src/PVE/Firewall.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index 634ff90..c7ddd10 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -20,6 +20,7 @@ use IO::File; use Net::IP; use PVE::Tools qw(run_command lock_file dir_glob_foreach); use Encode; +use Storable qw(dclone); my $hostfw_conf_filename = "/etc/pve/local/host.fw"; my $pvefw_conf_dir = "/etc/pve/firewall"; @@ -548,7 +549,8 @@ my $FWACCEPTMARK_ON = "0x80000000/0x80000000"; my $FWACCEPTMARK_OFF = "0x00000000/0x80000000"; my $pve_std_chains = {}; -$pve_std_chains->{4} = { +my $pve_std_chains_conf = {}; +$pve_std_chains_conf->{4} = { 'PVEFW-SET-ACCEPT-MARK' => [ { target => "-j MARK --set-mark $FWACCEPTMARK_ON" }, ], @@ -641,7 +643,7 @@ $pve_std_chains->{4} = { ], }; -$pve_std_chains->{6} = { +$pve_std_chains_conf->{6} = { 'PVEFW-SET-ACCEPT-MARK' => [ { target => "-j MARK --set-mark $FWACCEPTMARK_ON" }, ], @@ -3354,6 +3356,9 @@ sub compile { my $vmfw_configs; + # fixme: once we read standard chains from config this needs to be put in test/standard cases below + $pve_std_chains = dclone($pve_std_chains_conf); + if ($vmdata) { # test mode my $testdir = $vmdata->{testdir} || die "no test directory specified"; my $filename = "$testdir/cluster.fw"; -- 2.39.2