From: Remi Gacogne Date: Fri, 12 Nov 2021 15:10:16 +0000 (+0100) Subject: dnsdist: Only expose SNMP helpers when SNMP is built in X-Git-Tag: auth-4.7.0-alpha1~103^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed57a2775e331fabc0a9aa7daaf71e947f95a457;p=thirdparty%2Fpdns.git dnsdist: Only expose SNMP helpers when SNMP is built in --- 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();