From: Kees Monshouwer Date: Mon, 27 Jun 2022 08:59:49 +0000 (+0200) Subject: auth: add catalog to DomainInfo X-Git-Tag: auth-4.8.0-alpha0~7^2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4bc3a9e06c8b451d96d194d1eae94cf026ec6144;p=thirdparty%2Fpdns.git auth: add catalog to DomainInfo --- diff --git a/modules/gmysqlbackend/4.3.0_to_4.7.0_schema.mysql.sql b/modules/gmysqlbackend/4.3.0_to_4.7.0_schema.mysql.sql index 97fd3c465f..bb0956d0b7 100644 --- a/modules/gmysqlbackend/4.3.0_to_4.7.0_schema.mysql.sql +++ b/modules/gmysqlbackend/4.3.0_to_4.7.0_schema.mysql.sql @@ -1 +1,4 @@ ALTER TABLE domains ADD options VARCHAR(64000) DEFAULT NULL AFTER notified_serial; +ALTER TABLE domains ADD catalog VARCHAR(255) DEFAULT NULL AFTER options; + +CREATE INDEX catalog_idx ON domains(catalog); diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index 0b6073a6d3..af3bd54ea2 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -101,7 +101,7 @@ public: declare(suffix, "remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id=? and type is null"); declare(suffix, "delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id=? and name=? and type is null"); - declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,account from domains where name=?"); + declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name=?"); declare(suffix, "info-all-slaves-query", "", "select id,name,master,last_check from domains where type='SLAVE'"); declare(suffix, "supermaster-query", "", "select account from supermasters where ip=? and nameserver=?"); @@ -128,6 +128,7 @@ public: declare(suffix, "update-master-query", "", "update domains set master=? where name=?"); declare(suffix, "update-kind-query", "", "update domains set type=? where name=?"); declare(suffix, "update-options-query", "", "update domains set options=? where name=?"); + declare(suffix, "update-catalog-query", "", "update domains set catalog=? where name=?"); declare(suffix, "update-account-query", "", "update domains set account=? where name=?"); declare(suffix, "update-serial-query", "", "update domains set notified_serial=? where id=?"); declare(suffix, "update-lastcheck-query", "", "update domains set last_check=? where id=?"); diff --git a/modules/gmysqlbackend/schema.mysql.sql b/modules/gmysqlbackend/schema.mysql.sql index 6d7c17890d..554786aee1 100644 --- a/modules/gmysqlbackend/schema.mysql.sql +++ b/modules/gmysqlbackend/schema.mysql.sql @@ -6,11 +6,13 @@ CREATE TABLE domains ( type VARCHAR(6) NOT NULL, notified_serial INT UNSIGNED DEFAULT NULL, options VARCHAR(64000) DEFAULT NULL, + catalog VARCHAR(255) DEFAULT NULL, account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL, PRIMARY KEY (id) ) Engine=InnoDB CHARACTER SET 'latin1'; CREATE UNIQUE INDEX name_index ON domains(name); +CREATE INDEX catalog_idx ON domains(catalog); CREATE TABLE records ( diff --git a/modules/godbcbackend/4.3.0_to_4.7.0_schema.mssql.sql b/modules/godbcbackend/4.3.0_to_4.7.0_schema.mssql.sql index 8babd7aa98..b874edf348 100644 --- a/modules/godbcbackend/4.3.0_to_4.7.0_schema.mssql.sql +++ b/modules/godbcbackend/4.3.0_to_4.7.0_schema.mssql.sql @@ -1 +1,4 @@ ALTER TABLE domains ADD COLUMN options VARCHAR(MAX) DEFAULT NULL; +ALTER TABLE domains ADD COLUMN catalog VARCHAR(255) DEFAULT NULL; + +CREATE INDEX catalog_idx ON domains(catalog); diff --git a/modules/godbcbackend/godbcbackend.cc b/modules/godbcbackend/godbcbackend.cc index 055dedf697..60572cf5ac 100644 --- a/modules/godbcbackend/godbcbackend.cc +++ b/modules/godbcbackend/godbcbackend.cc @@ -81,7 +81,7 @@ public: declare(suffix, "remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id=? and type is null"); declare(suffix, "delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id=? and name=? and type is null"); - declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,account from domains where name=?"); + declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name=?"); declare(suffix, "info-all-slaves-query", "", "select id,name,master,last_check from domains where type='SLAVE'"); declare(suffix, "supermaster-query", "", "select account from supermasters where ip=? and nameserver=?"); @@ -108,6 +108,7 @@ public: declare(suffix, "update-master-query", "", "update domains set master=? where name=?"); declare(suffix, "update-kind-query", "", "update domains set type=? where name=?"); declare(suffix, "update-options-query", "", "update domains set options=? where name=?"); + declare(suffix, "update-catalog-query", "", "update domains set catalog=? where name=?"); declare(suffix, "update-account-query", "", "update domains set account=? where name=?"); declare(suffix, "update-serial-query", "", "update domains set notified_serial=? where id=?"); declare(suffix, "update-lastcheck-query", "", "update domains set last_check=? where id=?"); diff --git a/modules/godbcbackend/schema.mssql.sql b/modules/godbcbackend/schema.mssql.sql index 1646d4e665..14e4212370 100644 --- a/modules/godbcbackend/schema.mssql.sql +++ b/modules/godbcbackend/schema.mssql.sql @@ -6,11 +6,14 @@ CREATE TABLE domains ( type VARCHAR(6) NOT NULL, notified_serial INT DEFAULT NULL, options VARCHAR(MAX) DEFAULT NULL, + catalog VARCHAR(255) DEFAULT NULL, account VARCHAR(40) DEFAULT NULL, PRIMARY KEY (id) ); CREATE UNIQUE INDEX name_index ON domains(name); +CREATE INDEX catalog_idx ON domains(catalog); + CREATE TABLE records ( id INT IDENTITY, diff --git a/modules/gpgsqlbackend/4.3.0_to_4.7.0_schema.pgsql.sql b/modules/gpgsqlbackend/4.3.0_to_4.7.0_schema.pgsql.sql index ed9b6e2faa..420ec1d79a 100644 --- a/modules/gpgsqlbackend/4.3.0_to_4.7.0_schema.pgsql.sql +++ b/modules/gpgsqlbackend/4.3.0_to_4.7.0_schema.pgsql.sql @@ -1,8 +1,11 @@ BEGIN; ALTER TABLE domains ADD COLUMN options VARCHAR(65535) DEFAULT NULL; + ALTER TABLE domains ADD COLUMN catalog VARCHAR(255) DEFAULT NULL; ALTER TABLE domains ADD COLUMN account_new VARCHAR(40) DEFAULT NULL; UPDATE domains SET account_new = account; ALTER TABLE domains DROP COLUMN account; ALTER TABLE domains RENAME COLUMN account_new TO account; + + CREATE INDEX catalog_idx ON domains(catalog); COMMIT; diff --git a/modules/gpgsqlbackend/gpgsqlbackend.cc b/modules/gpgsqlbackend/gpgsqlbackend.cc index 2f7598e933..bbd39645e4 100644 --- a/modules/gpgsqlbackend/gpgsqlbackend.cc +++ b/modules/gpgsqlbackend/gpgsqlbackend.cc @@ -108,7 +108,7 @@ public: declare(suffix, "remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id=$1 and type is null"); declare(suffix, "delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id=$1 and name=$2 and type is null"); - declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,account from domains where name=$1"); + declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name=$1"); declare(suffix, "info-all-slaves-query", "", "select id,name,master,last_check from domains where type='SLAVE'"); declare(suffix, "supermaster-query", "", "select account from supermasters where ip=$1 and nameserver=$2"); @@ -135,6 +135,7 @@ public: declare(suffix, "update-master-query", "", "update domains set master=$1 where name=$2"); declare(suffix, "update-kind-query", "", "update domains set type=$1 where name=$2"); declare(suffix, "update-options-query", "", "update domains set options=$1 where name=$2"); + declare(suffix, "update-catalog-query", "", "update domains set catalog=$1 where name=$2"); declare(suffix, "update-account-query", "", "update domains set account=$1 where name=$2"); declare(suffix, "update-serial-query", "", "update domains set notified_serial=$1 where id=$2"); declare(suffix, "update-lastcheck-query", "", "update domains set last_check=$1 where id=$2"); diff --git a/modules/gpgsqlbackend/schema.pgsql.sql b/modules/gpgsqlbackend/schema.pgsql.sql index 29bb1793b5..535328998b 100644 --- a/modules/gpgsqlbackend/schema.pgsql.sql +++ b/modules/gpgsqlbackend/schema.pgsql.sql @@ -5,12 +5,14 @@ CREATE TABLE domains ( last_check INT DEFAULT NULL, type VARCHAR(6) NOT NULL, notified_serial BIGINT DEFAULT NULL, - options VARCHAR(65535) DEFAULT NULL; + options VARCHAR(65535) DEFAULT NULL, + catalog VARCHAR(255) DEFAULT NULL, account VARCHAR(40) DEFAULT NULL, CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT))) ); CREATE UNIQUE INDEX name_index ON domains(name); +CREATE INDEX catalog_idx ON domains(catalog); CREATE TABLE records ( diff --git a/modules/gsqlite3backend/4.3.1_to_4.7.0_schema.sqlite3.sql b/modules/gsqlite3backend/4.3.1_to_4.7.0_schema.sqlite3.sql index 32374d5ca2..b48071ff55 100644 --- a/modules/gsqlite3backend/4.3.1_to_4.7.0_schema.sqlite3.sql +++ b/modules/gsqlite3backend/4.3.1_to_4.7.0_schema.sqlite3.sql @@ -9,14 +9,16 @@ BEGIN TRANSACTION; type VARCHAR(6) NOT NULL, notified_serial INTEGER DEFAULT NULL, options VARCHAR(65535) DEFAULT NULL, + catalog VARCHAR(255) DEFAULT NULL, account VARCHAR(40) DEFAULT NULL ); - INSERT INTO domains_temp SELECT id,name,master,last_check,type,motified_serial,NULL,account FROM domains; + INSERT INTO domains_temp SELECT id,name,master,last_check,type,motified_serial,NULL,NULL,account FROM domains; DROP TABLE domains; ALTER TABLE domains_temp RENAME TO domains; CREATE UNIQUE INDEX name_index ON domains(name); + CREATE INDEX catalog_idx ON domains(catalog); COMMIT; PRAGMA foreign_keys = 1; diff --git a/modules/gsqlite3backend/gsqlite3backend.cc b/modules/gsqlite3backend/gsqlite3backend.cc index 55d9f387ac..a0ff8a0b8b 100644 --- a/modules/gsqlite3backend/gsqlite3backend.cc +++ b/modules/gsqlite3backend/gsqlite3backend.cc @@ -94,7 +94,7 @@ public: declare(suffix, "remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id=:domain_id and type is null"); declare(suffix, "delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id=:domain_id and name=:qname and type is null"); - declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,account from domains where name=:domain"); + declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name=:domain"); declare(suffix, "info-all-slaves-query", "", "select id,name,master,last_check from domains where type='SLAVE'"); declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver"); @@ -121,6 +121,7 @@ public: declare(suffix, "update-master-query", "", "update domains set master=:master where name=:domain"); declare(suffix, "update-kind-query", "", "update domains set type=:kind where name=:domain"); declare(suffix, "update-options-query", "", "update domains set options=:options where name=:domain"); + declare(suffix, "update-catalog-query", "", "update domains set catalog=:options where name=:domain"); declare(suffix, "update-account-query", "", "update domains set account=:account where name=:domain"); declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id"); declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id"); diff --git a/modules/gsqlite3backend/schema.sqlite3.sql b/modules/gsqlite3backend/schema.sqlite3.sql index 5067320755..d1663b28a9 100644 --- a/modules/gsqlite3backend/schema.sqlite3.sql +++ b/modules/gsqlite3backend/schema.sqlite3.sql @@ -7,11 +7,13 @@ CREATE TABLE domains ( last_check INTEGER DEFAULT NULL, type VARCHAR(6) NOT NULL, options VARCHAR(65535) DEFAULT NULL, + catalog VARCHAR(255) DEFAULT NULL, notified_serial INTEGER DEFAULT NULL, account VARCHAR(40) DEFAULT NULL ); CREATE UNIQUE INDEX name_index ON domains(name); +CREATE INDEX catalog_idx ON domains(catalog); CREATE TABLE records ( diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index ae620a295e..018faf820f 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -202,6 +202,7 @@ namespace serialization ar& g.notified_serial; ar& g.kind; ar& g.options; + ar& g.catalog; } template @@ -216,9 +217,11 @@ namespace serialization ar& g.kind; if (version >= 1) { ar& g.options; + ar& g.catalog; } else { g.options.clear(); + g.catalog.clear(); } } @@ -981,6 +984,13 @@ bool LMDBBackend::setOptions(const DNSName& domain, const std::string& options) }); } +bool LMDBBackend::setCatalog(const DNSName& domain, const DNSName& catalog) +{ + return genChangeDomain(domain, [catalog](DomainInfo& di) { + di.catalog = catalog; + }); +} + bool LMDBBackend::setAccount(const DNSName& domain, const std::string& account) { return genChangeDomain(domain, [account](DomainInfo& di) { diff --git a/modules/lmdbbackend/lmdbbackend.hh b/modules/lmdbbackend/lmdbbackend.hh index 70f9e54922..34a4eb95ac 100644 --- a/modules/lmdbbackend/lmdbbackend.hh +++ b/modules/lmdbbackend/lmdbbackend.hh @@ -107,6 +107,7 @@ public: void setFresh(uint32_t domain_id) override; void setNotified(uint32_t id, uint32_t serial) override; bool setOptions(const DNSName& domain, const std::string& options) override; + bool setCatalog(const DNSName& domain, const DNSName& options) override; bool setAccount(const DNSName& domain, const std::string& account) override; bool deleteDomain(const DNSName& domain) override; diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 0f4241c733..bf15ea450f 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -80,6 +80,7 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_UpdateSerialOfZoneQuery=getArg("update-serial-query"); d_UpdateLastCheckOfZoneQuery=getArg("update-lastcheck-query"); d_UpdateOptionsOfZoneQuery = getArg("update-options-query"); + d_UpdateCatalogOfZoneQuery = getArg("update-catalog-query"); d_UpdateAccountOfZoneQuery=getArg("update-account-query"); d_InfoOfAllMasterDomainsQuery=getArg("info-all-master-query"); d_DeleteDomainQuery=getArg("delete-domain-query"); @@ -154,6 +155,7 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_UpdateSerialOfZoneQuery_stmt = nullptr; d_UpdateLastCheckOfZoneQuery_stmt = nullptr; d_UpdateOptionsOfZoneQuery_stmt = nullptr; + d_UpdateCatalogOfZoneQuery_stmt = nullptr; d_UpdateAccountOfZoneQuery_stmt = nullptr; d_InfoOfAllMasterDomainsQuery_stmt = nullptr; d_DeleteDomainQuery_stmt = nullptr; @@ -296,6 +298,25 @@ bool GSQLBackend::setOptions(const DNSName& domain, const string& options) return true; } +bool GSQLBackend::setCatalog(const DNSName& domain, const DNSName& catalog) +{ + try { + reconnectIfNeeded(); + + // clang-format off + d_UpdateCatalogOfZoneQuery_stmt-> + bind("catalog", catalog)-> + bind("domain", domain)-> + execute()-> + reset(); + // clang-format on + } + catch (SSqlException& e) { + throw PDNSException("GSQLBackend unable to set catalog of domain '" + domain.toLogString() + "' to '" + catalog.toLogString() + "': " + e.txtReason()); + } + return true; +} + bool GSQLBackend::setAccount(const DNSName &domain, const string &account) { try { @@ -334,17 +355,18 @@ bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di, bool getS if(!numanswers) return false; - ASSERT_ROW_COLUMNS("info-zone-query", d_result[0], 8); + ASSERT_ROW_COLUMNS("info-zone-query", d_result[0], 9); pdns::checked_stoi_into(di.id, d_result[0][0]); try { di.zone=DNSName(d_result[0][1]); + di.catalog = (!d_result[0][7].empty() ? DNSName(d_result[0][7]) : DNSName()); } catch (...) { return false; } string type=d_result[0][5]; di.options = d_result[0][6]; - di.account = d_result[0][7]; + di.account = d_result[0][8]; di.kind = DomainInfo::stringToKind(type); vector masters; diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index dbe02aac61..e7ffdb3370 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -75,6 +75,7 @@ protected: d_UpdateMasterOfZoneQuery_stmt = d_db->prepare(d_UpdateMasterOfZoneQuery, 2); d_UpdateKindOfZoneQuery_stmt = d_db->prepare(d_UpdateKindOfZoneQuery, 2); d_UpdateOptionsOfZoneQuery_stmt = d_db->prepare(d_UpdateOptionsOfZoneQuery, 2); + d_UpdateCatalogOfZoneQuery_stmt = d_db->prepare(d_UpdateCatalogOfZoneQuery, 2); d_UpdateAccountOfZoneQuery_stmt = d_db->prepare(d_UpdateAccountOfZoneQuery, 2); d_UpdateSerialOfZoneQuery_stmt = d_db->prepare(d_UpdateSerialOfZoneQuery, 2); d_UpdateLastCheckOfZoneQuery_stmt = d_db->prepare(d_UpdateLastCheckOfZoneQuery, 2); @@ -142,6 +143,7 @@ protected: d_UpdateMasterOfZoneQuery_stmt.reset(); d_UpdateKindOfZoneQuery_stmt.reset(); d_UpdateOptionsOfZoneQuery_stmt.reset(); + d_UpdateCatalogOfZoneQuery_stmt.reset(); d_UpdateAccountOfZoneQuery_stmt.reset(); d_UpdateSerialOfZoneQuery_stmt.reset(); d_UpdateLastCheckOfZoneQuery_stmt.reset(); @@ -215,6 +217,7 @@ public: bool setMasters(const DNSName &domain, const vector &masters) override; bool setKind(const DNSName &domain, const DomainInfo::DomainKind kind) override; bool setOptions(const DNSName& domain, const string& options) override; + bool setCatalog(const DNSName& domain, const DNSName& catalog) override; bool setAccount(const DNSName &domain, const string &account) override; bool getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after) override; @@ -307,6 +310,7 @@ private: string d_UpdateMasterOfZoneQuery; string d_UpdateKindOfZoneQuery; string d_UpdateOptionsOfZoneQuery; + string d_UpdateCatalogOfZoneQuery; string d_UpdateAccountOfZoneQuery; string d_UpdateSerialOfZoneQuery; string d_UpdateLastCheckOfZoneQuery; @@ -381,6 +385,7 @@ private: unique_ptr d_UpdateMasterOfZoneQuery_stmt; unique_ptr d_UpdateKindOfZoneQuery_stmt; unique_ptr d_UpdateOptionsOfZoneQuery_stmt; + unique_ptr d_UpdateCatalogOfZoneQuery_stmt; unique_ptr d_UpdateAccountOfZoneQuery_stmt; unique_ptr d_UpdateSerialOfZoneQuery_stmt; unique_ptr d_UpdateLastCheckOfZoneQuery_stmt; diff --git a/pdns/backends/gsql/ssql.hh b/pdns/backends/gsql/ssql.hh index 7007d5fe90..7f2fd40c9d 100644 --- a/pdns/backends/gsql/ssql.hh +++ b/pdns/backends/gsql/ssql.hh @@ -57,7 +57,10 @@ public: virtual SSqlStatement* bind(const string& name, unsigned long long value)=0; virtual SSqlStatement* bind(const string& name, const std::string& value)=0; SSqlStatement* bind(const string& name, const DNSName& value) { - return bind(name, value.makeLowerCase().toStringRootDot()); + if (!value.empty()) { + return bind(name, value.makeLowerCase().toStringRootDot()); + } + return bind(name, string("")); } virtual SSqlStatement* bindNull(const string& name)=0; virtual SSqlStatement* execute()=0;; diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index a73d4438df..e48c0ca5ac 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -49,6 +49,7 @@ struct DomainInfo DomainInfo() : last_check(0), backend(nullptr), id(0), notified_serial(0), receivedNotify(false), serial(0), kind(DomainInfo::Native) {} DNSName zone; + DNSName catalog; time_t last_check; string options; string account; @@ -356,6 +357,12 @@ public: return false; } + //! Called when the catalog of a domain should be changed + virtual bool setCatalog(const DNSName& domain, const DNSName& catalog) + { + return false; + } + //! Called when the Account of a domain should be changed virtual bool setAccount(const DNSName &domain, const string &account) { diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 75826d1774..ad033150a2 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1875,6 +1875,22 @@ static int setZoneOptions(const DNSName& zone, const string& options) return EXIT_SUCCESS; } +static int setZoneCatalog(const DNSName& zone, const DNSName& catalog) +{ + UeberBackend B("default"); + DomainInfo di; + + if (!B.getDomainInfo(zone, di)) { + cerr << "No such zone " << zone << " in the database" << endl; + return EXIT_FAILURE; + } + if (!di.backend->setCatalog(zone, catalog)) { + cerr << "Could not find backend willing to accept new zone configuration" << endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + static int setZoneAccount(const DNSName& zone, const string &account) { UeberBackend B("default"); @@ -2122,6 +2138,10 @@ static bool showZone(DNSSECKeeper& dk, const DNSName& zone, bool exportDS = fals cout << "Options:" << endl; cout << di.options << endl; } + if (!di.catalog.empty()) { + cout << "Catalog: " << endl; + cout << di.catalog << endl; + } return true; } @@ -2486,6 +2506,7 @@ try cout << "secure-zone ZONE [ZONE ..] Add DNSSEC to zone ZONE" << endl; cout << "set-kind ZONE KIND Change the kind of ZONE to KIND (primary, secondary, native)" << endl; cout << "set-options ZONE OPTIONS Change the options of ZONE to OPTIONS" << endl; + cout << "set-catalog ZONE CATALOG Change the catalog of ZONE to CATALOG" << endl; cout << "set-account ZONE ACCOUNT Change the account (owner) of ZONE to ACCOUNT" << endl; cout << "set-nsec3 ZONE ['PARAMS' [narrow]] Enable NSEC3 with PARAMS. Optionally narrow" << endl; cout << "set-presigned ZONE Use presigned RRSIGs from storage" << endl; @@ -3138,15 +3159,29 @@ try return 0; } // Verify json - std::string err; - json11::Json doc = json11::Json::parse(cmds.at(2), err); - if (doc.is_null()) { - cerr << "Parsing of JSON document failed:" << err << endl; - return EXIT_FAILURE; + if (!cmds.at(2).empty()) { + std::string err; + json11::Json doc = json11::Json::parse(cmds.at(2), err); + if (doc.is_null()) { + cerr << "Parsing of JSON document failed:" << err << endl; + return EXIT_FAILURE; + } } DNSName zone(cmds.at(1)); return setZoneOptions(zone, cmds.at(2)); } + else if (cmds.at(0) == "set-catalog") { + if (cmds.size() != 3) { + cerr << "Syntax: pdnsutil set-catalog ZONE CATALOG" << endl; + return 0; + } + DNSName zone(cmds.at(1)); + DNSName catalog; // Create an empty DNSName() + if (!cmds.at(2).empty()) { + catalog = DNSName(cmds.at(2)); + } + return setZoneCatalog(zone, catalog); + } else if (cmds.at(0) == "set-account") { if(cmds.size() != 3) { cerr<<"Syntax: pdnsutil set-account ZONE ACCOUNT"<