summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2012-11-19 13:13:07 -0800
committerGaurav Sinha <gaurav.sinha@vyatta.com>2012-11-20 10:35:05 -0800
commit88721dcffecf1f360d9fe635f7a2475e92139822 (patch)
treefcee0ed41b15d13a7de3690de39f47c4ed0b95c1 /scripts
parent133792295d2e20f11a65dc8343149f7bec590180 (diff)
downloadvyatta-cfg-firewall-88721dcffecf1f360d9fe635f7a2475e92139822.tar.gz
vyatta-cfg-firewall-88721dcffecf1f360d9fe635f7a2475e92139822.zip
Bugfix 7613: cleanup firewall groups correctly
(cherry picked from commit 0c029ec3b5564e67e645755c77dfee48d07a3344)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/firewall/vyatta-ipset.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/firewall/vyatta-ipset.pl b/scripts/firewall/vyatta-ipset.pl
index ddac0b9..0627381 100755
--- a/scripts/firewall/vyatta-ipset.pl
+++ b/scripts/firewall/vyatta-ipset.pl
@@ -37,6 +37,16 @@ use IO::Prompt;
use warnings;
use strict;
+sub get_sys_sets {
+ my @sets = ();
+ my @lines = `ipset -L`;
+ foreach my $line (@lines) {
+ if ($line =~ /^Name:\s+(\w+)$/) {
+ push @sets, $1;
+ }
+ }
+ return @sets;
+}
sub warn_before_reset {
if (prompt("This can be temporarily disruptive: Proceed with reset? (Yes/No) [No] ", -ynd=>"n")) {
@@ -310,6 +320,20 @@ sub prune_deleted_sets {
return $rc if (($rc = ipset_delete($g)));
}
}
+
+ # fixup system sets
+ my @sys_sets = get_sys_sets();
+ foreach my $set (@sys_sets) {
+ my $group = new Vyatta::IpTables::IpSet($set);
+ # only try groups with no references
+ if ($group->exists() && ($group->references() == 0)) {
+ my $type = $group->get_type();
+ $cfg->setLevel("firewall group $type-group");
+ next if ($cfg->isEffective($set)); # don't prune if still in config
+ my $rc;
+ return $rc if (($rc = ipset_delete($set)));
+ }
+ }
exit 0;
}