From c524989b390462e1a3b5f8dfa39597aad0f303a8 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Thu, 10 May 2018 12:31:39 +0200 Subject: [PATCH] pdnsutil: also load modules through the load-modules directive --- pdns/pdnsutil.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 59f5955b0a..d617105403 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -58,6 +58,32 @@ string humanTime(time_t t) return ret; } +static void loadModules() +{ + if(!::arg()["load-modules"].empty()) { + vectormodules; + + stringtok(modules,::arg()["load-modules"],", "); + + for(vector::const_iterator i=modules.begin();i!=modules.end();++i) { + bool res; + const string &module=*i; + + if(module.find(".")==string::npos) + res=UeberBackend::loadmodule(::arg()["module-dir"]+"/lib"+module+"backend.so"); + else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path + res=UeberBackend::loadmodule(module); + else + res=UeberBackend::loadmodule(::arg()["module-dir"]+"/"+module); + + if(res==false) { + g_log<(); ::arg().setCmd("help","Provide a helpful message"); + ::arg().set("load-modules","Load this module - supply absolute or relative path")=""; //::arg().laxParse(argc,argv); if(::arg().mustDo("help")) { @@ -98,6 +125,8 @@ void loadMainConfig(const std::string& configdir) ::arg().set("rng", "Specify random number generator to use. Valid values are auto,sodium,openssl,getrandom,arc4random,urandom.")="auto"; ::arg().laxFile(configname.c_str()); + loadModules(); + g_log.toConsole(Logger::Error); // so we print any errors BackendMakers().launch(::arg()["launch"]); // vrooooom! if(::arg().asNum("loglevel") >= 3) // so you can't kill our errors -- 2.47.2