]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
On second thought, relax the zone check for the view add operation too. 16352/head
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 06:24:47 +0000 (08:24 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 06:24:47 +0000 (08:24 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/ws-auth.cc

index 7fe71beb3415be7b789dfa2984a8495aed6a5c6c..10400a523e86b2f077dbdac890cdece3231f157e 100644 (file)
@@ -2828,21 +2828,19 @@ static void apiServerViewsGET(HttpRequest* req, HttpResponse* resp)
 // POST /views/<view> + name in json adds ZoneName "name" to view "view"
 static void apiServerViewsPOST(HttpRequest* req, HttpResponse* resp)
 {
-  UeberBackend backend;
-  DomainInfo domainInfo;
   const auto& document = req->json();
+  // We can't use a ZoneData object here, as the zone being added to the
+  // view may not exist yet.
   ZoneName zonename = apiNameToZoneName(stringFromJson(document, "name"));
 
-  if (!backend.getDomainInfo(zonename, domainInfo)) {
-    throw ApiException("Zone " + zonename.toString() + " does not exist");
-  }
   std::string view{req->parameters["view"]};
   std::string error;
   if (!Check::validateViewName(view, error)) {
     throw ApiException(error);
   }
 
-  if (!domainInfo.backend->viewAddZone(view, zonename)) {
+  UeberBackend backend;
+  if (!backend.viewAddZone(view, zonename)) {
     throw ApiException("Failed to add " + zonename.toString() + " to view " + view);
   }
   // Notify zone cache of the new association
@@ -2866,6 +2864,7 @@ static void apiServerViewsDELETE(HttpRequest* req, HttpResponse* resp)
   // We can't use a ZoneData object here, as the zone being removed from the
   // view may no longer exist.
   ZoneName zoneName(apiZoneIdToName(req->parameters["id"]));
+
   std::string view{req->parameters["view"]};
   std::string error;
   if (!Check::validateViewName(view, error)) {