compilers include error and warning messages in generated scripts and config files

This commit is contained in:
Vadim Kurland
2008-06-05 18:44:13 +00:00
parent b73ef65f91
commit f6d0d3f66c
8 changed files with 95 additions and 1 deletions
+12
View File
@@ -1,3 +1,15 @@
2008-06-05 Vadim Kurland <vadim@vk.crocodile.org>
* All compilers: all compilers include error and warning messages
produced during compilation in the generated script. Messages are
grouped by corresponding section (Policy, NAT, all branches
etc.). Normally only warnings will be included because compilers
stop when they encounter an error condition, however if compiler
is being ran with "-xt" command line option, it does not stop and
includes error messages in the output as well. This helps catch
changes that generate warnings but do not translate into
differences in generated configuration.
2008-06-02 Vadim Kurland <vadim@vk.crocodile.org> 2008-06-02 Vadim Kurland <vadim@vk.crocodile.org>
* PolicyCompiler_PrintRule.cpp (PrintRule::_printTimeInterval): * PolicyCompiler_PrintRule.cpp (PrintRule::_printTimeInterval):
+8
View File
@@ -393,6 +393,14 @@ int main(int argc, char * const * argv)
ofile << oscnf->getCompiledScript(); ofile << oscnf->getCompiledScript();
ofile << endl; ofile << endl;
if (c->haveErrorsAndWarnings())
{
ofile << "! Policy compiler errors and warnings:"
<< endl;
ofile << c->getErrors();
}
ofile << c->getCompiledScript(); ofile << c->getCompiledScript();
ofile << endl; ofile << endl;
+17
View File
@@ -513,6 +513,14 @@ int main(int argc, char * const *argv)
#else #else
ipf_file.open(ipf_file_name.c_str()); ipf_file.open(ipf_file_name.c_str());
#endif #endif
if (c.haveErrorsAndWarnings())
{
ipf_file << "# Policy compiler errors and warnings:"
<< endl;
ipf_file << c.getErrors();
}
ipf_file << c.getCompiledScript(); ipf_file << c.getCompiledScript();
ipf_file.close(); ipf_file.close();
@@ -540,6 +548,15 @@ int main(int argc, char * const *argv)
#else #else
nat_file.open(nat_file_name.c_str()); nat_file.open(nat_file_name.c_str());
#endif #endif
if (n.haveErrorsAndWarnings())
{
nat_file << "# NAT compiler errors and warnings:"
<< endl;
nat_file << n.getErrors();
}
nat_file << n.getCompiledScript(); nat_file << n.getCompiledScript();
nat_file.close(); nat_file.close();
+7
View File
@@ -445,6 +445,13 @@ int main(int argc, char * const *argv)
if (have_ipfw) if (have_ipfw)
{ {
if (c.haveErrorsAndWarnings())
{
fw_file << "# Policy compiler errors and warnings:"
<< endl;
fw_file << c.getErrors();
}
fw_file << c.getCompiledScript(); fw_file << c.getCompiledScript();
} }
+20
View File
@@ -610,6 +610,13 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi
n_str << "# ================ Table 'nat', rule set " n_str << "# ================ Table 'nat', rule set "
<< branch_name << endl; << branch_name << endl;
if (n.haveErrorsAndWarnings())
{
n_str << "# NAT compiler errors and warnings:"
<< endl;
n_str << n.getErrors();
}
if (Compiler::isRootRuleSet(nat)) if (Compiler::isRootRuleSet(nat))
n_str << n.flushAndSetDefaultPolicy(); n_str << n.flushAndSetDefaultPolicy();
@@ -657,6 +664,13 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi
} }
m_str << "# ================ Table 'mangle', rule set " m_str << "# ================ Table 'mangle', rule set "
<< branch_name << endl; << branch_name << endl;
if (m.haveErrorsAndWarnings())
{
m_str << "# Policy compiler errors and warnings:"
<< endl;
m_str << m.getErrors();
}
m_str << m.getCompiledScript(); m_str << m.getCompiledScript();
m_str << m.commit(); m_str << m.commit();
m_str << endl; m_str << endl;
@@ -687,6 +701,12 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi
{ {
c_str << "# ================ Table 'filter', rule set " c_str << "# ================ Table 'filter', rule set "
<< branch_name << endl; << branch_name << endl;
if (c.haveErrorsAndWarnings())
{
c_str << "# Policy compiler errors and warnings:"
<< endl;
c_str << c.getErrors();
}
c_str << c.getCompiledScript(); c_str << c.getCompiledScript();
c_str << c.commit(); c_str << c.commit();
c_str << endl; c_str << endl;
+14
View File
@@ -716,6 +716,13 @@ int main(int argc, char * const *argv)
if (n.getCompiledScriptLength() > 0) if (n.getCompiledScriptLength() > 0)
{ {
if (n.haveErrorsAndWarnings())
{
*(generated_scripts[ruleset_name])
<< "# NAT compiler errors and warnings:"
<< endl;
*(generated_scripts[ruleset_name]) << n.getErrors();
}
*(generated_scripts[ruleset_name]) << n.getCompiledScript(); *(generated_scripts[ruleset_name]) << n.getCompiledScript();
*(generated_scripts[ruleset_name]) << endl; *(generated_scripts[ruleset_name]) << endl;
} }
@@ -770,6 +777,13 @@ int main(int argc, char * const *argv)
if (c.getCompiledScriptLength() > 0) if (c.getCompiledScriptLength() > 0)
{ {
if (c.haveErrorsAndWarnings())
{
*(generated_scripts[ruleset_name])
<< "# Policy compiler errors and warnings:"
<< endl;
*(generated_scripts[ruleset_name]) << c.getErrors();
}
*(generated_scripts[ruleset_name]) << c.getCompiledScript(); *(generated_scripts[ruleset_name]) << c.getCompiledScript();
*(generated_scripts[ruleset_name]) << endl; *(generated_scripts[ruleset_name]) << endl;
} }
+16
View File
@@ -606,8 +606,24 @@ int main(int argc, char * const * argv)
ofile << oscnf->getCompiledScript(); ofile << oscnf->getCompiledScript();
ofile << endl; ofile << endl;
if (c->haveErrorsAndWarnings())
{
ofile << "! Policy compiler errors and warnings:"
<< endl;
ofile << c->getErrors();
}
ofile << c->getCompiledScript(); ofile << c->getCompiledScript();
ofile << endl; ofile << endl;
if (n->haveErrorsAndWarnings())
{
ofile << "! NAT compiler errors and warnings:"
<< endl;
ofile << n->getErrors();
}
ofile << n->getCompiledScript(); ofile << n->getCompiledScript();
ofile << endl; ofile << endl;
+1 -1
View File
@@ -10,7 +10,7 @@ while (<>) {
$fw=$1; $fw=$1;
printf "\n"; printf "\n";
printf "echo '***** $fw'\n"; printf "echo '***** $fw'\n";
printf "fwb_ipt -4 -v -f $XMLFILE $fw\n"; printf "fwb_ipt -4 -v -f $XMLFILE -xt $fw\n";
$str=~ s/^.*<Firewall [^>]+name="$fw"[^>]+>//; $str=~ s/^.*<Firewall [^>]+name="$fw"[^>]+>//;
} }
} }