Changeset 1791

Show
Ignore:
Timestamp:
01/02/11 20:40:46 (2 years ago)
Author:
ahu
Message:

hook up activate-domain-key, deactivate-domain-key, remove-domain-key

Location:
trunk/pdns/pdns
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/backends/gsql/gsqlbackend.cc

    r1790 r1791  
    102102      SOAData sd; 
    103103      if(!getSOA(domain,sd))  
    104         L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl; 
     104        L<<Logger::Notice<<"No serial for '"<<domain<<"' found - zone is missing?"<<endl; 
    105105      else 
    106         di.serial=sd.serial; 
     106        di.serial=sd.serial; 
    107107    } 
    108108    catch(AhuException &ae){ 
     
    251251  d_ClearDomainMetadataQuery = "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'"; 
    252252  d_SetDomainMetadataQuery = "insert into domainmetadata (domain_id, kind, content) select id, '%s', '%s' from domains where name='%s'"; 
     253   
     254  d_ActivateDomainKeyQuery = "update cryptokeys set active=1 where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d"; 
     255  d_DeactivateDomainKeyQuery = "update cryptokeys set active=0 where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d"; 
     256  d_RemoveDomainKeyQuery = "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d"; 
    253257} 
    254258 
     
    327331  return 1; // XXX FIXME, no idea how to get the id 
    328332} 
     333 
     334bool GSQLBackend::activateDomainKey(const string& name, unsigned int id) 
     335{ 
     336  char output[1024]; 
     337  snprintf(output,sizeof(output)-1,d_ActivateDomainKeyQuery.c_str(), sqlEscape(name).c_str(), id); 
     338 
     339  try { 
     340    d_db->doCommand(output); 
     341  } 
     342  catch (SSqlException &e) { 
     343    throw AhuException("GSQLBackend unable to activate key: "+e.txtReason()); 
     344  } 
     345  return true; 
     346} 
     347 
     348bool GSQLBackend::deactivateDomainKey(const string& name, unsigned int id) 
     349{ 
     350  char output[1024]; 
     351  snprintf(output,sizeof(output)-1,d_DeactivateDomainKeyQuery.c_str(), sqlEscape(name).c_str(), id); 
     352 
     353  try { 
     354    d_db->doCommand(output); 
     355  } 
     356  catch (SSqlException &e) { 
     357    throw AhuException("GSQLBackend unable to deactivate key: "+e.txtReason()); 
     358  } 
     359  return true; 
     360} 
     361 
     362bool GSQLBackend::removeDomainKey(const string& name, unsigned int id) 
     363{ 
     364  char output[1024]; 
     365  snprintf(output,sizeof(output)-1,d_RemoveDomainKeyQuery.c_str(), sqlEscape(name).c_str(), id); 
     366 
     367  try { 
     368    d_db->doCommand(output); 
     369  } 
     370  catch (SSqlException &e) { 
     371    throw AhuException("GSQLBackend unable to remove key: "+e.txtReason()); 
     372  } 
     373  return true; 
     374} 
     375 
     376 
    329377 
    330378bool GSQLBackend::getDomainKeys(const string& name, unsigned int kind, std::vector<KeyData>& keys) 
  • trunk/pdns/pdns/backends/gsql/gsqlbackend.hh

    r1790 r1791  
    4848  bool getDomainMetadata(const string& name, const std::string& kind, std::vector<std::string>& meta); 
    4949  bool setDomainMetadata(const string& name, const std::string& kind, const std::vector<std::string>& meta); 
     50   
     51  bool removeDomainKey(const string& name, unsigned int id); 
     52  bool activateDomainKey(const string& name, unsigned int id); 
     53  bool deactivateDomainKey(const string& name, unsigned int id); 
     54   
    5055private: 
    5156  string d_qname; 
     
    8792  string d_ClearDomainMetadataQuery; 
    8893  string d_SetDomainMetadataQuery; 
     94 
     95  string d_RemoveDomainKeyQuery; 
     96  string d_ActivateDomainKeyQuery; 
     97  string d_DeactivateDomainKeyQuery; 
    8998protected:   
    9099  bool d_dnssecQueries; 
  • trunk/pdns/pdns/dbdnsseckeeper.cc

    r1790 r1791  
    8989void DNSSECKeeper::removeKey(const std::string& zname, unsigned int id) 
    9090{ 
    91   // XXX 
     91  UeberBackend db; 
     92  db.removeDomainKey(zname, id); 
    9293} 
    9394 
    9495void DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id) 
    9596{ 
    96   // XX 
     97  UeberBackend db; 
     98  db.deactivateDomainKey(zname, id); 
    9799} 
    98100 
    99101void DNSSECKeeper::activateKey(const std::string& zname, unsigned int id) 
    100102{ 
    101   // XXX 
     103  UeberBackend db; 
     104  db.activateDomainKey(zname, id); 
    102105} 
    103106 
  • trunk/pdns/pdns/pdnssec.cc

    r1788 r1791  
    2424  return arg; 
    2525} 
    26  
    2726 
    2827string humanTime(time_t t) 
     
    257256    const string& zone=cmds[1]; 
    258257    // need to get algorithm & ksk or zsk from commandline 
     258    cerr<<"Adding a ZSK"<<endl; 
    259259    dk.addKey(zone, 1, 5, 0);  
    260     cerr<<"Not implemented"<<endl; 
    261260  } 
    262261  else if(cmds[0] == "remove-zone-key") { 
     
    323322    DNSSECPrivateKey dpk=dk.getKeyById(zone, id); 
    324323    cout << dpk.d_key.convertToISC(dpk.d_algorithm) <<endl; 
    325   } 
     324  }   
    326325  else if(cmds[0]=="import-zone-key") { 
    327     cerr<<"This isn't quite right yet!"<<endl; /// XXX FIXME 
     326    if(cmds.size()!=3) { 
     327      cerr<<"Syntax: pdnssec import-zone-key zone-name filename"<<endl; 
     328      exit(1); 
     329    } 
    328330    string zone=cmds[1]; 
    329331    string fname=cmds[2]; 
  • trunk/pdns/pdns/ueberbackend.cc

    r1781 r1791  
    130130  BOOST_FOREACH(DNSBackend* db, backends) { 
    131131    if(db->setDomainMetadata(name, kind, meta)) 
     132      return true; 
     133  } 
     134  return false; 
     135} 
     136 
     137bool UeberBackend::activateDomainKey(const string& name, unsigned int id) 
     138{ 
     139  BOOST_FOREACH(DNSBackend* db, backends) { 
     140    if(db->activateDomainKey(name, id)) 
     141      return true; 
     142  } 
     143  return false; 
     144} 
     145 
     146bool UeberBackend::deactivateDomainKey(const string& name, unsigned int id) 
     147{ 
     148  BOOST_FOREACH(DNSBackend* db, backends) { 
     149    if(db->deactivateDomainKey(name, id)) 
     150      return true; 
     151  } 
     152  return false; 
     153} 
     154 
     155bool UeberBackend::removeDomainKey(const string& name, unsigned int id) 
     156{ 
     157  BOOST_FOREACH(DNSBackend* db, backends) { 
     158    if(db->removeDomainKey(name, id)) 
    132159      return true; 
    133160  } 
  • trunk/pdns/pdns/ueberbackend.hh

    r1781 r1791  
    128128  bool getDomainMetadata(const string& name, const std::string& kind, std::vector<std::string>& meta); 
    129129  bool setDomainMetadata(const string& name, const std::string& kind, const std::vector<std::string>& meta); 
     130 
     131  bool removeDomainKey(const string& name, unsigned int id); 
     132  bool activateDomainKey(const string& name, unsigned int id); 
     133  bool deactivateDomainKey(const string& name, unsigned int id); 
    130134   
    131135  void alsoNotifies(const string &domain, set<string> *ips);