Changeset 2221

Show
Ignore:
Timestamp:
06/29/11 10:12:52 (2 years ago)
Author:
ahu
Message:

someone anonymous contributed this patch, thanks!

- Fix up spelling mistake - remove keys when using disable-dnssec - Fix
- formatting of help - Do better checking of arguments given to commands -
- When adding a key don't activate it initially.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/pdnssec.cc

    r2216 r2221  
    349349    BOOST_FOREACH(DNSSECKeeper::keyset_t::value_type value, keyset) { 
    350350      dk.deactivateKey(zone, value.second.id); 
     351      dk.removeKey(zone, value.second.id); 
    351352    } 
    352353  } 
     
    464465    cerr<<"Usage: \npdnssec [options] [show-zone] [secure-zone] [rectify-zone] [add-zone-key] [deactivate-zone-key] [remove-zone-key] [activate-zone-key]\n"; 
    465466    cerr<<"         [import-zone-key] [export-zone-key] [set-nsec3] [set-presigned] [unset-nsec3] [unset-presigned] [export-zone-dnskey]\n\n"; 
    466     cerr<<"activate-zone-key ZONE KEY-ID   Activate the key with key id KEY-ID in ZONE\n"; 
    467     cerr<<"add-zone-key ZONE [zsk|ksk]     Add a ZSK or KSK to a zone\n"; 
    468     cerr<<"  [bits] [rsasha1|rsasha256]    and specify algorithm & bits\n"; 
    469     cerr<<"check-zone ZONE                 Check a zone for correctness\n"; 
    470     cerr<<"deactivate-zone-key             Dectivate the key with key id KEY-ID in ZONE\n"; 
    471     cerr<<"disable-dnssec ZONE             Deactivate all keys and unset PRESIGNED\n"; 
    472     cerr<<"export-zone-dnskey ZONE KEY-ID  Export to stdout the public DNSKEY described\n"; 
    473     cerr<<"export-zone-key ZONE KEY-ID     Export to stdout the private key described\n"; 
    474     cerr<<"hash-zone-record ZONE RNAME     Calculate the NSEC3 hash for RNAME in ZONE\n"; 
    475     cerr<<"import-zone-key ZONE FILE       Import from a file a private key, ZSK or KSK\n";             
    476     cerr<<"                [ksk|zsk]       Defaults to KSK\n"; 
    477     cerr<<"rectify-zone ZONE               Fix up DNSSEC fields (order, auth)\n"; 
    478     cerr<<"remove-zone-key ZONE KEY-ID     Remove key with KEY-ID from ZONE\n"; 
    479     cerr<<"secure-zone ZONE                Add KSK and two ZSKs\n"; 
    480     cerr<<"set-nsec3 ZONE 'params' [narrow]     Enable NSEC3 with PARAMs. Optionally narrow\n"; 
    481     cerr<<"set-presigned ZONE              Use presigned RRSIGs from storage\n"; 
    482     cerr<<"show-zone ZONE                  Show DNSSEC (public) key details about a zone\n"; 
    483     cerr<<"unset-nsec3 ZONE                Switch back to NSEC\n"; 
    484     cerr<<"unset-presigned ZONE            No longer use presigned RRSIGs\n\n"; 
     467    cerr<<"activate-zone-key ZONE KEY-ID    Activate the key with key id KEY-ID in ZONE\n"; 
     468    cerr<<"add-zone-key ZONE [zsk|ksk]      Add a ZSK or KSK to a zone\n"; 
     469    cerr<<"  [bits] [rsasha1|rsasha256]     and specify algorithm & bits\n"; 
     470    cerr<<"check-zone ZONE                  Check a zone for correctness\n"; 
     471    cerr<<"deactivate-zone-key ZONE KEY-ID  Deactivate the key with key id KEY-ID in ZONE\n"; 
     472    cerr<<"disable-dnssec ZONE              Deactivate all keys and unset PRESIGNED in ZONE\n"; 
     473    cerr<<"export-zone-dnskey ZONE KEY-ID   Export to stdout the public DNSKEY described\n"; 
     474    cerr<<"export-zone-key ZONE KEY-ID      Export to stdout the private key described\n"; 
     475    cerr<<"hash-zone-record ZONE RNAME      Calculate the NSEC3 hash for RNAME in ZONE\n"; 
     476    cerr<<"import-zone-key ZONE FILE        Import from a file a private key, ZSK or KSK\n";             
     477    cerr<<"                [ksk|zsk]        Defaults to KSK\n"; 
     478    cerr<<"rectify-zone ZONE                Fix up DNSSEC fields (order, auth)\n"; 
     479    cerr<<"remove-zone-key ZONE KEY-ID      Remove key with KEY-ID from ZONE\n"; 
     480    cerr<<"secure-zone ZONE                 Add KSK and two ZSKs\n"; 
     481    cerr<<"set-nsec3 ZONE 'params' [narrow] Enable NSEC3 with PARAMs. Optionally narrow\n"; 
     482    cerr<<"set-presigned ZONE               Use presigned RRSIGs from storage\n"; 
     483    cerr<<"show-zone ZONE                   Show DNSSEC (public) key details about a zone\n"; 
     484    cerr<<"unset-nsec3 ZONE                 Switch back to NSEC\n"; 
     485    cerr<<"unset-presigned ZONE             No longer use presigned RRSIGs\n\n"; 
    485486    cerr<<"Options:"<<endl; 
    486487    cerr<<desc<<endl; 
     
    497498  DNSSECKeeper dk; 
    498499 
    499   if(cmds[0] == "rectify-zone" || cmds[0] == "order-zone") { 
     500  if(cmds[0] == "rectify-zone") { 
    500501    if(cmds.size() != 2) { 
    501       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     502      cerr << "Syntax: pdnssec rectify-zone ZONE"<<endl; 
    502503      return 0; 
    503504    } 
     
    506507  else if(cmds[0] == "check-zone") { 
    507508    if(cmds.size() != 2) { 
    508       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     509      cerr << "Syntax: pdnssec check-zone ZONE"<<endl; 
    509510      return 0; 
    510511    } 
     
    522523#endif 
    523524  else if(cmds[0] == "test-speed") { 
    524     if(cmds.size() < 3) { 
    525       cerr << "Error: "<<cmds[0]<<" takes  2 or 3 parameters, zone numcores [signing-server]"<<endl; 
     525    if(cmds.size() < 2) { 
     526      cerr << "Syntax: pdnssec test-speed numcores [signing-server]"<<endl; 
    526527      return 0; 
    527528    } 
     
    530531  else if(cmds[0] == "verify-crypto") { 
    531532    if(cmds.size() != 2) { 
    532       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     533      cerr << "Syntax: pdnssec verify-crypto FILE"<<endl; 
    533534      return 0; 
    534535    } 
     
    538539  else if(cmds[0] == "show-zone") { 
    539540    if(cmds.size() != 2) { 
    540       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     541      cerr << "Syntax: pdnssec show-zone ZONE"<<endl; 
    541542      return 0; 
    542543    } 
     
    546547  else if(cmds[0] == "disable-dnssec") { 
    547548    if(cmds.size() != 2) { 
    548       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     549      cerr << "Syntax: pdnssec disable-dnssec ZONE"<<endl; 
    549550      return 0; 
    550551    } 
     
    553554  } 
    554555  else if(cmds[0] == "activate-zone-key") { 
     556    if(cmds.size() != 3) { 
     557      cerr << "Syntax: pdnssec activate-zone-key ZONE KEY-ID"<<endl; 
     558      return 0; 
     559    } 
    555560    const string& zone=cmds[1]; 
    556561    unsigned int id=atoi(cmds[2].c_str()); 
     
    558563  } 
    559564  else if(cmds[0] == "deactivate-zone-key") { 
     565    if(cmds.size() != 3) { 
     566      cerr << "Syntax: pdnssec deactivate-zone-key ZONE KEY-ID"<<endl; 
     567      return 0; 
     568    } 
    560569    const string& zone=cmds[1]; 
    561570    unsigned int id=atoi(cmds[2].c_str()); 
     
    563572  } 
    564573  else if(cmds[0] == "add-zone-key") { 
     574    if(cmds.size() < 3 ) { 
     575      cerr << "Syntax: pdnssec add-zone-key ZONE [zsk|ksk] [bits] [rsasha1|rsasha256]"<<endl; 
     576      return 0; 
     577    } 
    565578    const string& zone=cmds[1]; 
    566579    // need to get algorithm, bits & ksk or zsk from commandline 
     
    595608    if(bits) 
    596609      cerr<<"Requesting specific key size of "<<bits<<" bits"<<endl; 
    597     dk.addKey(zone, keyOrZone, algorithm, bits);  
     610    dk.addKey(zone, keyOrZone, algorithm, bits, false);  
    598611  } 
    599612  else if(cmds[0] == "remove-zone-key") { 
    600613    if(cmds.size() < 3) { 
    601       cerr<<"Syntax: pdnssec remove-zone-key ZONE KEY-ID\n"; 
     614      cerr<<"Syntax: pdnssec remove-zone-key ZONE KEY-ID"; 
    602615      return 0; 
    603616    } 
     
    609622  else if(cmds[0] == "secure-zone") { 
    610623    if(cmds.size() < 2) { 
    611       cerr << "Error: "<<cmds[0]<<" takes at least 1 parameter"<<endl; 
     624      cerr << "Syntax: pdnssec secure-zone ZONE"<<endl; 
    612625      return 0; 
    613626    } 
     
    626639  } 
    627640  else if(cmds[0]=="set-nsec3") { 
     641    if(cmds.size() < 2) { 
     642      cerr<<"Syntax: pdnssec set-nsec3 ZONE 'params' [narrow]"<<endl; 
     643      return 0; 
     644    } 
    628645    string nsec3params =  cmds.size() > 2 ? cmds[2] : "1 1 1 ab"; 
    629646    bool narrow = cmds.size() > 3 && cmds[3]=="narrow"; 
     
    638655  else if(cmds[0]=="set-presigned") { 
    639656    if(cmds.size() < 2) { 
    640       cerr<<"Wrong number of arguments, syntax: set-presigned DOMAIN"<<endl; 
     657      cerr<<"Syntax: pdnssec set-presigned ZONE"<<endl; 
     658      return 0;  
    641659    } 
    642660    dk.setPresigned(cmds[1]); 
    643661  } 
    644662  else if(cmds[0]=="unset-presigned") { 
    645         if(cmds.size() < 2) { 
    646                 cerr<<"Wrong number of arguments, syntax: unset-presigned DOMAIN"<<endl; 
    647         } 
     663    if(cmds.size() < 2) { 
     664      cerr<<"Syntax: pdnssec unset-presigned ZONE"<<endl; 
     665      return 0;  
     666    } 
    648667    dk.unsetPresigned(cmds[1]); 
    649668  } 
    650669  else if(cmds[0]=="hash-zone-record") { 
    651670    if(cmds.size() < 3) { 
    652       cerr<<"Wrong number of arguments, syntax: hash-zone-record ZONE RECORD"<<endl; 
     671      cerr<<"Syntax: pdnssec hash-zone-record ZONE RNAME"<<endl; 
    653672      return 0; 
    654673    } 
     
    668687  } 
    669688  else if(cmds[0]=="unset-nsec3") { 
     689    if(cmds.size() < 2) { 
     690      cerr<<"Syntax: pdnssec unset-nsec3 ZONE"<<endl; 
     691      exit(1); 
     692    } 
    670693    dk.unsetNSEC3PARAM(cmds[1]); 
    671694  } 
    672695  else if(cmds[0]=="export-zone-key") { 
    673696    if(cmds.size() < 3) { 
    674       cerr<<"Syntax: pdnssec export-zone-key zone-name id"<<endl; 
    675       cerr<<cmds.size()<<endl; 
     697      cerr<<"Syntax: pdnssec export-zone-key ZONE KEY-ID"<<endl; 
    676698      exit(1); 
    677699    } 
     
    684706  else if(cmds[0]=="import-zone-key-pem") { 
    685707    if(cmds.size() < 4) { 
    686       cerr<<"Syntax: pdnssec import-zone-key zone-name filename.pem algorithm [zsk|ksk]"<<endl; 
     708      cerr<<"Syntax: pdnssec import-zone-key ZONE FILE algorithm [zsk|ksk]"<<endl; 
    687709      exit(1); 
    688710    } 
     
    728750  } 
    729751  else if(cmds[0]=="import-zone-key") { 
    730     if(cmds.size() < 3) { 
    731       cerr<<"Syntax: pdnssec import-zone-key zone-name filename [zsk|ksk]"<<endl; 
     752    if(cmds.size() < 4) { 
     753      cerr<<"Syntax: pdnssec import-zone-key ZONE FILE [zsk|ksk]"<<endl; 
    732754      exit(1); 
    733755    } 
     
    762784  else if(cmds[0]=="export-zone-dnskey") { 
    763785    if(cmds.size() < 3) { 
    764       cerr<<"Syntax: pdnssec export-zone-dnskey zone-name id"<<endl; 
     786      cerr<<"Syntax: pdnssec export-zone-dnskey ZONE KEY-ID"<<endl; 
    765787      exit(1); 
    766788    }