]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: report DomainInfo errors in the API
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 12 Mar 2019 11:47:26 +0000 (12:47 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Thu, 21 Mar 2019 09:37:06 +0000 (10:37 +0100)
pdns/ws-auth.cc

index d2c3f9ae0db3a53decb4afdb72d649b9bcc34964..df59b7eaf1d80df13c08d926cd8bdf6feac58c4e 100644 (file)
@@ -620,6 +620,11 @@ static void updateDomainSettingsFromDocument(UeberBackend& B, const DomainInfo&
     string master = value.string_value();
     if (master.empty())
       throw ApiException("Master can not be an empty string");
+    try {
+      ComboAddress m(master);
+    } catch (const PDNSException &e) {
+      throw ApiException("Master (" + master + ") is not an IP address: " + e.reason);
+    }
     zonemaster.push_back(master);
   }
 
@@ -1689,8 +1694,12 @@ static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
 
   UeberBackend B;
   DomainInfo di;
-  if (!B.getDomainInfo(zonename, di)) {
-    throw HttpNotFoundException();
+  try {
+    if (!B.getDomainInfo(zonename, di)) {
+      throw HttpNotFoundException();
+    }
+  } catch(const PDNSException &e) {
+    throw HttpInternalServerErrorException("Could not retrieve Domain Info: " + e.reason);
   }
 
   if(req->method == "PUT") {