]> git.proxmox.com Git - pve-firewall.git/commitdiff
make $pve_std_chains a copy of $pve_std_chains_conf
authorTom Weber <pve@junkyard.4t2.com>
Wed, 18 Oct 2017 20:24:02 +0000 (22:24 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 19 Oct 2017 06:00:17 +0000 (08:00 +0200)
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 <pve@junkyard.4t2.com>
src/PVE/Firewall.pm

index 634ff90c8ab7f216af72a3e4b0f9590cf4c220ce..c7ddd10e29313f80980fa16f044116e008ee028a 100644 (file)
@@ -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";