]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdnsutil validate key id when (de)activating
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 9 Nov 2020 18:23:18 +0000 (19:23 +0100)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 9 Nov 2020 18:23:18 +0000 (19:23 +0100)
pdns/pdnsutil.cc

index 020665ae89b18ecedc381e4929504e20d8261b42..55ae03a17b9d52de48b1fd5ee889113704b14047 100644 (file)
@@ -2391,6 +2391,12 @@ try
       cerr<<"Invalid KEY-ID '"<<cmds[2]<<"'"<<endl;
       return 1;
     }
+    try {
+      dk.getKeyById(zone, id);
+    } catch (std::exception& e) {
+      cerr<<e.what()<<endl;
+      return 1;
+    }
     if (!dk.activateKey(zone, id)) {
       cerr<<"Activation of key failed"<<endl;
       return 1;
@@ -2409,6 +2415,12 @@ try
       cerr<<"Invalid KEY-ID"<<endl;
       return 1;
     }
+    try {
+      dk.getKeyById(zone, id);
+    } catch (std::exception& e) {
+      cerr<<e.what()<<endl;
+      return 1;
+    }
     if (!dk.deactivateKey(zone, id)) {
       cerr<<"Deactivation of key failed"<<endl;
       return 1;
@@ -2427,6 +2439,12 @@ try
       cerr<<"Invalid KEY-ID '"<<cmds[2]<<"'"<<endl;
       return 1;
     }
+    try {
+      dk.getKeyById(zone, id);
+    } catch (std::exception& e) {
+      cerr<<e.what()<<endl;
+      return 1;
+    }
     if (!dk.publishKey(zone, id)) {
       cerr<<"Publishing of key failed"<<endl;
       return 1;
@@ -2445,6 +2463,12 @@ try
       cerr<<"Invalid KEY-ID '"<<cmds[2]<<"'"<<endl;
       return 1;
     }
+    try {
+      dk.getKeyById(zone, id);
+    } catch (std::exception& e) {
+      cerr<<e.what()<<endl;
+      return 1;
+    }
     if (!dk.unpublishKey(zone, id)) {
       cerr<<"Unpublishing of key failed"<<endl;
       return 1;