]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not build the completion and help when DISABLE_COMPLETION is defined
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 Nov 2021 08:52:00 +0000 (09:52 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 22 Dec 2021 08:30:43 +0000 (09:30 +0100)
A configure option would be better, as we might then also not link
against libedit.

pdns/dnsdist-console.cc
pdns/dnsdist-console.hh
pdns/dnsdist-lua.cc
pdns/dnsdist.cc

index 8c05dd3f99cb32de20fff048abd48d282da0e718..b7951303f72cab49aa7525d0a15bbcbf6f6fe0e7 100644 (file)
@@ -397,6 +397,8 @@ void doConsole()
     }
   }
 }
+
+#ifndef DISABLE_COMPLETION
 /**** CARGO CULT CODE AHEAD ****/
 const std::vector<ConsoleKeyword> g_consoleKeywords{
   /* keyword, function, parameters, description */
@@ -755,6 +757,7 @@ char** my_completion( const char * text , int start,  int end)
   return matches;
 }
 }
+#endif /* DISABLE_COMPLETION */
 
 static void controlClientThread(ConsoleConnection&& conn)
 {
index 5697c8ac8e3d31f7ee88936b58c9a2693a7f1479..1ef046c395f5569a19243f6ad95069c4fb616fab 100644 (file)
@@ -21,6 +21,9 @@
  */
 #pragma once
 
+#include "config.h"
+
+#ifndef DISABLE_COMPLETION
 struct ConsoleKeyword {
   std::string name;
   bool function;
@@ -37,9 +40,14 @@ struct ConsoleKeyword {
     return res;
   }
 };
+extern const std::vector<ConsoleKeyword> g_consoleKeywords;
+extern "C" {
+char** my_completion( const char * text , int start,  int end);
+}
+
+#endif /* DISABLE_COMPLETION */
 
 extern GlobalStateHolder<NetmaskGroup> g_consoleACL;
-extern const std::vector<ConsoleKeyword> g_consoleKeywords;
 extern std::string g_consoleKey; // in theory needs locking
 extern bool g_logConsoleConnections;
 extern bool g_consoleEnabled;
@@ -47,9 +55,6 @@ extern uint32_t g_consoleOutputMsgMaxSize;
 
 void doClient(ComboAddress server, const std::string& command);
 void doConsole();
-extern "C" {
-char** my_completion( const char * text , int start,  int end);
-}
 void controlThread(int fd, ComboAddress local);
 void clearConsoleHistory();
 
index 4793ce3568b58dc81a6cf3742fee3129221c6da6..26808d4c65dd4a0876c9f6a929ec99a80008a6dd 100644 (file)
@@ -1811,6 +1811,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
   luaCtx.writeFunction("help", [](boost::optional<std::string> command) {
     setLuaNoSideEffect();
     g_outputBuffer = "";
+#ifndef DISABLE_COMPLETION
     for (const auto& keyword : g_consoleKeywords) {
       if (!command) {
         g_outputBuffer += keyword.toString() + "\n";
@@ -1820,6 +1821,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         return;
       }
     }
+#endif /* DISABLE_COMPLETION */
     if (command) {
       g_outputBuffer = "Nothing found for " + *command + "\n";
     }
index 47a016cc66b41e63fd642681c7b6e3100d708b7e..896075afea4b5c55aae2e47a6489a3a2f5a7b1a9 100644 (file)
@@ -2237,8 +2237,10 @@ int main(int argc, char** argv)
   try {
     size_t udpBindsCount = 0;
     size_t tcpBindsCount = 0;
+#ifndef DISABLE_COMPLETION
     rl_attempted_completion_function = my_completion;
     rl_completion_append_character = 0;
+#endif /* DISABLE_COMPLETION */
 
     signal(SIGPIPE, SIG_IGN);
     signal(SIGCHLD, SIG_IGN);