From edda7cc40c2388537779a74914f3c396c98ddaad Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 3 Aug 2022 08:56:48 +0200 Subject: [PATCH] Handle error initially loading Lua script. Fixes #11818 #10079 --- pdns/lua-base4.hh | 2 +- pdns/recursordist/rec-main.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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"]))); } -- 2.47.2