From: Remi Gacogne Date: Fri, 5 Nov 2021 08:52:00 +0000 (+0100) Subject: dnsdist: Do not build the completion and help when DISABLE_COMPLETION is defined X-Git-Tag: auth-4.7.0-alpha1~103^2~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ff9703a0519cf3c7671d3406c05af02511dfdb6;p=thirdparty%2Fpdns.git dnsdist: Do not build the completion and help when DISABLE_COMPLETION is defined A configure option would be better, as we might then also not link against libedit. --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 8c05dd3f99..b7951303f7 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -397,6 +397,8 @@ void doConsole() } } } + +#ifndef DISABLE_COMPLETION /**** CARGO CULT CODE AHEAD ****/ const std::vector 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) { diff --git a/pdns/dnsdist-console.hh b/pdns/dnsdist-console.hh index 5697c8ac8e..1ef046c395 100644 --- a/pdns/dnsdist-console.hh +++ b/pdns/dnsdist-console.hh @@ -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 g_consoleKeywords; +extern "C" { +char** my_completion( const char * text , int start, int end); +} + +#endif /* DISABLE_COMPLETION */ extern GlobalStateHolder g_consoleACL; -extern const std::vector 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(); diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 4793ce3568..26808d4c65 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1811,6 +1811,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) luaCtx.writeFunction("help", [](boost::optional 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"; } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 47a016cc66..896075afea 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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);