]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Relax zone checks when removing a zone from a view.
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 05:34:56 +0000 (07:34 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 05:34:56 +0000 (07:34 +0200)
It's ok for the zone to no longer exist at this point.

Fixes: #16351
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/ws-auth.cc

index 73332f2b5cb79e183f4fd0ec6a94aa78dff1ea91..7fe71beb3415be7b789dfa2984a8495aed6a5c6c 100644 (file)
@@ -2863,20 +2863,23 @@ static void apiServerViewsPOST(HttpRequest* req, HttpResponse* resp)
 // DELETE /views/<view>/<id>     removes ZoneName "id" from view "view"
 static void apiServerViewsDELETE(HttpRequest* req, HttpResponse* resp)
 {
-  ZoneData zoneData{req};
+  // 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)) {
     throw ApiException(error);
   }
 
-  if (!zoneData.domainInfo.backend->viewDelZone(view, zoneData.zoneName)) {
-    throw ApiException("Failed to remove " + zoneData.zoneName.toString() + " from view " + view);
+  UeberBackend backend;
+  if (!backend.viewDelZone(view, zoneName)) {
+    throw ApiException("Failed to remove " + zoneName.toString() + " from view " + view);
   }
   // Notify zone cache of the removed association
   bool emptyView{false};
   if (g_zoneCache.isEnabled()) {
-    emptyView = g_zoneCache.removeFromView(view, zoneData.zoneName);
+    emptyView = g_zoneCache.removeFromView(view, zoneName);
   }
   // Purge packet cache for that zone
   if (PC.enabled()) {
@@ -2884,7 +2887,7 @@ static void apiServerViewsDELETE(HttpRequest* req, HttpResponse* resp)
       (void)PC.purgeView(view);
     }
     else {
-      std::string purgename = zoneData.zoneName.operator const DNSName&().toString();
+      std::string purgename = zoneName.operator const DNSName&().toString();
       purgename.append("$");
       (void)PC.purge(view, purgename);
     }