]> git.proxmox.com Git - pve-firewall.git/commitdiff
correctly remove stale chains
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 19 Feb 2014 07:26:22 +0000 (08:26 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 19 Feb 2014 07:26:22 +0000 (08:26 +0100)
PVE/Firewall.pm

index d266bd66fc325088dbe453c6d588be05d1125407..d24ca6322615fdde4084a8ec08f20d41bc2bdc0d 100644 (file)
@@ -746,8 +746,7 @@ sub apply_ruleset {
            }
            $cmdlist .= print_sig_rule($chain, $stat->{sig});
        } elsif ($stat->{action} eq 'delete') {
            }
            $cmdlist .= print_sig_rule($chain, $stat->{sig});
        } elsif ($stat->{action} eq 'delete') {
-           $cmdlist .= "-F $chain\n";
-           $cmdlist .= "-X $chain\n";
+           die "internal error"; # this should not happen
        } elsif ($stat->{action} eq 'exists') {
            # do nothing
        } else {
        } elsif ($stat->{action} eq 'exists') {
            # do nothing
        } else {
@@ -755,6 +754,15 @@ sub apply_ruleset {
        }
     }
 
        }
     }
 
+    foreach my $chain (keys %$statushash) {
+       next if $statushash->{$chain}->{action} ne 'delete';
+       $cmdlist .= "-F $chain\n";
+    }
+    foreach my $chain (keys %$statushash) {
+       next if $statushash->{$chain}->{action} ne 'delete';
+       $cmdlist .= "-X $chain\n";
+    }
+
     $cmdlist .= "COMMIT\n";
 
     print $cmdlist if $verbose;
     $cmdlist .= "COMMIT\n";
 
     print $cmdlist if $verbose;