]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: pdnsutil, implement list-member-zones
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 22 Dec 2022 20:21:20 +0000 (21:21 +0100)
committermind04 <mind04@monshouwer.org>
Mon, 9 Jan 2023 21:16:56 +0000 (22:16 +0100)
docs/manpages/pdnsutil.1.rst
pdns/pdnsutil.cc

index f306dd4f80c7887bfdac40b3c7a2315efa9676f3..2de83ce0dfa9a4c2ad993947b2e6cb013f81e98f 100644 (file)
@@ -220,6 +220,8 @@ list-keys [*ZONE*]
 list-all-zones:
     List all active zone names. --verbose or -v will also include disabled
     or empty zones.
+list-member-zones *CATALOG*
+    List all members of catalog zone *CATALOG*"
 list-zone *ZONE*
     Show all records for *ZONE*.
 load-zone *ZONE* *FILE*
index efa69265dcc97a6e11f445bb47f03339e6cbda60..6799edf427ac9ae9d0a1f0a8186342638a91c2fd 100644 (file)
@@ -1775,6 +1775,47 @@ static int listAllZones(const string &type="") {
   return 0;
 }
 
+static int listMemberZones(const string& catalog)
+{
+
+  UeberBackend B("default");
+
+  DNSName catz(catalog);
+  DomainInfo di;
+  if (!B.getDomainInfo(catz, di)) {
+    cerr << "Zone '" << catz << "' not found" << endl;
+    return EXIT_FAILURE;
+  }
+  if (!di.isCatalogType()) {
+    cerr << "Zone '" << catz << "' is not a catalog zone" << endl;
+    return EXIT_FAILURE;
+  }
+
+  CatalogInfo::CatalogType type;
+  if (di.kind == DomainInfo::Producer) {
+    type = CatalogInfo::Producer;
+  }
+  else {
+    type = CatalogInfo::Consumer;
+  }
+
+  vector<CatalogInfo> members;
+  if (!di.backend->getCatalogMembers(catz, members, type)) {
+    cerr << "Backend does not support catalog zones" << endl;
+    return EXIT_FAILURE;
+  }
+
+  for (const auto& ci : members) {
+    cout << ci.d_zone << endl;
+  }
+
+  if (g_verbose) {
+    cout << "All zonecount: " << members.size() << endl;
+  }
+
+  return EXIT_SUCCESS;
+}
+
 static bool testAlgorithm(int algo)
 {
   return DNSCryptoKeyEngine::testOne(algo);
@@ -2563,6 +2604,7 @@ try
     cout << "list-zone ZONE                     List zone contents" << endl;
     cout << "list-all-zones [primary|secondary|native|producer|consumer]" << endl;
     cout << "                                   List all active zone names. --verbose or -v will also include disabled or empty zones" << endl;
+    cout << "list-member-zones CATALOG          List all members of catalog zone CATALOG" << endl;
 
     cout << "list-tsig-keys                     List all TSIG keys" << endl;
     cout << "publish-zone-key ZONE KEY-ID       Publish the zone key with key id KEY-ID in ZONE" << endl;
@@ -2791,6 +2833,13 @@ try
       return listAllZones(cmds.at(1));
     return listAllZones();
   }
+  else if (cmds.at(0) == "list-member-zones") {
+    if (cmds.size() != 2) {
+      cerr << "Syntax: pdnsutil list-member-zones CATALOG" << endl;
+      return 0;
+    }
+    return listMemberZones(cmds.at(1));
+  }
   else if (cmds.at(0) == "test-zone") {
     cerr << "Did you mean check-zone?"<<endl;
     return 0;