]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #15080 from miodvallat/import_with_care
authorMiod Vallat <miod.vallat@open-xchange.com>
Thu, 13 Feb 2025 09:41:08 +0000 (10:41 +0100)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 09:41:08 +0000 (10:41 +0100)
pdnsutil: check for key presence after import

1  2 
pdns/pdnsutil.cc

index d3b1700bcd853d8217570f7e385724a1f6ba2865,ca0f1c8958592566dcddc425a96574b8c1dbcc98..3a35755fd0518e06114d5719895928121a9b34ab
@@@ -2922,9 -2899,29 +2922,29 @@@ static int unpublishZoneKey(vector<stri
    return 0;
  }
  
+ static int checkZoneKey(DNSSECKeeper &dsk, DNSName &zone, int64_t keyId)
+ {
+   if (keyId == -1) {
+     cerr<<std::to_string(keyId)<<": Key was added, but backend does not support returning of key id"<<endl;
+     return 0;
+   }
+   if (keyId < -1) {
+     cerr<<std::to_string(keyId)<<": Key was added, but there was a failure while returning the key id"<<endl;
+     return 1;
+   }
+   try {
+     dsk.getKeyById(zone, keyId);
+     cout<<std::to_string(keyId)<<endl;
+   } catch (std::exception& exc) {
+     cerr<<std::to_string(keyId)<<": Key was added, but there was a failure while reading it back: " <<exc.what()<<endl;
+     return 1;
+   }
+   return 0;
+ }
  static int addZoneKey(vector<string>& cmds)
  {
 -  if(cmds.size() < 3 ) {
 +  if(cmds.size() < 2 ) {
      cerr << "Syntax: pdnsutil add-zone-key ZONE [zsk|ksk] [BITS] [active|inactive] [rsasha1|rsasha1-nsec3-sha1|rsasha256|rsasha512|ecdsa256|ecdsa384";
  #if defined(HAVE_LIBSODIUM) || defined(HAVE_LIBCRYPTO_ED25519)
      cerr << "|ed25519";