diff --git a/doc/ChangeLog b/doc/ChangeLog index 5eb4cdf93..b85e9a218 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,15 @@ +2008-06-05 Vadim Kurland + + * 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 * PolicyCompiler_PrintRule.cpp (PrintRule::_printTimeInterval): diff --git a/src/iosacl/iosacl.cpp b/src/iosacl/iosacl.cpp index d0b927565..9f6d14279 100644 --- a/src/iosacl/iosacl.cpp +++ b/src/iosacl/iosacl.cpp @@ -393,6 +393,14 @@ int main(int argc, char * const * argv) ofile << oscnf->getCompiledScript(); ofile << endl; + + if (c->haveErrorsAndWarnings()) + { + ofile << "! Policy compiler errors and warnings:" + << endl; + ofile << c->getErrors(); + } + ofile << c->getCompiledScript(); ofile << endl; diff --git a/src/ipf/ipf.cpp b/src/ipf/ipf.cpp index f7c3a211f..7d73f9a61 100644 --- a/src/ipf/ipf.cpp +++ b/src/ipf/ipf.cpp @@ -513,6 +513,14 @@ int main(int argc, char * const *argv) #else ipf_file.open(ipf_file_name.c_str()); #endif + + if (c.haveErrorsAndWarnings()) + { + ipf_file << "# Policy compiler errors and warnings:" + << endl; + ipf_file << c.getErrors(); + } + ipf_file << c.getCompiledScript(); ipf_file.close(); @@ -540,6 +548,15 @@ int main(int argc, char * const *argv) #else nat_file.open(nat_file_name.c_str()); #endif + + if (n.haveErrorsAndWarnings()) + { + nat_file << "# NAT compiler errors and warnings:" + << endl; + nat_file << n.getErrors(); + } + + nat_file << n.getCompiledScript(); nat_file.close(); diff --git a/src/ipfw/ipfw.cpp b/src/ipfw/ipfw.cpp index 29bb125d5..a1f62fca8 100644 --- a/src/ipfw/ipfw.cpp +++ b/src/ipfw/ipfw.cpp @@ -445,6 +445,13 @@ int main(int argc, char * const *argv) if (have_ipfw) { + if (c.haveErrorsAndWarnings()) + { + fw_file << "# Policy compiler errors and warnings:" + << endl; + fw_file << c.getErrors(); + } + fw_file << c.getCompiledScript(); } diff --git a/src/ipt/ipt.cpp b/src/ipt/ipt.cpp index 901453bdc..3673e4290 100644 --- a/src/ipt/ipt.cpp +++ b/src/ipt/ipt.cpp @@ -610,6 +610,13 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi n_str << "# ================ Table 'nat', rule set " << branch_name << endl; + if (n.haveErrorsAndWarnings()) + { + n_str << "# NAT compiler errors and warnings:" + << endl; + n_str << n.getErrors(); + } + if (Compiler::isRootRuleSet(nat)) 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 " << 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.commit(); 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 " << 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.commit(); c_str << endl; diff --git a/src/pf/pf.cpp b/src/pf/pf.cpp index 8ea0c9fa3..f9a93194c 100644 --- a/src/pf/pf.cpp +++ b/src/pf/pf.cpp @@ -716,6 +716,13 @@ int main(int argc, char * const *argv) 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]) << endl; } @@ -770,6 +777,13 @@ int main(int argc, char * const *argv) 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]) << endl; } diff --git a/src/pix/pix.cpp b/src/pix/pix.cpp index 9f21d3639..15bc6cf53 100644 --- a/src/pix/pix.cpp +++ b/src/pix/pix.cpp @@ -606,8 +606,24 @@ int main(int argc, char * const * argv) ofile << oscnf->getCompiledScript(); ofile << endl; + + if (c->haveErrorsAndWarnings()) + { + ofile << "! Policy compiler errors and warnings:" + << endl; + ofile << c->getErrors(); + } + ofile << c->getCompiledScript(); ofile << endl; + + if (n->haveErrorsAndWarnings()) + { + ofile << "! NAT compiler errors and warnings:" + << endl; + ofile << n->getErrors(); + } + ofile << n->getCompiledScript(); ofile << endl; diff --git a/test/ipt/run.all b/test/ipt/run.all index a7b9469df..01691a16c 100755 --- a/test/ipt/run.all +++ b/test/ipt/run.all @@ -10,7 +10,7 @@ while (<>) { $fw=$1; printf "\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/^.*]+name="$fw"[^>]+>//; } }