]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
setKey() was actually "appendKey()". In addition, '-k' would not override for server...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 23 Mar 2017 20:39:10 +0000 (21:39 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 23 Mar 2017 20:39:10 +0000 (21:39 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc

index fe0abd01be683d969a43fb96c31dca68f20dae49..7372ec3a85877a45689b9d06dda87083770d0141 100644 (file)
@@ -1462,11 +1462,16 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
     });
   
   g_lua.writeFunction("setKey", [](const std::string& key) {
+      if(!g_configurationDone && ! g_key.empty()) { // this makes sure the commandline -k key prevails over dnsdist.conf
+        return;                                     // but later setKeys() trump the -k value again
+      }
+
       setLuaSideEffect();
+      g_key.clear();
       if(B64Decode(key, g_key) < 0) {
-         g_outputBuffer=string("Unable to decode ")+key+" as Base64";
-         errlog("%s", g_outputBuffer);
-       }
+        g_outputBuffer=string("Unable to decode ")+key+" as Base64";
+        errlog("%s", g_outputBuffer);
+      }
     });
 
   
index 9e10eea9048dadf9082e7a92251df600c50ddac3..cb77c3e2c121b77b28783c24cd20781b39ebf1e8 100644 (file)
@@ -1670,9 +1670,6 @@ struct
   string pidfile;
   string command;
   string config;
-#ifdef HAVE_LIBSODIUM
-  string setKey;
-#endif
   string uid;
   string gid;
 } g_cmdLine;
@@ -1804,7 +1801,7 @@ try
       break;
 #ifdef HAVE_LIBSODIUM
     case 'k':
-      if (B64Decode(string(optarg), g_cmdLine.setKey) < 0) {
+      if (B64Decode(string(optarg), g_key) < 0) {
         cerr<<"Unable to decode key '"<<optarg<<"'."<<endl;
         exit(EXIT_FAILURE);
       }
@@ -1870,10 +1867,6 @@ try
     setupLua(true, g_cmdLine.config);
     if (clientAddress != ComboAddress())
       g_serverControl = clientAddress;
-#ifdef HAVE_LIBSODIUM
-    if (!g_cmdLine.setKey.empty())
-      g_key = g_cmdLine.setKey;
-#endif
     doClient(g_serverControl, g_cmdLine.command);
     _exit(EXIT_SUCCESS);
   }