]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: give better error mesage on api-dir not set 17016/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 20 Mar 2026 08:43:47 +0000 (09:43 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 20 Mar 2026 11:59:16 +0000 (12:59 +0100)
Plus skip irrelevant settings when generating the settings table
as some settings are Lua or YAML only.

Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/rec-rust-lib/generate.py
pdns/recursordist/ws-recursor.cc

index 8737479a759f8f850be52354924eb4f49825e533..4d83a4ecb51d111870baef3483ecd0feffbdec06 100644 (file)
@@ -295,6 +295,8 @@ def gen_cxx_defineoldsettings(file, entries):
     """Generate C++ code to declare old-style settings"""
     file.write("void pdns::settings::rec::defineOldStyleSettings()\n{\n")
     for entry in entries:
+        if "skip-old" in entry:
+            continue
         helptxt = quote(entry["help"])
         oldname = quote(entry["oldname"])
         if entry["type"] == LType.Bool:
index 5c3bbab4ae325c8cae59a64c23e1d28493305f97..d8183d2c609b0f1944331eb5fc9727ff3cdf56c2 100644 (file)
@@ -65,11 +65,19 @@ std::optional<uint64_t> productServerStatisticsFetch(const std::string& name)
   return getStatByName(name);
 }
 
-static void apiWriteConfigFile(const string& filebasename, const string& content)
+static void checkApiDirSet()
 {
   if (::arg()["api-config-dir"].empty()) {
+    if (g_yamlSettings) {
+      throw ApiException("Config option webservice.api_dir must be set");
+    }
     throw ApiException("Config Option \"api-config-dir\" must be set");
   }
+}
+
+static void apiWriteConfigFile(const string& filebasename, const string& content)
+{
+  checkApiDirSet();
 
   string filename = ::arg()["api-config-dir"] + "/" + filebasename;
   if (g_yamlSettings) {
@@ -243,9 +251,7 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp)
 
 static void doCreateZone(const Json& document)
 {
-  if (::arg()["api-config-dir"].empty()) {
-    throw ApiException("Config Option \"api-config-dir\" must be set");
-  }
+  checkApiDirSet();
 
   const DNSName zone = apiNameToDNSName(stringFromJson(document, "name"));
   const string zonename = zone.toString();
@@ -347,9 +353,7 @@ static void doCreateZone(const Json& document)
 
 static bool doDeleteZone(const DNSName& zonename)
 {
-  if (::arg()["api-config-dir"].empty()) {
-    throw ApiException("Config Option \"api-config-dir\" must be set");
-  }
+  checkApiDirSet();
 
   string filename;
   if (g_yamlSettings) {
@@ -372,9 +376,7 @@ static bool doDeleteZone(const DNSName& zonename)
 
 static void apiServerZonesPOST(HttpRequest* req, HttpResponse* resp)
 {
-  if (::arg()["api-config-dir"].empty()) {
-    throw ApiException("Config Option \"api-config-dir\" must be set");
-  }
+  checkApiDirSet();
 
   Json document = req->json();