return ret;
}
-static void loadModules()
-{
- if(!::arg()["load-modules"].empty()) {
- vector<string>modules;
-
- stringtok(modules,::arg()["load-modules"],", ");
-
- for(vector<string>::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<<Logger::Error<<"Receiver unable to load module "<<module<<endl;
- exit(1);
- }
- }
- }
-}
-
void loadMainConfig(const std::string& configdir)
{
::arg().set("config-dir","Location of configuration directory (pdns.conf)")=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();
+ if(!::arg()["load-modules"].empty()) {
+ vector<string> modules;
+
+ stringtok(modules,::arg()["load-modules"], ", ");
+ if (!UeberBackend::loadModules(modules, ::arg()["module-dir"])) {
+ exit(1);
+ }
+ }
g_log.toConsole(Logger::Error); // so we print any errors
BackendMakers().launch(::arg()["launch"]); // vrooooom!
::arg().set("daemon","Operate as a daemon")="no";
}
-static void loadModules()
-{
- if(!::arg()["load-modules"].empty()) {
- vector<string>modules;
-
- stringtok(modules,::arg()["load-modules"],", ");
-
- for(vector<string>::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<<Logger::Error<<"Receiver unable to load module "<<module<<endl;
- exit(1);
- }
- }
- }
-}
-
#ifdef __GLIBC__
#include <execinfo.h>
static void tbhandler(int num)
/* setup rng */
dns_random_init();
- loadModules();
+ if(!::arg()["load-modules"].empty()) {
+ vector<string> modules;
+
+ stringtok(modules,::arg()["load-modules"], ", ");
+ if (!UeberBackend::loadModules(modules, ::arg()["module-dir"])) {
+ exit(1);
+ }
+ }
+
BackendMakers().launch(::arg()["launch"]); // vrooooom!
if(!::arg().getCommands().empty()) {
return true;
}
+bool UeberBackend::loadModules(const vector<string>& modules, const string& path)
+{
+ for (const auto& module: modules) {
+ bool res;
+ if (module.find(".")==string::npos) {
+ res = UeberBackend::loadmodule(path+"/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(path+"/"+module);
+ }
+
+ if (res == false) {
+ return false;
+ }
+ }
+ return true;
+}
+
void UeberBackend::go(void)
{
pthread_mutex_lock(&d_mut);
static pthread_mutex_t instances_lock;
static bool loadmodule(const string &name);
+ static bool loadModules(const vector<string>& modules, const string& path);
static void go(void);