5
5
#include " base64.hh"
6
6
#include < boost/foreach.hpp>
7
7
#include < boost/program_options.hpp>
8
+ #include < boost/assign/list_of.hpp>
8
9
#include " dnsbackend.hh"
9
10
#include " ueberbackend.hh"
10
11
#include " arguments.hh"
@@ -656,11 +657,11 @@ void testSpeed(DNSSECKeeper& dk, const string& zone, const string& remote, int c
656
657
;
657
658
}
658
659
cerr<<" Flushing the pipe, " <<csp.d_signed <<" signed, " <<csp.d_queued <<" queued, " <<csp.d_outstanding <<" outstanding" << endl;
659
- cerr<<" Net speed: " <<csp.d_signed / (dt.udiffNoReset ()/1000000.0 ) << " sigs/s\n " ;
660
+ cerr<<" Net speed: " <<csp.d_signed / (dt.udiffNoReset ()/1000000.0 ) << " sigs/s" <<endl ;
660
661
while (signatures = csp.getChunk (true ), !signatures.empty ())
661
662
;
662
663
cerr<<" Done, " <<csp.d_signed <<" signed, " <<csp.d_queued <<" queued, " <<csp.d_outstanding <<" outstanding" << endl;
663
- cerr<<" Net speed: " <<csp.d_signed / (dt.udiff ()/1000000.0 ) << " sigs/s\n " ;
664
+ cerr<<" Net speed: " <<csp.d_signed / (dt.udiff ()/1000000.0 ) << " sigs/s" <<endl ;
664
665
}
665
666
666
667
void verifyCrypto (const string& zone)
@@ -720,7 +721,7 @@ bool disableDNSSECOnZone(DNSSECKeeper& dk, const string& zone)
720
721
}
721
722
722
723
if (!dk.isSecuredZone (zone)) {
723
- cerr<<" Zone is not secured\n " ;
724
+ cerr<<" Zone is not secured" <<endl ;
724
725
return false ;
725
726
}
726
727
DNSSECKeeper::keyset_t keyset=dk.getKeys (zone);
@@ -750,7 +751,7 @@ bool showZone(DNSSECKeeper& dk, const std::string& zone)
750
751
}
751
752
752
753
if (!dk.isSecuredZone (zone)) {
753
- cerr<<" Zone is not actively secured\n " ;
754
+ cerr<<" Zone is not actively secured" <<endl ;
754
755
}
755
756
NSEC3PARAMRecordContent ns3pr;
756
757
bool narrow;
@@ -766,7 +767,7 @@ bool showZone(DNSSECKeeper& dk, const std::string& zone)
766
767
cerr << " Zone uses following TSIG key(s): " << boost::join (meta, " ," ) << endl;
767
768
}
768
769
769
- cout <<" Zone is " << (dk.isPresigned (zone) ? " " : " not " ) << " presigned\n " ;
770
+ cout <<" Zone is " << (dk.isPresigned (zone) ? " " : " not " ) << " presigned" <<endl ;
770
771
771
772
if (keyset.empty ()) {
772
773
cerr << " No keys for zone '" <<zone<<" '." <<endl;
@@ -863,19 +864,19 @@ bool secureZone(DNSSECKeeper& dk, const std::string& zone)
863
864
864
865
// run secure-zone with first default algorith, then add keys
865
866
if (!dk.secureZone (zone, shorthand2algorithm (k_algos[0 ]), k_size)) {
866
- cerr<<" No backend was able to secure '" <<zone<<" ', most likely because no DNSSEC\n " ;
867
- cerr<<" capable backends are loaded, or because the backends have DNSSEC disabled.\n " ;
868
- cerr<<" For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or\n " ;
869
- cerr<<" 'gpgsql-dnssec' flag. Also make sure the schema has been updated for DNSSEC!\n " ;
867
+ cerr<<" No backend was able to secure '" <<zone<<" ', most likely because no DNSSEC" <<endl ;
868
+ cerr<<" capable backends are loaded, or because the backends have DNSSEC disabled." <<endl ;
869
+ cerr<<" For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or" <<endl ;
870
+ cerr<<" 'gpgsql-dnssec' flag. Also make sure the schema has been updated for DNSSEC!" <<endl ;
870
871
return false ;
871
872
}
872
873
873
874
if (!dk.isSecuredZone (zone)) {
874
- cerr<<" Failed to secure zone. Is your backend dnssec enabled? (set \n " ;
875
- cerr<<" gsqlite3-dnssec, or gmysql-dnssec etc). Check this first.\n " ;
876
- cerr<<" If you run with the BIND backend, make sure you have configured\n " ;
877
- cerr<<" it to use DNSSEC with 'bind-dnssec-db=/path/fname' and\n " ;
878
- cerr<<" 'pdnssec create-bind-db /path/fname'!\n " ;
875
+ cerr<<" Failed to secure zone. Is your backend dnssec enabled? (set " <<endl ;
876
+ cerr<<" gsqlite3-dnssec, or gmysql-dnssec etc). Check this first." <<endl ;
877
+ cerr<<" If you run with the BIND backend, make sure you have configured" <<endl ;
878
+ cerr<<" it to use DNSSEC with 'bind-dnssec-db=/path/fname' and" <<endl ;
879
+ cerr<<" 'pdnssec create-bind-db /path/fname'!" <<endl ;
879
880
return false ;
880
881
}
881
882
@@ -1027,43 +1028,46 @@ try
1027
1028
g_verbose = g_vm.count (" verbose" );
1028
1029
1029
1030
if (cmds.empty () || g_vm.count (" help" )) {
1030
- cerr<<" Usage: \n pdnssec [options] <command> [params ..]\n\n " ;
1031
- cerr<<" Commands:\n " ;
1032
- cerr<<" activate-zone-key ZONE KEY-ID Activate the key with key id KEY-ID in ZONE\n " ;
1033
- cerr<<" add-zone-key ZONE zsk|ksk [bits] [active|passive]\n " ;
1034
- cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]\n " ;
1035
- cerr<<" Add a ZSK or KSK to zone and specify algo&bits\n " ;
1036
- cerr<<" check-zone ZONE Check a zone for correctness\n " ;
1037
- cerr<<" check-all-zones Check all zones for correctness\n " ;
1038
- cerr<<" create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)\n " ;
1039
- cerr<<" deactivate-zone-key ZONE KEY-ID Deactivate the key with key id KEY-ID in ZONE\n " ;
1040
- cerr<<" disable-dnssec ZONE Deactivate all keys and unset PRESIGNED in ZONE\n " ;
1041
- cerr<<" export-zone-dnskey ZONE KEY-ID Export to stdout the public DNSKEY described\n " ;
1042
- cerr<<" export-zone-key ZONE KEY-ID Export to stdout the private key described\n " ;
1043
- cerr<<" generate-zone-key zsk|ksk [algorithm] [bits]\n " ;
1044
- cerr<<" Generate a ZSK or KSK to stdout with specified algo&bits\n " ;
1045
- cerr<<" hash-zone-record ZONE RNAME Calculate the NSEC3 hash for RNAME in ZONE\n " ;
1046
- cerr<<" increase-serial ZONE Increases the SOA-serial by 1. Uses SOA-EDIT\n " ;
1047
- cerr<<" import-zone-key ZONE FILE Import from a file a private key, ZSK or KSK\n " ;
1048
- cerr<<" [active|passive][ksk|zsk] Defaults to KSK and active\n " ;
1049
- cerr<<" rectify-zone ZONE [ZONE ..] Fix up DNSSEC fields (order, auth)\n " ;
1050
- cerr<<" rectify-all-zones Rectify all zones.\n " ;
1051
- cerr<<" remove-zone-key ZONE KEY-ID Remove key with KEY-ID from ZONE\n " ;
1052
- cerr<<" secure-zone ZONE [ZONE ..] Add KSK and two ZSKs\n " ;
1053
- cerr<<" set-nsec3 ZONE ['params' [narrow]] Enable NSEC3 with PARAMs. Optionally narrow\n " ;
1054
- cerr<<" set-presigned ZONE Use presigned RRSIGs from storage\n " ;
1055
- cerr<<" show-zone ZONE Show DNSSEC (public) key details about a zone\n " ;
1056
- cerr<<" unset-nsec3 ZONE Switch back to NSEC\n " ;
1057
- cerr<<" unset-presigned ZONE No longer use presigned RRSIGs\n " ;
1058
- cerr<<" test-schema ZONE Test DB schema - will create ZONE\n " ;
1059
- cerr<<" import-tsig-key NAME ALGORITHM KEY Import TSIG key\n " ;
1060
- cerr<<" create-tsig-key NAME ALGORITHM Generate new TSIG key\n " ;
1061
- cerr<<" list-tsig-keys List all TSIG keys\n " ;
1062
- cerr<<" delete-tsig-key NAME Delete TSIG key (warning! will not unmap key!)\n " ;
1063
- cerr<<" enable-tsig-key ZONE NAME [master|slave]\n " ;
1064
- cerr<<" Enable TSIG key for a zone\n " ;
1065
- cerr<<" disable-tsig-key ZONE NAME [master|slave]\n " ;
1066
- cerr<<" Disable TSIG key for a zone\n " ;
1031
+ cerr<<" Usage: \n pdnssec [options] <command> [params ..]\n " <<endl;
1032
+ cerr<<" Commands:" <<endl;
1033
+ cerr<<" activate-zone-key ZONE KEY-ID Activate the key with key id KEY-ID in ZONE" <<endl;
1034
+ cerr<<" add-zone-key ZONE zsk|ksk [bits] [active|passive]" <<endl;
1035
+ cerr<<" [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]" <<endl;
1036
+ cerr<<" Add a ZSK or KSK to zone and specify algo&bits" <<endl;
1037
+ cerr<<" check-zone ZONE Check a zone for correctness" <<endl;
1038
+ cerr<<" check-all-zones Check all zones for correctness" <<endl;
1039
+ cerr<<" create-bind-db FNAME Create DNSSEC db for BIND backend (bind-dnssec-db)" <<endl;
1040
+ cerr<<" create-tsig-key NAME ALGORITHM Generate new TSIG key" <<endl;
1041
+ cerr<<" deactivate-zone-key ZONE KEY-ID Deactivate the key with key id KEY-ID in ZONE" <<endl;
1042
+ cerr<<" delete-tsig-key NAME Delete TSIG key (warning! will not unmap key!)" <<endl;
1043
+ cerr<<" disable-dnssec ZONE Deactivate all keys and unset PRESIGNED in ZONE" <<endl;
1044
+ cerr<<" disable-tsig-key ZONE NAME [master|slave]" <<endl;
1045
+ cerr<<" Disable TSIG key for a zone" <<endl;
1046
+ cerr<<" enable-tsig-key ZONE NAME [master|slave]" <<endl;
1047
+ cerr<<" Enable TSIG key for a zone" <<endl;
1048
+ cerr<<" export-zone-dnskey ZONE KEY-ID Export to stdout the public DNSKEY described" <<endl;
1049
+ cerr<<" export-zone-key ZONE KEY-ID Export to stdout the private key described" <<endl;
1050
+ cerr<<" generate-zone-key zsk|ksk [algorithm] [bits]" <<endl;
1051
+ cerr<<" Generate a ZSK or KSK to stdout with specified algo&bits" <<endl;
1052
+ cerr<<" get-meta ZONE [KIND] Get zone metadata. If no KIND given, lists all" <<endl;
1053
+ cerr<<" hash-zone-record ZONE RNAME Calculate the NSEC3 hash for RNAME in ZONE" <<endl;
1054
+ cerr<<" increase-serial ZONE Increases the SOA-serial by 1. Uses SOA-EDIT" <<endl;
1055
+ cerr<<" import-tsig-key NAME ALGORITHM KEY Import TSIG key" <<endl;
1056
+ cerr<<" import-zone-key ZONE FILE Import from a file a private key, ZSK or KSK" <<endl;
1057
+ cerr<<" [active|passive][ksk|zsk] Defaults to KSK and active" <<endl;
1058
+ cerr<<" list-tsig-keys List all TSIG keys" <<endl;
1059
+ cerr<<" rectify-zone ZONE [ZONE ..] Fix up DNSSEC fields (order, auth)" <<endl;
1060
+ cerr<<" rectify-all-zones Rectify all zones." <<endl;
1061
+ cerr<<" remove-zone-key ZONE KEY-ID Remove key with KEY-ID from ZONE" <<endl;
1062
+ cerr<<" secure-zone ZONE [ZONE ..] Add KSK and two ZSKs" <<endl;
1063
+ cerr<<" set-nsec3 ZONE ['params' [narrow]] Enable NSEC3 with PARAMs. Optionally narrow" <<endl;
1064
+ cerr<<" set-presigned ZONE Use presigned RRSIGs from storage" <<endl;
1065
+ cerr<<" set-meta ZONE KIND value [value ..]" <<endl;
1066
+ cerr<<" Set zone metadata, optionally providing more than one value" <<endl;
1067
+ cerr<<" show-zone ZONE Show DNSSEC (public) key details about a zone" <<endl;
1068
+ cerr<<" unset-nsec3 ZONE Switch back to NSEC" <<endl;
1069
+ cerr<<" unset-presigned ZONE No longer use presigned RRSIGs" <<endl;
1070
+ cerr<<" test-schema ZONE Test DB schema - will create ZONE" <<endl;
1067
1071
cerr<<desc<<endl;
1068
1072
return 0 ;
1069
1073
}
@@ -1437,7 +1441,7 @@ try
1437
1441
else if (pdns_iequals (cmds[4 ], " KSK" ))
1438
1442
dpk.d_flags = 257 ;
1439
1443
else {
1440
- cerr<<" Unknown key flag '" <<cmds[4 ]<<" '\n " ;
1444
+ cerr<<" Unknown key flag '" <<cmds[4 ]<<" '" <<endl ;
1441
1445
exit (1 );
1442
1446
}
1443
1447
}
@@ -1479,7 +1483,7 @@ try
1479
1483
else if (pdns_iequals (cmds[n], " passive" ) || pdns_iequals (cmds[n], " inactive" ))
1480
1484
active = 0 ;
1481
1485
else {
1482
- cerr<<" Unknown key flag '" <<cmds[n]<<" '\n " ;
1486
+ cerr<<" Unknown key flag '" <<cmds[n]<<" '" <<endl ;
1483
1487
exit (1 );
1484
1488
}
1485
1489
}
@@ -1706,8 +1710,56 @@ try
1706
1710
return 1 ;
1707
1711
}
1708
1712
return 0 ;
1709
- }
1710
- else {
1713
+ } else if (cmds[0 ]==" get-meta" ) {
1714
+ UeberBackend B (" default" );
1715
+ if (cmds.size () < 2 ) {
1716
+ cerr << " Syntax: " << cmds[0 ] << " zone [kind kind ..]" << endl;
1717
+ return 1 ;
1718
+ }
1719
+ string zone = cmds[1 ];
1720
+ vector<string> keys;
1721
+ DomainInfo di;
1722
+
1723
+ if (!B.getDomainInfo (zone, di)) {
1724
+ cerr << " Invalid zone '" << zone << " '" << endl;
1725
+ return 1 ;
1726
+ }
1727
+
1728
+ if (cmds.size () > 2 ) {
1729
+ keys.assign (cmds.begin () + 2 , cmds.end ());
1730
+ } else {
1731
+ keys = boost::assign::list_of (" ALLOW-AXFR-FROM" )
1732
+ (" ALLOW-2136-FROM" )(" TSIG-ALLOW-2136" )(" TSIG-ALLOW-2136" )
1733
+ (" SOA-EDIT-2136" )(" ALSO-NOTIFY" )(" AXFR-MASTER-TSIG" )
1734
+ (" LUA-AXFR-SCRIPT" )(" NSEC3NARROW" )(" NSEC3PARAM" )
1735
+ (" PRESIGNED" )(" SOA-EDIT" )(" TSIG-ALLOW-AXFR" ); // NOTE: Add new metas here
1736
+
1737
+ }
1738
+ std::cout << " Metadata for '" << zone << " '" << endl;
1739
+ BOOST_FOREACH (const string kind, keys) {
1740
+ vector<string> meta;
1741
+ meta.clear ();
1742
+ if (B.getDomainMetadata (zone, kind, meta)) {
1743
+ cout << kind << " = " << boost::join (meta, " , " ) << endl;
1744
+ }
1745
+ }
1746
+ } else if (cmds[0 ]==" set-meta" ) {
1747
+ UeberBackend B (" default" );
1748
+ if (cmds.size () < 3 ) {
1749
+ cerr << " Syntax: " << cmds[0 ] << " zone kind [value value ..]" << endl;
1750
+ return 1 ;
1751
+ }
1752
+ string zone = cmds[1 ];
1753
+ string kind = cmds[2 ];
1754
+ vector<string> meta (cmds.begin () + 3 , cmds.end ());
1755
+
1756
+ if (!B.setDomainMetadata (zone, kind, meta)) {
1757
+ cerr << " Unable to set meta for '" << zone << " '" << endl;
1758
+ return 1 ;
1759
+ } else {
1760
+ cout << " Set '" << zone << " ' meta " << kind << " = " << boost::join (meta, " , " ) << endl;
1761
+ }
1762
+ } else {
1711
1763
cerr<<" Unknown command '" <<cmds[0 ] << endl;
1712
1764
return 1 ;
1713
1765
}
0 commit comments