From 9b2ff836e0fb0cc82fff29577bfcf8e45e0c60ed Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Sat, 19 Jun 2021 13:33:55 +0200 Subject: [PATCH] pdnsutil create-zone: better error if default-soa-content is broken --- pdns/pdnsutil.cc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index a5c99b19d0..4eeb838838 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1394,12 +1394,6 @@ static int createZone(const DNSName &zone, const DNSName& nsname) { cerr << "Zone '" << zone << "' exists already" << endl; return EXIT_FAILURE; } - cerr<<"Creating empty zone '"<(), ""); - if(!B.getDomainInfo(zone, di)) { - cerr << "Zone '" << zone << "' was not created!" << endl; - return EXIT_FAILURE; - } DNSResourceRecord rr; rr.qname = zone; @@ -1410,8 +1404,29 @@ static int createZone(const DNSName &zone, const DNSName& nsname) { string soa = ::arg()["default-soa-content"]; boost::replace_all(soa, "@", zone.toStringNoDot()); SOAData sd; - fillSOAData(soa, sd); + try { + fillSOAData(soa, sd); + } + catch(const std::exception& e) { + cerr<<"Error while parsing default-soa-content ("<getZoneRepresentation(true); + + cerr<<"Creating empty zone '"<(), ""); + if(!B.getDomainInfo(zone, di)) { + cerr << "Zone '" << zone << "' was not created!" << endl; + return EXIT_FAILURE; + } + rr.domain_id = di.id; di.backend->startTransaction(zone, di.id); di.backend->feedRecord(rr, DNSName()); -- 2.47.2