From: Aki Tuomi Date: Fri, 1 Nov 2013 21:19:34 +0000 (+0200) Subject: Implement get-meta/set-meta, also change \n to endl X-Git-Tag: rec-3.6.0-rc1~365^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=451ba512037270284ee6b5e82fb82216127664a9;p=pdns Implement get-meta/set-meta, also change \n to endl --- diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index 0f3633b6f..1c7bb482b 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -5,6 +5,7 @@ #include "base64.hh" #include #include +#include #include "dnsbackend.hh" #include "ueberbackend.hh" #include "arguments.hh" @@ -656,11 +657,11 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c ; } cerr<<"Flushing the pipe, "< [params ..]\n\n"; - cerr<<"Commands:\n"; - cerr<<"activate-zone-key ZONE KEY-ID Activate the key with key id KEY-ID in ZONE\n"; - cerr<<"add-zone-key ZONE zsk|ksk [bits] [active|passive]\n"; - cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]\n"; - cerr<<" Add a ZSK or KSK to zone and specify algo&bits\n"; - cerr<<"check-zone ZONE Check a zone for correctness\n"; - cerr<<"check-all-zones Check all zones for correctness\n"; - cerr<<"create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)\n"; - cerr<<"deactivate-zone-key ZONE KEY-ID Deactivate the key with key id KEY-ID in ZONE\n"; - cerr<<"disable-dnssec ZONE Deactivate all keys and unset PRESIGNED in ZONE\n"; - cerr<<"export-zone-dnskey ZONE KEY-ID Export to stdout the public DNSKEY described\n"; - cerr<<"export-zone-key ZONE KEY-ID Export to stdout the private key described\n"; - cerr<<"generate-zone-key zsk|ksk [algorithm] [bits]\n"; - cerr<<" Generate a ZSK or KSK to stdout with specified algo&bits\n"; - cerr<<"hash-zone-record ZONE RNAME Calculate the NSEC3 hash for RNAME in ZONE\n"; - cerr<<"increase-serial ZONE Increases the SOA-serial by 1. Uses SOA-EDIT\n"; - cerr<<"import-zone-key ZONE FILE Import from a file a private key, ZSK or KSK\n"; - cerr<<" [active|passive][ksk|zsk] Defaults to KSK and active\n"; - cerr<<"rectify-zone ZONE [ZONE ..] Fix up DNSSEC fields (order, auth)\n"; - cerr<<"rectify-all-zones Rectify all zones.\n"; - cerr<<"remove-zone-key ZONE KEY-ID Remove key with KEY-ID from ZONE\n"; - cerr<<"secure-zone ZONE [ZONE ..] Add KSK and two ZSKs\n"; - cerr<<"set-nsec3 ZONE ['params' [narrow]] Enable NSEC3 with PARAMs. Optionally narrow\n"; - cerr<<"set-presigned ZONE Use presigned RRSIGs from storage\n"; - cerr<<"show-zone ZONE Show DNSSEC (public) key details about a zone\n"; - cerr<<"unset-nsec3 ZONE Switch back to NSEC\n"; - cerr<<"unset-presigned ZONE No longer use presigned RRSIGs\n"; - cerr<<"test-schema ZONE Test DB schema - will create ZONE\n"; - cerr<<"import-tsig-key NAME ALGORITHM KEY Import TSIG key\n"; - cerr<<"create-tsig-key NAME ALGORITHM Generate new TSIG key\n"; - cerr<<"list-tsig-keys List all TSIG keys\n"; - cerr<<"delete-tsig-key NAME Delete TSIG key (warning! will not unmap key!)\n"; - cerr<<"enable-tsig-key ZONE NAME [master|slave]\n"; - cerr<<" Enable TSIG key for a zone\n"; - cerr<<"disable-tsig-key ZONE NAME [master|slave]\n"; - cerr<<" Disable TSIG key for a zone\n"; + cerr<<"Usage: \npdnssec [options] [params ..]\n"< keys; + DomainInfo di; + + if (!B.getDomainInfo(zone, di)) { + cerr << "Invalid zone '" << zone << "'" << endl; + return 1; + } + + if (cmds.size() > 2) { + keys.assign(cmds.begin() + 2, cmds.end()); + } else { + keys = boost::assign::list_of("ALLOW-AXFR-FROM") + ("ALLOW-2136-FROM")("TSIG-ALLOW-2136")("TSIG-ALLOW-2136") + ("SOA-EDIT-2136")("ALSO-NOTIFY")("AXFR-MASTER-TSIG") + ("LUA-AXFR-SCRIPT")("NSEC3NARROW")("NSEC3PARAM") + ("PRESIGNED")("SOA-EDIT")("TSIG-ALLOW-AXFR"); // NOTE: Add new metas here + + } + std::cout << "Metadata for '" << zone << "'" << endl; + BOOST_FOREACH(const string kind, keys) { + vector meta; + meta.clear(); + if (B.getDomainMetadata(zone, kind, meta)) { + cout << kind << " = " << boost::join(meta, ", ") << endl; + } + } + } else if (cmds[0]=="set-meta") { + UeberBackend B("default"); + if (cmds.size() < 3) { + cerr << "Syntax: " << cmds[0] << " zone kind [value value ..]" << endl; + return 1; + } + string zone = cmds[1]; + string kind = cmds[2]; + vector meta(cmds.begin() + 3, cmds.end()); + + if (!B.setDomainMetadata(zone, kind, meta)) { + cerr << "Unable to set meta for '" << zone << "'" << endl; + return 1; + } else { + cout << "Set '" << zone << "' meta " << kind << " = " << boost::join(meta, ", ") << endl; + } + } else { cerr<<"Unknown command '"<