summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Sinha <gaurav.sinha@vyatta.com>2012-11-17 00:34:54 -0800
committerGaurav Sinha <gaurav.sinha@vyatta.com>2012-11-19 12:32:12 -0800
commit3727dbfdf84a4153772c12e07dc6814216cbeb28 (patch)
treed77e295f30d326ce2b8d01d2dccebb5194721139
parent0e1b6d26640898dbe2d27de52fbb3276502317d2 (diff)
downloadvyatta-cfg-firewall-3727dbfdf84a4153772c12e07dc6814216cbeb28.tar.gz
vyatta-cfg-firewall-3727dbfdf84a4153772c12e07dc6814216cbeb28.zip
Add warning prompt before doing reset
(cherry picked from commit 3d248225eecc99e3e39c497f3a4bd76d5d3aac96) (cherry picked from commit fffe09f9d7a53d5d74bae6bafc2c7b7409a4babf)
-rwxr-xr-xscripts/firewall/vyatta-ipset.pl14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/firewall/vyatta-ipset.pl b/scripts/firewall/vyatta-ipset.pl
index 99ae085..0f8c27e 100755
--- a/scripts/firewall/vyatta-ipset.pl
+++ b/scripts/firewall/vyatta-ipset.pl
@@ -32,13 +32,25 @@ use Vyatta::TypeChecker;
use Vyatta::Misc;
use Vyatta::IpTables::IpSet;
use Sort::Versions;
+use IO::Prompt;
use warnings;
use strict;
+
+sub warn_before_reset {
+ if (prompt("This can be temporarily disruptive: Proceed with reset? (Yes/No) [No] ", -ynd=>"n")) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
sub ipset_reset {
my ($set_name, $set_type) = @_;
-
+ if (!warn_before_reset()) {
+ die "Cancelling reset\n";
+ }
my $group = new Vyatta::IpTables::IpSet($set_name, $set_type);
return $group->reset_ipset();