Changeset 1760

Show
Ignore:
Timestamp:
12/27/10 20:25:04 (2 years ago)
Author:
ahu
Message:

align our key storage naming with the excellent ldns/nsd/unbound tools, which also found a few bugs in our storage

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

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

    r1758 r1760  
    3838  outputs_t outputs; 
    3939  push_back(outputs)("Modulus", &d_context.N)("PublicExponent",&d_context.E) 
    40     ("Modulus", &d_context.N) 
    41     ("PublicExponent",&d_context.E) 
    4240    ("PrivateExponent",&d_context.D) 
    4341    ("Prime1",&d_context.P) 
     
    8482  { 
    8583    //    cerr<<"Entry: '"<< dir_itr->leaf() <<"'"<<endl; 
    86     if(ends_with(dir_itr->leaf(),".isc")) { 
     84    if(ends_with(dir_itr->leaf(),".private")) { 
    8785      //      cerr<<"Hit!"<<endl; 
    8886 
     
    119117        ++dir_itr ) 
    120118  { 
    121           if(ends_with(dir_itr->leaf(),".isc")) { 
     119          if(ends_with(dir_itr->leaf(),".private")) { 
    122120                  maxID = max(maxID, (unsigned int)atoi(dir_itr->leaf().c_str())); 
    123121          } 
     
    171169   
    172170  {   
    173     ofstream iscFile((iscName+".isc").c_str()); 
     171    ofstream iscFile((iscName+".private").c_str()); 
    174172    iscFile << isc; 
    175173  } 
    176174 
    177175  {   
    178     ofstream dnskeyFile((iscName+".dnskey").c_str()); 
     176    ofstream dnskeyFile((iscName+".key").c_str()); 
    179177    dnskeyFile << toCanonic("", name) << " IN DNSKEY " << drc.getZoneRepresentation()<<endl; 
    180178  } 
     
    183181 
    184182 
    185 static bool zskCompareByID(const DNSSECKeeper::keyset_t::value_type& a, const DNSSECKeeper::keyset_t::value_type& b) 
    186 { 
    187   return a.second.id < b.second.id; 
     183static bool keyCompareByKindAndID(const DNSSECKeeper::keyset_t::value_type& a, const DNSSECKeeper::keyset_t::value_type& b) 
     184{ 
     185  return make_pair(!a.second.keyOrZone, a.second.id) < 
     186         make_pair(!b.second.keyOrZone, b.second.id); 
    188187} 
    189188 
    190189void DNSSECKeeper::removeKey(const std::string& zname, unsigned int id) 
    191190{ 
    192   // unlink((d_dirname +"/"+ zname +"/zsks/"+fname).c_str()); 
    193   abort(); 
     191  string fname = getKeyFilenameById(d_dirname+"/keys/", id); 
     192  if(unlink(fname.c_str()) < 0) 
     193    unixDie("removing key file '"+fname+"'"); 
    194194} 
    195195 
    196196void DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id) 
    197197{ 
    198   // unlink((d_dirname +"/"+ zname +"/zsks/"+fname).c_str()); 
    199198  string fname = getKeyFilenameById(d_dirname+"/keys/", id); 
    200199  string newname = boost::replace_last_copy(fname, ".active", ".passive"); 
     
    205204void DNSSECKeeper::activateKey(const std::string& zname, unsigned int id) 
    206205{ 
    207   // unlink((d_dirname +"/"+ zname +"/zsks/"+fname).c_str()); 
    208   abort(); 
     206  string fname = getKeyFilenameById(d_dirname+"/keys/", id); 
     207  string newname = boost::replace_last_copy(fname, ".passive", ".active"); 
     208  if(rename(fname.c_str(), newname.c_str()) < 0) 
     209    unixDie("renaming file to deactivate key, from: '"+fname+"' to '"+newname+"'"); 
    209210} 
    210211 
     
    264265  { 
    265266    //cerr<<"Entry: '"<< dir_itr->leaf() <<"'"<<endl; 
    266     if(ends_with(dir_itr->leaf(),".isc")) { 
     267    if(ends_with(dir_itr->leaf(),".private")) { 
    267268      DNSSECPrivateKey dpk; 
    268269      getRSAKeyFromISC(&dpk.d_key.getContext(), dir_itr->path().file_string().c_str()); 
     
    286287        &ts1.tm_mon, &ts1.tm_mday, &ts1.tm_hour, &ts1.tm_min); 
    287288              
    288  
    289289      ts1.tm_year -= 1900; 
    290        
    291290      ts1.tm_mon--; 
    292291       
     
    300299        keyset.push_back(make_pair(dpk, kmd)); 
    301300    } 
    302     sort(keyset.begin(), keyset.end(), zskCompareByID); 
     301    sort(keyset.begin(), keyset.end(), keyCompareByKindAndID); 
    303302  } 
    304303 
     
    343342 
    344343  {   
    345     ofstream iscFile((iscName+".isc").c_str()); 
     344    ofstream iscFile((iscName+".private").c_str()); 
    346345    iscFile << isc; 
    347346  } 
    348347 
    349348  {   
    350     ofstream dnskeyFile((iscName+".dnskey").c_str()); 
     349    ofstream dnskeyFile((iscName+".key").c_str()); 
    351350    dnskeyFile << toCanonic("", name) << " IN DNSKEY " << drc.getZoneRepresentation()<<endl; 
    352351  } 
  • trunk/pdns/pdns/misc.hh

    r1714 r1760  
    77    as published by the Free Software Foundation 
    88     
    9  
    109    This program is distributed in the hope that it will be useful, 
    1110    but WITHOUT ANY WARRANTY; without even the implied warranty of 
  • trunk/pdns/pdns/pdnssec.cc

    r1757 r1760  
    273273    const string& zone=cmds[1]; 
    274274     
    275     DNSSECKeeper::keyset_t keyset=dk.getKeys(zone, boost::indeterminate); 
     275    DNSSECKeeper::keyset_t keyset=dk.getKeys(zone); 
    276276 
    277277    if(keyset.empty())  {