}
-void DNSSECKeeper::removeKey(const std::string& zname, unsigned int id)
+bool DNSSECKeeper::removeKey(const std::string& zname, unsigned int id)
{
clearCaches(zname);
- d_keymetadb->removeDomainKey(zname, id);
+ return d_keymetadb->removeDomainKey(zname, id);
}
-void DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id)
+bool DNSSECKeeper::deactivateKey(const std::string& zname, unsigned int id)
{
clearCaches(zname);
- d_keymetadb->deactivateDomainKey(zname, id);
+ return d_keymetadb->deactivateDomainKey(zname, id);
}
-void DNSSECKeeper::activateKey(const std::string& zname, unsigned int id)
+bool DNSSECKeeper::activateKey(const std::string& zname, unsigned int id)
{
clearCaches(zname);
- d_keymetadb->activateDomainKey(zname, id);
+ return d_keymetadb->activateDomainKey(zname, id);
}
return true;
}
-void DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow)
+bool DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow)
{
clearCaches(zname);
string descr = ns3p.getZoneRepresentation();
vector<string> meta;
meta.push_back(descr);
- d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", meta);
-
- meta.clear();
- if(narrow)
- meta.push_back("1");
- d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", meta);
+ if (d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", meta)) {
+ meta.clear();
+
+ if(narrow)
+ meta.push_back("1");
+
+ return d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", meta);
+ }
+ return false;
}
-void DNSSECKeeper::unsetNSEC3PARAM(const std::string& zname)
+bool DNSSECKeeper::unsetNSEC3PARAM(const std::string& zname)
{
clearCaches(zname);
- d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", vector<string>());
- d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", vector<string>());
+ return (d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", vector<string>()) && d_keymetadb->setDomainMetadata(zname, "NSEC3NARROW", vector<string>()));
}
-void DNSSECKeeper::setPresigned(const std::string& zname)
+bool DNSSECKeeper::setPresigned(const std::string& zname)
{
clearCaches(zname);
vector<string> meta;
meta.push_back("1");
- d_keymetadb->setDomainMetadata(zname, "PRESIGNED", meta);
+ return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", meta);
}
-void DNSSECKeeper::unsetPresigned(const std::string& zname)
+bool DNSSECKeeper::unsetPresigned(const std::string& zname)
{
clearCaches(zname);
- d_keymetadb->setDomainMetadata(zname, "PRESIGNED", vector<string>());
+ return d_keymetadb->setDomainMetadata(zname, "PRESIGNED", vector<string>());
}
DNSSECPrivateKey getKeyById(const std::string& zone, unsigned int id);
bool addKey(const std::string& zname, bool keyOrZone, int algorithm=5, int bits=0, bool active=true);
bool addKey(const std::string& zname, const DNSSECPrivateKey& dpk, bool active=true);
- void removeKey(const std::string& zname, unsigned int id);
- void activateKey(const std::string& zname, unsigned int id);
- void deactivateKey(const std::string& zname, unsigned int id);
+ bool removeKey(const std::string& zname, unsigned int id);
+ bool activateKey(const std::string& zname, unsigned int id);
+ bool deactivateKey(const std::string& zname, unsigned int id);
bool secureZone(const std::string& fname, int algorithm);
bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* n3p=0, bool* narrow=0);
- void setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false);
- void unsetNSEC3PARAM(const std::string& zname);
+ bool setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false);
+ bool unsetNSEC3PARAM(const std::string& zname);
void clearAllCaches();
void clearCaches(const std::string& name);
bool getPreRRSIGs(DNSBackend& db, const std::string& signer, const std::string& qname, const std::string& wildcardname, const QType& qtype, DNSPacketWriter::Place, vector<DNSResourceRecord>& rrsigs, uint32_t signTTL);
bool isPresigned(const std::string& zname);
- void setPresigned(const std::string& zname);
- void unsetPresigned(const std::string& zname);
+ bool setPresigned(const std::string& zname);
+ bool unsetPresigned(const std::string& zname);
bool TSIGGrantsAccess(const string& zone, const string& keyname, const string& algorithm);
bool getTSIGForAccess(const string& zone, const string& master, string* keyname);
cerr<<"Invalid KEY-ID"<<endl;
return 1;
}
- dk.activateKey(zone, id);
+ if (!dk.activateKey(zone, id)) {
+ cerr<<"Activation of key failed"<<endl;
+ return 1;
+ }
+ return 0;
}
else if(cmds[0] == "deactivate-zone-key") {
if(cmds.size() != 3) {
cerr<<"Invalid KEY-ID"<<endl;
return 1;
}
- dk.deactivateKey(zone, id);
+ if (!dk.deactivateKey(zone, id)) {
+ cerr<<"Deactivation of key failed"<<endl;
+ return 1;
+ }
+ return 0;
}
else if(cmds[0] == "add-zone-key") {
if(cmds.size() < 3 ) {
}
const string& zone=cmds[1];
unsigned int id=atoi(cmds[2].c_str());
- dk.removeKey(zone, id);
+ if (!dk.removeKey(zone, id)) {
+ return 1;
+ }
+ return 0;
}
else if(cmds[0] == "secure-zone") {
cerr<<"Syntax: pdnssec set-presigned ZONE"<<endl;
return 0;
}
- dk.setPresigned(cmds[1]);
+ if (! dk.setPresigned(cmds[1])) {
+ return 1;
+ }
+ return 0;
}
else if(cmds[0]=="unset-presigned") {
if(cmds.size() < 2) {
cerr<<"Syntax: pdnssec unset-presigned ZONE"<<endl;
return 0;
}
- dk.unsetPresigned(cmds[1]);
+ if (! dk.unsetPresigned(cmds[1])) {
+ return 1;
+ }
+ return 0;
}
else if(cmds[0]=="hash-zone-record") {
if(cmds.size() < 3) {
else if(cmds[0]=="unset-nsec3") {
if(cmds.size() < 2) {
cerr<<"Syntax: pdnssec unset-nsec3 ZONE"<<endl;
- exit(1);
+ return 0;
}
- dk.unsetNSEC3PARAM(cmds[1]);
+ if ( ! dk.unsetNSEC3PARAM(cmds[1])) {
+ return 1;
+ }
+ return 0;
}
else if(cmds[0]=="export-zone-key") {
if(cmds.size() < 3) {
cerr<<"Syntax: pdnssec export-zone-key ZONE KEY-ID"<<endl;
- exit(1);
+ return 0;
}
string zone=cmds[1];