]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Handle error initially loading Lua script. 11820/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 3 Aug 2022 06:56:48 +0000 (08:56 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 3 Aug 2022 06:56:48 +0000 (08:56 +0200)
Fixes #11818 #10079

pdns/lua-base4.hh
pdns/recursordist/rec-main.cc

index 9394de4f8466c5390d8763f9a4e3b09a573956fc..f587f4223f6dc145071fc6f00f938d2e317eafe1 100644 (file)
@@ -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
index 48685818dc42b52785f42efbee128414e26ce015..c5c77e10a83af1cec11b7dce6e12cca5e6d9f648 100644 (file)
@@ -2321,7 +2321,10 @@ static void recursorThread()
       try {
         if (!::arg()["lua-dns-script"].empty()) {
           t_pdl = std::make_shared<RecursorLua4>();
-          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"])));
         }