From 37db19faf96c8c2d4ce19eaf3254a177bfa1f863 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Fri, 18 Dec 2009 23:44:58 +0000 Subject: [PATCH] fixes #939 Add backup ssh access rule to the "stop" section of generated iptables script. Now with dialog control to make this optional --- build_num | 2 +- src/gui/iptAdvancedDialog.cpp | 2 + src/gui/iptadvanceddialog_q.ui | 134 +++++++++++----------- src/iptlib/CompilerDriver_ipt_run.cpp | 17 +-- test/ipt/objects-for-regression-tests.fwb | 14 ++- 5 files changed, 93 insertions(+), 76 deletions(-) diff --git a/build_num b/build_num index 3f07def5d..5be78076f 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 2197 +#define BUILD_NUM 2198 diff --git a/src/gui/iptAdvancedDialog.cpp b/src/gui/iptAdvancedDialog.cpp index 3bb45a1cc..c8076eab0 100644 --- a/src/gui/iptAdvancedDialog.cpp +++ b/src/gui/iptAdvancedDialog.cpp @@ -146,6 +146,8 @@ iptAdvancedDialog::iptAdvancedDialog(QWidget *parent,FWObject *o) data.registerOption(m_dialog->mgmt_ssh, fwoptions, "mgmt_ssh"); data.registerOption(m_dialog->mgmt_addr, fwoptions, "mgmt_addr"); + data.registerOption(m_dialog->add_mgmt_ssh_rule_when_stoped, + fwoptions, "add_mgmt_ssh_rule_when_stoped"); data.registerOption(m_dialog->addVirtualsforNAT, fwoptions, "manage_virtual_addr"); diff --git a/src/gui/iptadvanceddialog_q.ui b/src/gui/iptadvanceddialog_q.ui index 3877c00ef..f9a450bee 100644 --- a/src/gui/iptadvanceddialog_q.ui +++ b/src/gui/iptadvanceddialog_q.ui @@ -9,7 +9,7 @@ 0 0 671 - 772 + 812 @@ -24,7 +24,7 @@ false - + @@ -34,16 +34,13 @@ - 4 + 0 Compiler - - -1 - @@ -57,7 +54,7 @@ - + @@ -86,7 +83,7 @@ - + @@ -96,7 +93,7 @@ - + @@ -115,7 +112,7 @@ - + @@ -125,7 +122,7 @@ - + Generated script can be copied to the firewall machine under different name. If this field is left blank, the file name does not change. @@ -145,7 +142,7 @@ - + @@ -155,7 +152,7 @@ - + QFrame::HLine @@ -168,7 +165,36 @@ - + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Assume firewall is part of 'any' + + + + Qt::Horizontal @@ -184,7 +210,7 @@ - + @@ -197,7 +223,7 @@ - + @@ -210,7 +236,7 @@ - + Drop packets that are associated with @@ -218,14 +244,14 @@ no known connection - + and log them - + Qt::Horizontal @@ -241,7 +267,7 @@ no known connection - + @@ -254,7 +280,7 @@ no known connection - + @@ -267,7 +293,7 @@ no known connection - + @@ -280,7 +306,7 @@ no known connection - + @@ -293,7 +319,7 @@ no known connection - + @@ -313,14 +339,14 @@ in host settings dialog. - + Make Tag and Classify actions terminating - + Compiler will automatically generate rules to permit ICMP6 packets used in IPv6 @@ -332,7 +358,7 @@ the rule that drops packets in state INVALID. - + Default action on 'Reject': @@ -342,10 +368,10 @@ the rule that drops packets in state INVALID. - + - + Qt::Horizontal @@ -361,7 +387,7 @@ the rule that drops packets in state INVALID. - + QFrame::HLine @@ -374,7 +400,7 @@ the rule that drops packets in state INVALID. - + Qt::Horizontal @@ -390,16 +416,14 @@ the rule that drops packets in state INVALID. - + - Always permit ssh access from -the management workstation -with this address: + Always permit ssh access from the management workstation with this address: - + @@ -415,6 +439,14 @@ with this address: + + + + Install the rule for ssh access from the management workstation when the firewall +is stopped + + + @@ -431,35 +463,6 @@ with this address: - - - - Qt::Vertical - - - QSizePolicy::Maximum - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Assume firewall is part of 'any' - - - @@ -1609,7 +1612,6 @@ with this address: ipv4before buttonHelp - diff --git a/src/iptlib/CompilerDriver_ipt_run.cpp b/src/iptlib/CompilerDriver_ipt_run.cpp index dad15da6e..c289f276c 100644 --- a/src/iptlib/CompilerDriver_ipt_run.cpp +++ b/src/iptlib/CompilerDriver_ipt_run.cpp @@ -605,13 +605,16 @@ string CompilerDriver_ipt::run(const std::string &cluster_id, Configlet stop_action(fw, "linux24", "stop_action"); stop_action.collapseEmptyStrings(true); - std::auto_ptr policy_compiler = createPolicyCompiler( - fw, false, NULL, NULL); - PolicyCompiler_ipt::PrintRule* print_rule = - policy_compiler->createPrintRuleProcessor(); - - print_rule->setContext(policy_compiler.get()); - print_rule->_printBackupSSHAccessRules(&stop_action); + if (fw->getOptionsObject()->getBool("add_mgmt_ssh_rule_when_stoped")) + { + std::auto_ptr policy_compiler = createPolicyCompiler( + fw, false, NULL, NULL); + PolicyCompiler_ipt::PrintRule* print_rule = + policy_compiler->createPrintRuleProcessor(); + print_rule->setContext(policy_compiler.get()); + print_rule->_printBackupSSHAccessRules(&stop_action); + } else + stop_action->setVariable("mgmt_access", 0); script_skeleton.setVariable("stop_action", stop_action.expand()); diff --git a/test/ipt/objects-for-regression-tests.fwb b/test/ipt/objects-for-regression-tests.fwb index 52e22fa0f..0b7b5b8bd 100644 --- a/test/ipt/objects-for-regression-tests.fwb +++ b/test/ipt/objects-for-regression-tests.fwb @@ -2942,7 +2942,7 @@ - + @@ -4799,14 +4799,21 @@ + + + + + + + @@ -4818,6 +4825,7 @@ + @@ -4863,7 +4871,9 @@ + + @@ -45401,7 +45411,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - +