From ed57a2775e331fabc0a9aa7daaf71e947f95a457 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 12 Nov 2021 16:10:16 +0100 Subject: [PATCH] dnsdist: Only expose SNMP helpers when SNMP is built in --- pdns/dnsdist-lua.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 69dc8efc43..1e7bf17dc2 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -1951,10 +1951,10 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) luaCtx.writeFunction("setTCPInternalPipeBufferSize", [](uint64_t size) { g_tcpInternalPipeBufferSize = size; }); +#ifdef HAVE_NET_SNMP luaCtx.writeFunction("snmpAgent", [client, configCheck](bool enableTraps, boost::optional daemonSocket) { if (client || configCheck) return; -#ifdef HAVE_NET_SNMP if (g_configurationDone) { errlog("snmpAgent() cannot be used at runtime!"); g_outputBuffer = "snmpAgent() cannot be used at runtime!\n"; @@ -1970,10 +1970,6 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) g_snmpEnabled = true; g_snmpTrapsEnabled = enableTraps; g_snmpAgent = new DNSDistSNMPAgent("dnsdist", daemonSocket ? *daemonSocket : std::string()); -#else - errlog("NET SNMP support is required to use snmpAgent()"); - g_outputBuffer = "NET SNMP support is required to use snmpAgent()\n"; -#endif /* HAVE_NET_SNMP */ }); luaCtx.writeFunction("sendCustomTrap", [](const std::string& str) { @@ -1981,6 +1977,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) g_snmpAgent->sendCustomTrap(str); } }); +#endif /* HAVE_NET_SNMP */ luaCtx.writeFunction("setServerPolicy", [](const ServerPolicy& policy) { setLuaSideEffect(); -- 2.47.2