From: Remi Gacogne Date: Mon, 25 Mar 2019 10:41:09 +0000 (+0100) Subject: dnsdist: Fail if we can't check the configuration file X-Git-Tag: dnsdist-1.8.0-rc1~68^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b0539681aaa4c9afdfbff7c8ee9c1005615667e;p=thirdparty%2Fpdns.git dnsdist: Fail if we can't check the configuration file --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index e7d8c2dfed..320b67b39d 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -3181,10 +3181,17 @@ vector> setupLua(LuaContext& luaCtx, bool client, bool #endif std::ifstream ifs(config); - if (!ifs) - warnlog("Unable to read configuration from '%s'", config); - else + if (!ifs) { + if (configCheck) { + throw std::runtime_error("Unable to read configuration file from " + config); + } + else { + warnlog("Unable to read configuration from '%s'", config); + } + } + else { vinfolog("Read configuration from '%s'", config); + } luaCtx.executeCode(ifs); diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index bd3cec2a54..b5a2f24dea 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2604,7 +2604,7 @@ int main(int argc, char** argv) ServerPolicy leastOutstandingPol{"leastOutstanding", leastOutstanding, false}; g_policy.setState(leastOutstandingPol); - if(g_cmdLine.beClient || !g_cmdLine.command.empty()) { + if (g_cmdLine.beClient || !g_cmdLine.command.empty()) { setupLua(*(g_lua.lock()), true, false, g_cmdLine.config); if (clientAddress != ComboAddress()) g_serverControl = clientAddress; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 6b98fb29d5..8825356113 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -1192,8 +1192,6 @@ struct LocalHolders LocalStateHolder pools; }; -vector> setupLua(bool client, const std::string& config); - void tcpAcceptorThread(std::vector states); #ifdef HAVE_DNS_OVER_HTTPS