From 597b9b3ea566e3fb3cea378a71d4f2b6db4a0a5f Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Fri, 2 Oct 2015 19:09:29 +0200 Subject: [PATCH] pdnssec: add list-keys command, closes #2396 --- docs/manpages/pdnssec.1.md | 3 ++ pdns/pdnssec.cc | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/docs/manpages/pdnssec.1.md b/docs/manpages/pdnssec.1.md index 867a5f139..384188359 100644 --- a/docs/manpages/pdnssec.1.md +++ b/docs/manpages/pdnssec.1.md @@ -164,6 +164,9 @@ hash-zone-record *ZONE* *RNAME* : This convenience command hashes the name *RNAME* according to the NSEC3 settings of *ZONE*. Refuses to hash for zones with no NSEC3 settings. +list-keys [*ZONE*] +: List DNSSEC information for all keys or for *ZONE*. + list-all-zones: : List all zone names. diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index 3880e026d..f2b90563e 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -776,6 +776,84 @@ int deleteZone(const DNSName &zone) { return 1; } +void listKey(DomainInfo const &di, DNSSECKeeper& dk, bool printHeader = true) { + if (printHeader) { + cout<<"Zone Type Size Algorithm ID Location Keytag"< 29) + cout<(key.first.getKey()->getBits()).length() >= 8) ? 1 : 8 - lexical_cast(key.first.getKey()->getBits()).length(); + if (key.first.getKey()->getBits() < 1) { + cout<<"invalid "<getBits()<= 13) ? 1 : 13 - algname.length(); + cout<(key.second.id).length() > 5) ? 1 : 5 - lexical_cast(key.second.id).length(); + cout<convertToISCVector(); + string engine, slot, label = ""; + for (auto const &elem : stormap) { + //cout<= 12) ? 1 : 12 - engine.length()-slot.length()-label.length()-2; + cout< domainInfo; + B.getAllDomains(&domainInfo); + bool printHeader = true; + for (auto const di : domainInfo) { + listKey(di, dk, printHeader); + printHeader = false; + } + } + return true; +} + int listZone(const DNSName &zone) { UeberBackend B; DomainInfo di; @@ -1356,6 +1434,7 @@ try cerr<<" [active|passive] [ksk|zsk] Defaults to KSK and active"< 2) { + cerr<<"Syntax: pdnssec list-keys [ZONE]"<