From: Miod Vallat Date: Thu, 23 Oct 2025 06:24:47 +0000 (+0200) Subject: On second thought, relax the zone check for the view add operation too. X-Git-Tag: auth-5.0.1~1^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16360%2Fhead;p=thirdparty%2Fpdns.git On second thought, relax the zone check for the view add operation too. Signed-off-by: Miod Vallat (cherry picked from commit d6f700a88b9038298ac55023a7eb5bc66a8eb575) --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 51664fdeba..e3de1d2abe 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -2742,17 +2742,15 @@ static void apiServerViewsGET(HttpRequest* req, HttpResponse* resp) // POST /views/ + 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"]}; - 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 @@ -2776,6 +2774,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"]}; UeberBackend backend;