From: Miod Vallat Date: Thu, 23 Oct 2025 05:34:56 +0000 (+0200) Subject: Relax zone checks when removing a zone from a view. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a912c5a1623372e87c663c55956bbd3dda652d0f;p=thirdparty%2Fpdns.git Relax zone checks when removing a zone from a view. It's ok for the zone to no longer exist at this point. Fixes: #16351 Signed-off-by: Miod Vallat --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 73332f2b5c..7fe71beb34 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -2863,20 +2863,23 @@ static void apiServerViewsPOST(HttpRequest* req, HttpResponse* resp) // DELETE /views// 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); }