From: tho Date: Tue, 2 Mar 2010 15:38:45 +0000 (+0000) Subject: Console: SystemException in parseFile() should include filename X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=d80f142699130075658d6448c90adf71338f2c5a;p=senf.git Console: SystemException in parseFile() should include filename Packet: GenericTLV: removed useless const git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1585 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/GenericTLV.hh b/senf/Packets/GenericTLV.hh index 0e0ddc3..db0708f 100644 --- a/senf/Packets/GenericTLV.hh +++ b/senf/Packets/GenericTLV.hh @@ -201,7 +201,7 @@ namespace senf { class Predicate { public: - const bool operator() (BaseParser const &p) const{ + bool operator() (BaseParser const &p) const { return p.template is(); } }; diff --git a/senf/Utils/Console/ConfigFile.test.cc b/senf/Utils/Console/ConfigFile.test.cc index 8cb3e30..692fad6 100644 --- a/senf/Utils/Console/ConfigFile.test.cc +++ b/senf/Utils/Console/ConfigFile.test.cc @@ -62,13 +62,14 @@ namespace { } -#define SENF_CHECK_THROW_SYSTEMEXCEPTION( expr, errorNumber) \ +#define SENF_CHECK_THROW_SYSTEMEXCEPTION( expr, errorNumber, msg) \ try { \ BOOST_TEST_PASSPOINT(); \ expr; \ BOOST_ERROR( "senf::SystemException is expected"); \ } catch( senf::SystemException const & ex ) { \ BOOST_CHECK( ex.anyOf( errorNumber)); \ + BOOST_CHECK( ex.message().find(msg) != std::string::npos); \ } \ @@ -103,16 +104,15 @@ SENF_AUTO_UNIT_TEST(configFile) { senf::console::ConfigFile cfg ("i don't exist"); - SENF_CHECK_THROW_SYSTEMEXCEPTION( - cfg.parse(), ENOENT); + SENF_CHECK_THROW_SYSTEMEXCEPTION(cfg.parse(), ENOENT, "i don't exist"); cfg.ignoreMissing(); SENF_CHECK_NO_THROW( cfg.parse() ); } - { - if (getuid() != 0 && boost::filesystem::exists("/etc/shadow")) { - senf::console::ConfigFile cfg ("/etc/shadow"); - SENF_CHECK_THROW_SYSTEMEXCEPTION( - cfg.parse(), EACCES); + { + std::string etc_shaddow ("/etc/shadow"); + if (getuid() != 0 && boost::filesystem::exists(etc_shaddow)) { + senf::console::ConfigFile cfg (etc_shaddow); + SENF_CHECK_THROW_SYSTEMEXCEPTION( cfg.parse(), EACCES, etc_shaddow); } } } diff --git a/senf/Utils/Console/Parse.cc b/senf/Utils/Console/Parse.cc index 5cd4e4c..7f0c5ba 100644 --- a/senf/Utils/Console/Parse.cc +++ b/senf/Utils/Console/Parse.cc @@ -373,16 +373,16 @@ prefix_ void senf::console::CommandParser::parseFile(std::string const & filenam // so we check the file size before struct stat statBuf; if (stat( filename.c_str(), &statBuf) != 0) - throw SystemException(errno SENF_EXC_DEBUGINFO); + throw SystemException(filename, errno SENF_EXC_DEBUGINFO); if (statBuf.st_size == 0) return; boost::spirit::file_iterator<> i (filename); if (!i) { if (errno == 0) // hmm.. errno==0 but the file_iterator is false; something is wrong but we // do not know what exactly, so we throw a SystemeException with EINVAL - throw SystemException(EINVAL SENF_EXC_DEBUGINFO); + throw SystemException(filename, EINVAL SENF_EXC_DEBUGINFO); else - throw SystemException(errno SENF_EXC_DEBUGINFO); + throw SystemException(filename, errno SENF_EXC_DEBUGINFO); } boost::spirit::file_iterator<> const i_end (i.make_end()); parseLoop(i, i_end, filename, cb);