From: Peter van Dijk Date: Sat, 19 Jun 2021 11:33:55 +0000 (+0200) Subject: pdnsutil create-zone: better error if default-soa-content is broken X-Git-Tag: dnsdist-1.7.0-alpha1~132^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10509%2Fhead;p=thirdparty%2Fpdns.git pdnsutil create-zone: better error if default-soa-content is broken --- 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());