return meta=="1";
}
-bool DNSSECKeeper::addKey(const DNSName& name, bool setSEPBit, int algorithm, int bits, bool active)
+int DNSSECKeeper::addKey(const DNSName& name, bool setSEPBit, int algorithm, int bits, bool active)
{
if(!bits) {
if(algorithm <= 10)
}
-bool DNSSECKeeper::addKey(const DNSName& name, const DNSSECPrivateKey& dpk, bool active)
+int DNSSECKeeper::addKey(const DNSName& name, const DNSSECPrivateKey& dpk, bool active)
{
clearCaches(name);
DNSBackend::KeyData kd;
kd.active = active;
kd.content = dpk.getKey()->convertToISC();
// now store it
- return d_keymetadb->addDomainKey(name, kd) >= 0; // >= 0 == s
+ return d_keymetadb->addDomainKey(name, kd);
}
keyset_t getEntryPoints(const DNSName& zname);
keyset_t getKeys(const DNSName& zone, bool useCache = true);
DNSSECPrivateKey getKeyById(const DNSName& zone, unsigned int id);
- bool addKey(const DNSName& zname, bool setSEPBit, int algorithm, int bits=0, bool active=true);
- bool addKey(const DNSName& zname, const DNSSECPrivateKey& dpk, bool active=true);
+ int addKey(const DNSName& zname, bool setSEPBit, int algorithm, int bits=0, bool active=true);
+ int addKey(const DNSName& zname, const DNSSECPrivateKey& dpk, bool active=true);
bool removeKey(const DNSName& zname, unsigned int id);
bool activateKey(const DNSName& zname, unsigned int id);
bool deactivateKey(const DNSName& zname, unsigned int id);
int algo = DNSSECKeeper::shorthand2algorithm(k_algo);
- if(!dk.addKey(zone, true, algo, k_size, true)) {
+ if(dk.addKey(zone, true, algo, k_size, true) < 0) {
cerr<<"No backend was able to secure '"<<zone<<"', most likely because no DNSSEC"<<endl;
cerr<<"capable backends are loaded, or because the backends have DNSSEC disabled."<<endl;
cerr<<"For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or"<<endl;
int algo = DNSSECKeeper::shorthand2algorithm(z_algo);
- if(!dk.addKey(zone, false, algo, z_size, true)) {
+ if(!dk.addKey(zone, false, algo, z_size, true) < 0) {
cerr<<"No backend was able to secure '"<<zone<<"', most likely because no DNSSEC"<<endl;
cerr<<"capable backends are loaded, or because the backends have DNSSEC disabled."<<endl;
cerr<<"For the Generic SQL backends, set the 'gsqlite3-dnssec', 'gmysql-dnssec' or"<<endl;
exit(EXIT_FAILURE);;
}
}
- if(!dk.addKey(zone, keyOrZone, algorithm, bits, active)) {
+ int id;
+ if((id = dk.addKey(zone, keyOrZone, algorithm, bits, active)) < 0) {
cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<<endl;
exit(1);
}
cerr<<"Added a " << (keyOrZone ? "KSK" : "ZSK")<<" with algorithm = "<<algorithm<<", active="<<active<<endl;
if(bits)
cerr<<"Requested specific key size of "<<bits<<" bits"<<endl;
+ cout<<std::to_string(id)<<endl;
}
}
else if(cmds[0] == "remove-zone-key") {
}
else
dpk.d_flags = 257; // ksk
-
- if(!dk.addKey(DNSName(zone), dpk)) {
+
+ int id;
+ if((id = dk.addKey(DNSName(zone), dpk)) < 0) {
cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<<endl;
exit(1);
}
+ cout<<std::to_string(id)<<endl;
}
else if(cmds[0]=="import-zone-key") {
exit(1);
}
}
- if(!dk.addKey(DNSName(zone), dpk, active)) {
+ int id;
+ if((id = dk.addKey(DNSName(zone), dpk, active)) < 0) {
cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<<endl;
exit(1);
}
+ cout<<std::to_string(id)<<endl;
}
else if(cmds[0]=="export-zone-dnskey") {
if(cmds.size() < 3) {