]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Be more straightforward in rec_control for 'hash-password'
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 8 Apr 2021 16:24:21 +0000 (18:24 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 16 Sep 2021 12:12:27 +0000 (14:12 +0200)
pdns/rec_control.cc

index 77bdfe789c8865069aaffbdcb3416d295994300f..6e61171eef1eaa3b5e48b33df4969f393e745650 100644 (file)
@@ -109,7 +109,6 @@ int main(int argc, char** argv)
 
     const vector<string>&commands=arg().getCommands();
     string command;
-    string password;
     int fd = -1;
     unsigned int i = 0;
     while (i < commands.size()) {
@@ -145,7 +144,9 @@ int main(int argc, char** argv)
       else if (commands.at(i) == "hash-password") {
         if (commands.size() > (i + 1)) {
           ++i;
-          password = commands.at(i);
+          auto password = commands.at(i);
+          cout << hashPassword(password) << endl;
+          return 0;
         }
         else {
           throw PDNSException("Command needs a password argument");
@@ -154,11 +155,6 @@ int main(int argc, char** argv)
       ++i;
     }
 
-    if (!password.empty()) {
-      cout << hashPassword(password) << endl;
-      return 0;
-    }
-
     auto timeout = arg().asNum("timeout");
     RecursorControlChannel rccS;
     rccS.connect(arg()["socket-dir"], sockname);