]> git.proxmox.com Git - pve-container.git/commitdiff
restore: also remove firewall config after failed restore
authorDaniel Tschlatscher <d.tschlatscher@proxmox.com>
Tue, 29 Nov 2022 14:00:19 +0000 (15:00 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 22 Dec 2022 12:47:25 +0000 (13:47 +0100)
Before, a failed restore would only remove the container config, but
the firewall config would remain.
Now, the firewall config is also removed, except for the case when the
user only has the VM.Backup permission. In this case the firewall
would not have been restored/changed by us and is left as is.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
src/PVE/API2/LXC.pm

index f2113deff7de611fa779530d56e4a6e1abbde738..50c9eaf34d6455b2c55d0a35b6a062626c618900 100644 (file)
@@ -499,6 +499,11 @@ __PACKAGE__->register_method({
                if ($destroy_config_on_error) {
                    eval { PVE::LXC::Config->destroy_config($vmid) };
                    warn $@ if $@;
+
+                   if (!$skip_fw_config_restore) { # Only if user has permission to change the fw
+                       PVE::Firewall::remove_vmfw_conf($vmid);
+                       warn $@ if $@;
+                   }
                }
                die "$emsg $err";
            }