From: Otto Moerbeek Date: Wed, 3 Aug 2022 06:56:48 +0000 (+0200) Subject: Handle error initially loading Lua script. X-Git-Tag: rec-4.8.0-alpha1~74^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11820%2Fhead;p=thirdparty%2Fpdns.git Handle error initially loading Lua script. Fixes #11818 #10079 --- diff --git a/pdns/lua-base4.hh b/pdns/lua-base4.hh index 9394de4f84..f587f4223f 100644 --- a/pdns/lua-base4.hh +++ b/pdns/lua-base4.hh @@ -13,7 +13,7 @@ protected: public: BaseLua4(); - int loadFile(const std::string &fname); + [[nodiscard]] int loadFile(const std::string &fname); void loadString(const std::string &script); void loadStream(std::istream &is); virtual ~BaseLua4(); // this is so unique_ptr works with an incomplete type diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 48685818dc..c5c77e10a8 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -2321,7 +2321,10 @@ static void recursorThread() try { if (!::arg()["lua-dns-script"].empty()) { t_pdl = std::make_shared(); - t_pdl->loadFile(::arg()["lua-dns-script"]); + auto err = t_pdl->loadFile(::arg()["lua-dns-script"]); + if (err != 0) { + throw std::runtime_error(stringerror(err)); + } SLOG(g_log << Logger::Warning << "Loaded 'lua' script from '" << ::arg()["lua-dns-script"] << "'" << endl, log->info(Logr::Warning, "Loading Lua script from file", "name", Logging::Loggable(::arg()["lua-dns-script"]))); }