Allow setting the account of a zone via pdnsutil
authorMark Schouten <mark@tuxis.nl>
Tue, 18 Oct 2016 13:51:36 +0000 (15:51 +0200)
committerMark Schouten <mark@tuxis.nl>
Thu, 8 Dec 2016 14:41:13 +0000 (15:41 +0100)
pdns/pdnsutil.cc

index f8fbbb94f517e63a18d101df2bcff3e4ea7d4a9e..6a31935db53267613553632d5685cb3b68ee247e 100644 (file)
@@ -1504,6 +1504,23 @@ bool disableDNSSECOnZone(DNSSECKeeper& dk, const DNSName& zone)
   return true;
 }
 
+int setZoneAccount(const DNSName& zone, const string &account)
+{
+  UeberBackend B("default");
+  DomainInfo di;
+  std::vector<std::string> meta;
+
+  if (!B.getDomainInfo(zone, di)){
+    cerr << "No such zone "<<zone<<" in the database" << endl;
+    return EXIT_FAILURE;
+  }
+  if(!di.backend->setAccount(zone, account)) {
+    cerr<<"Could not find backend willing to accept new zone configuration"<<endl;
+    return EXIT_FAILURE;
+  }
+  return EXIT_SUCCESS;
+}
+
 int setZoneKind(const DNSName& zone, const DomainInfo::DomainKind kind)
 {
   UeberBackend B("default");
@@ -2034,6 +2051,7 @@ try
     cout<<"secure-all-zones [increase-serial] Secure all zones without keys"<<endl;
     cout<<"secure-zone ZONE [ZONE ..]         Add DNSSEC to zone ZONE"<<endl;
     cout<<"set-kind ZONE KIND                 Change the kind of ZONE to KIND (master, slave native)"<<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;
     cout<<"set-publish-cdnskey ZONE           Enable sending CDNSKEY responses for ZONE"<<endl;
@@ -2498,6 +2516,13 @@ loadMainConfig(g_vm["config-dir"].as<string>());
     auto kind=DomainInfo::stringToKind(cmds[2]);
     exit(setZoneKind(zone, kind));
   }
+  else if(cmds[0]=="set-account") {
+    if(cmds.size() != 3) {
+      cerr<<"Syntax: pdnsutil set-account ZONE ACCOUNT"<<endl;
+    }
+    DNSName zone(cmds[1]);
+    exit(setZoneAccount(zone, cmds[2]));
+  }
   else if(cmds[0]=="set-nsec3") {
     if(cmds.size() < 2) {
       cerr<<"Syntax: pdnsutil set-nsec3 ZONE 'params' [narrow]"<<endl;