summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Common/ModuleManager.cpp16
-rw-r--r--src/Common/ModuleManager.h2
-rw-r--r--src/Common/UserManager.cpp81
-rw-r--r--src/Common/UserManager.h2
-rw-r--r--src/Core/ConfigEntry.cpp94
-rw-r--r--src/Core/ConfigEntry.h75
-rw-r--r--src/Core/ConfigManager.cpp40
-rw-r--r--src/Core/ConfigManager.h13
-rw-r--r--src/Core/Configurable.h4
-rw-r--r--src/Core/LogManager.cpp68
-rw-r--r--src/Core/LogManager.h3
-rw-r--r--src/Server/ConnectionManager.cpp32
-rw-r--r--src/Server/ConnectionManager.h4
-rw-r--r--src/Server/UserListManager.cpp2
-rw-r--r--src/Server/UserListManager.h2
-rw-r--r--src/mad-server.cpp2
-rw-r--r--src/madc.cpp2
-rw-r--r--src/madd.cpp2
-rw-r--r--src/modules/AuthProviderFile/AuthProviderFile.cpp34
-rw-r--r--src/modules/AuthProviderFile/AuthProviderFile.h3
-rw-r--r--src/modules/FileLogger/Module.cpp57
-rw-r--r--src/modules/FileLogger/Module.h4
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.cpp21
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.h3
-rw-r--r--src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp42
-rw-r--r--src/modules/UserConfigBackendHome/UserConfigBackendHome.h4
-rw-r--r--src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp43
-rw-r--r--src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h3
-rw-r--r--src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp146
-rw-r--r--src/modules/UserDBBackendMysql/UserDBBackendMysql.h5
30 files changed, 307 insertions, 502 deletions
diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index be25f9e..c119eab 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -58,18 +58,12 @@ ModuleManager::~ModuleManager() {
}
}
-bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
- if(handled)
- return false;
-
- if(entry[0].getKey().matches("LoadModule") && entry[1].isEmpty()) {
- if(!loadModule(entry[0][0].toLocale()))
- application->logf(Core::Logger::LOG_ERROR, "Can't load module '%s'.", entry[0][0].toLocale().c_str());
-
- return true;
+void ModuleManager::configure() {
+ std::vector<const Core::ConfigEntry*> entries = application->getConfigManager()->getEntries("LoadModule");
+ for(std::vector<const Core::ConfigEntry*>::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
+ if(!loadModule((*entry)->getValue().toLocale()))
+ application->logf(Core::Logger::LOG_ERROR, "Can't load module '%s'.", (*entry)->getValue().toLocale().c_str());
}
-
- return false;
}
bool ModuleManager::loadModule(const std::string &name) {
diff --git a/src/Common/ModuleManager.h b/src/Common/ModuleManager.h
index 1c6a195..dbb35cd 100644
--- a/src/Common/ModuleManager.h
+++ b/src/Common/ModuleManager.h
@@ -68,7 +68,7 @@ class MAD_COMMON_EXPORT ModuleManager : public Core::Configurable, private boost
void unloadModule(const std::string &name);
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
+ virtual void configure();
public:
bool loadModule(const std::string &name);
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index 90a0435..e71c38e 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -28,7 +28,7 @@
namespace Mad {
namespace Common {
-UserManager::UserManager(Application *application0) : application(application0), minUid(1000), maxUid(29999), minGid(1000), maxGid(29999) {
+UserManager::UserManager(Application *application0) : application(application0) {
application->getConfigManager()->registerConfigurable(this);
}
@@ -36,63 +36,34 @@ UserManager::~UserManager() {
application->getConfigManager()->unregisterConfigurable(this);
}
-bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(entry[0].getKey().matches("UserManager")) {
- if(entry[1].getKey().matches("MinUid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- minUid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MaxUid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- maxUid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MinGid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- minGid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MaxGid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- maxGid = val;
- }
- }
- }
- else if(!entry[1].isEmpty())
- return false;
+void UserManager::configure() {
+ minUid = std::strtoul(application->getConfigManager()->get("UserManager.MinUid", "1000").toString().c_str(), 0, 10);
+ if(minUid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'",
+ application->getConfigManager()->get("UserManager.MinUid").toLocale().c_str());
+ minUid = 1000;
+ }
+
+ maxUid = std::strtoul(application->getConfigManager()->get("UserManager.MaxUid", "29999").toString().c_str(), 0, 10);
+ if(maxUid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'",
+ application->getConfigManager()->get("UserManager.MaxUid").toLocale().c_str());
+ maxUid = 29999;
+ }
- return true;
+ minGid = std::strtoul(application->getConfigManager()->get("UserManager.MinGid", "1000").toString().c_str(), 0, 10);
+ if(minGid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'",
+ application->getConfigManager()->get("UserManager.MinGid").toLocale().c_str());
+ minGid = 1000;
}
- return false;
+ maxGid = std::strtoul(application->getConfigManager()->get("UserManager.MaxGid", "29999").toString().c_str(), 0, 10);
+ if(maxGid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'",
+ application->getConfigManager()->get("UserManager.MaxGid").toLocale().c_str());
+ maxGid = 29999;
+ }
}
void UserManager::registerBackend(boost::shared_ptr<UserDBBackend> backend) {
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h
index 0cf7fca..4319713 100644
--- a/src/Common/UserManager.h
+++ b/src/Common/UserManager.h
@@ -65,7 +65,7 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost::
~UserManager();
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/);
+ virtual void configure();
public:
void registerBackend(boost::shared_ptr<UserDBBackend> backend);
diff --git a/src/Core/ConfigEntry.cpp b/src/Core/ConfigEntry.cpp
index 04ed08f..ec716b6 100644
--- a/src/Core/ConfigEntry.cpp
+++ b/src/Core/ConfigEntry.cpp
@@ -22,43 +22,85 @@
namespace Mad {
namespace Core {
-String& ConfigEntry::Entry::operator[] (std::size_t i) {
- try {
- return value.at(i);
- }
- catch(std::out_of_range &e) {
- zero = String();
- return zero;
- }
+void ConfigEntry::addChild(const String &key, boost::shared_ptr<ConfigEntry> entry) {
+ String lowerKey(key);
+ lowerKey.toLower();
+
+ EntryMap::iterator child = children.find(lowerKey);
+
+ if(child == children.end())
+ child = children.insert(std::make_pair(lowerKey, EntryVector())).first;
+
+ child->second.push_back(entry);
}
-const String& ConfigEntry::Entry::operator[] (std::size_t i) const {
- try {
- return value.at(i);
- }
- catch(std::out_of_range &e) {
- return constZero;
+const ConfigEntry* ConfigEntry::getEntry(const String &key) const {
+ String childKey(key);
+ childKey.toLower();
+
+ int32_t dotIndex = key.indexOf('.');
+ if(dotIndex >= 0) {
+ childKey.remove(dotIndex);
}
-}
-ConfigEntry::Entry& ConfigEntry::operator[] (std::size_t i) {
- try {
- return entries.at(i);
+ EntryMap::const_iterator child = children.find(childKey);
+ if(child == children.end()) {
+ return 0;
}
- catch(std::out_of_range &e) {
- zero = Entry();
- return zero;
+ else {
+ if(dotIndex >= 0) {
+ return child->second.back()->getEntry(key.substr(dotIndex+1));
+ }
+ else {
+ return child->second.back().get();
+ }
}
}
-const ConfigEntry::Entry& ConfigEntry::operator[] (std::size_t i) const {
- try {
- return entries.at(i);
+std::vector<const ConfigEntry*> ConfigEntry::getEntries(const String &key) const {
+ String childKey(key);
+ childKey.toLower();
+
+ int32_t dotIndex = key.indexOf('.');
+ if(dotIndex >= 0) {
+ childKey.remove(dotIndex);
}
- catch(std::out_of_range &e) {
- return constZero;
+
+ EntryMap::const_iterator child = children.find(childKey);
+ if(child == children.end()) {
+ return std::vector<const ConfigEntry*>();
+ }
+ else {
+ if(dotIndex >= 0) {
+ return child->second.back()->getEntries(key.substr(dotIndex+1));
+ }
+ else {
+ std::vector<const ConfigEntry*> ret;
+
+ for(EntryVector::const_iterator entry = child->second.begin(); entry != child->second.end(); ++entry) {
+ ret.push_back(entry->get());
+ }
+
+ return ret;
+ }
}
}
+std::vector<String> ConfigEntry::getAll(const String &key) const {
+ const ConfigEntry *entry = getEntry(key);
+ if(!entry)
+ return std::vector<String>();
+ else
+ return entry->getValues();
+}
+
+String ConfigEntry::get(const String &key, const String &defaultValue) const {
+ const ConfigEntry *entry = getEntry(key);
+ if(!entry)
+ return defaultValue;
+ else
+ return entry->getValue(defaultValue);
+}
+
}
}
diff --git a/src/Core/ConfigEntry.h b/src/Core/ConfigEntry.h
index 26e77d2..1724267 100644
--- a/src/Core/ConfigEntry.h
+++ b/src/Core/ConfigEntry.h
@@ -23,63 +23,60 @@
#include "export.h"
#include "String.h"
-
-#include <stdexcept>
+#include <map>
#include <vector>
+#include <boost/shared_ptr.hpp>
namespace Mad {
namespace Core {
-class MAD_CORE_EXPORT ConfigEntry {
- public:
- class MAD_CORE_EXPORT Entry {
- private:
- String key;
- std::vector<String> value;
-
- String zero, constZero;
+class ConfigManager;
- public:
- Entry() {}
- Entry(const std::vector<String> &args) {
- if(args.empty())
- return;
-
- key = args.front();
+class MAD_CORE_EXPORT ConfigEntry {
+ private:
+ friend class ConfigManager;
- value.assign(args.begin()+1, args.end());
- }
+ typedef std::vector<boost::shared_ptr<ConfigEntry> > EntryVector;
+ typedef std::map<String, EntryVector> EntryMap;
- bool isEmpty() const {
- return key.isEmpty();
- }
+ ConfigEntry *parent;
- String &getKey() {return key;}
- const String &getKey() const {return key;}
+ std::vector<String> values;
+ EntryMap children;
- std::size_t getSize() const {return value.size();}
+ protected:
+ ConfigEntry() : parent(0) {}
- String& operator[] (std::size_t i);
- const String& operator[] (std::size_t i) const;
- };
+ public:
+ ConfigEntry(ConfigEntry *parent0, const std::vector<String> &values0)
+ : parent(parent0), values(values0) {}
- private:
- std::vector<Entry> entries;
- Entry zero, constZero;
+ void addChild(const String &key, boost::shared_ptr<ConfigEntry> entry);
- public:
- std::size_t getSize() const {return entries.size();}
+ const ConfigEntry* getParent() const {
+ return parent;
+ }
- Entry& operator[] (std::size_t i);
- const Entry& operator[] (std::size_t i) const;
+ ConfigEntry* getParent() {
+ return parent;
+ }
- void push(const Entry &entry) {
- entries.push_back(entry);
+ const std::vector<String>& getValues() const {
+ return values;
}
- void pop() {
- entries.pop_back();
+ String getValue(const String &defaultValue = String()) const {
+ if(values.empty())
+ return defaultValue;
+ else
+ return values.front();
}
+
+ const ConfigEntry* getEntry(const String &key) const;
+ std::vector<const ConfigEntry*> getEntries(const String &key) const;
+
+ std::vector<String> getAll(const String &key) const;
+ String get(const String &key, const String &defaultValue = String()) const;
};
}
diff --git a/src/Core/ConfigManager.cpp b/src/Core/ConfigManager.cpp
index fdbc93f..1cb4aa0 100644
--- a/src/Core/ConfigManager.cpp
+++ b/src/Core/ConfigManager.cpp
@@ -38,28 +38,16 @@ bool ConfigManager::Compare::operator() (const Configurable *c1, const Configura
return c1 < c2;
}
-
-void ConfigManager::handleConfigEntry(const ConfigEntry &entry) {
- bool handled = false;
-
- for(std::set<Configurable*, Compare>::iterator c = configurables.begin(); c != configurables.end(); ++c) {
- if((*c)->handleConfigEntry(entry, handled))
- handled = true;
- }
-
- if(!handled)
- application->logf(Logger::LOG_WARNING, "Invalid config option '%s'.", entry[entry.getSize()-1].getKey().toLocale().c_str());
-}
-
bool ConfigManager::loadFile(const std::string &filename) {
- if(finished)
+ if(configured)
return false;
std::ifstream file(filename.c_str());
- ConfigEntry entry;
+ ConfigEntry *currentEntry = this;
+ ConfigEntry *lastEntry = this;
String line, input;
UChar delim;
- std::vector<String> splitLine, lastConfigLine;
+ std::vector<String> splitLine;
if(!file.good())
return false;
@@ -90,11 +78,9 @@ bool ConfigManager::loadFile(const std::string &filename) {
}
if(!splitLine.empty()) {
- entry.push(splitLine);
- handleConfigEntry(entry);
- entry.pop();
-
- lastConfigLine = splitLine;
+ boost::shared_ptr<ConfigEntry> entry(new ConfigEntry(currentEntry, std::vector<String>(splitLine.begin()+1, splitLine.end())));
+ currentEntry->addChild(splitLine.front(), entry);
+ lastEntry = entry.get();
}
switch(delim) {
@@ -102,10 +88,10 @@ bool ConfigManager::loadFile(const std::string &filename) {
input.remove();
break;
case '{':
- entry.push(lastConfigLine);
+ currentEntry = lastEntry;
break;
case '}':
- entry.pop();
+ lastEntry = currentEntry = currentEntry->getParent();
}
line.remove();
@@ -116,14 +102,14 @@ bool ConfigManager::loadFile(const std::string &filename) {
return true;
}
-void ConfigManager::finish() {
- if(finished)
+void ConfigManager::configure() {
+ if(configured)
return;
for(std::set<Configurable*, Compare>::iterator c = configurables.begin(); c != configurables.end(); ++c)
- (*c)->configFinished();
+ (*c)->configure();
- finished = true;
+ configured = true;
}
}
diff --git a/src/Core/ConfigManager.h b/src/Core/ConfigManager.h
index 10b378d..2c11de9 100644
--- a/src/Core/ConfigManager.h
+++ b/src/Core/ConfigManager.h
@@ -22,6 +22,8 @@
#include "export.h"
+#include "ConfigEntry.h"
+
#include <memory>
#include <set>
#include <string>
@@ -30,10 +32,9 @@ namespace Mad {
namespace Core {
class Application;
-class ConfigEntry;
class Configurable;
-class MAD_CORE_EXPORT ConfigManager {
+class MAD_CORE_EXPORT ConfigManager : public ConfigEntry {
private:
struct MAD_CORE_EXPORT Compare {
bool operator() (const Configurable *c1, const Configurable *c2);
@@ -44,15 +45,13 @@ class MAD_CORE_EXPORT ConfigManager {
Application *application;
std::set<Configurable*, Compare> configurables;
- bool finished;
-
- ConfigManager(Application *application0) : application(application0), finished(false) {}
+ bool configured;
- void handleConfigEntry(const ConfigEntry &entry);
+ ConfigManager(Application *application0) : application(application0), configured(false) {}
public:
bool loadFile(const std::string &filename);
- void finish();
+ void configure();
void registerConfigurable(Configurable *c) {
configurables.insert(c);
diff --git a/src/Core/Configurable.h b/src/Core/Configurable.h
index c526379..1c41220 100644
--- a/src/Core/Configurable.h
+++ b/src/Core/Configurable.h
@@ -23,7 +23,6 @@
namespace Mad {
namespace Core {
-class ConfigEntry;
class ConfigManager;
class Configurable {
@@ -37,8 +36,7 @@ class Configurable {
Configurable() {}
- virtual bool handleConfigEntry(const ConfigEntry& /*entry*/, bool /*handled*/) {return false;}
- virtual void configFinished() {}
+ virtual void configure() = 0;
};
}
diff --git a/src/Core/LogManager.cpp b/src/Core/LogManager.cpp
index 7282009..955ac76 100644
--- a/src/Core/LogManager.cpp
+++ b/src/Core/LogManager.cpp
@@ -53,17 +53,17 @@ LogManager::MessageLevel LogManager::parseLevel(const String &str) throw (Except
if(str.isEmpty())
return Logger::LOG_DEFAULT;
- if(str.caseCompare(DEBUG_LEVEL, 0) == 0)
+ if(str.matches(DEBUG_LEVEL))
return Logger::LOG_DEBUG;
- else if(str.caseCompare(VERBOSE_LEVEL, 0) == 0)
+ else if(str.matches(VERBOSE_LEVEL))
return Logger::LOG_VERBOSE;
- else if(str.caseCompare(DEFAULT_LEVEL, 0) == 0)
+ else if(str.matches(DEFAULT_LEVEL))
return Logger::LOG_DEFAULT;
- else if(str.caseCompare(WARNING_LEVEL, 0) == 0)
+ else if(str.matches(WARNING_LEVEL))
return Logger::LOG_WARNING;
- else if(str.caseCompare(ERROR_LEVEL, 0) == 0)
+ else if(str.matches(ERROR_LEVEL))
return Logger::LOG_ERROR;
- else if(str.caseCompare(CRITICAL_LEVEL, 0) == 0)
+ else if(str.matches(CRITICAL_LEVEL))
return Logger::LOG_CRITICAL;
else
throw Exception(Exception::INVALID_INPUT);
@@ -79,41 +79,37 @@ LogManager::~LogManager() {
}
-bool LogManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
- if(entry[0].getKey().matches("Log")) {
- if(entry[0][0].matches("Console")) {
- if(entry[1].isEmpty()) {
- registerLogger(consoleLogger);
- return true;
- }
- else if(entry[1].getKey().matches("Level")) {
- if(entry[2].isEmpty()) {
- try {
- if(entry[1][0].matches("remote"))
- consoleLogger->setRemoteLevel(parseLevel(entry[1][1]));
- else
- consoleLogger->setLevel(parseLevel(entry[1][0]));
- }
- catch(Core::Exception e) {
- application->logf(Logger::LOG_WARNING, "Unknown log level '%s'.", entry[1][0].toLocale().c_str());
- }
-
- return true;
- }
- }
+void LogManager::configure() {
+ std::vector<const ConfigEntry*> entries = application->getConfigManager()->getEntries("Log");
+
+ for(std::vector<const ConfigEntry*>::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
+ const std::vector<String> &values = (*entry)->getValues();
+
+ if(values.empty() || !values.front().matches("Console"))
+ continue;
+
+ registerLogger(consoleLogger);
+
+ bool remote = false;
+ for(std::vector<String>::const_iterator value = values.begin()+1; value != values.end(); ++value) {
+ if(value->matches("remote"))
+ remote = true;
}
- else if(entry[1].isEmpty()) {
- if(!handled) {
- application->logf(Logger::LOG_WARNING, "Unknown logger '%s'.", entry[0][0].toLocale().c_str());
- return true;
+
+ String level = (*entry)->get("Level");
+ if(!level.isEmpty()) {
+ try {
+ if(remote)
+ consoleLogger->setRemoteLevel(parseLevel(level));
+ else
+ consoleLogger->setLevel(parseLevel(level));
+ }
+ catch(Core::Exception e) {
+ application->logf(Logger::LOG_WARNING, "Unknown log level '%s'.", level.toLocale().c_str());
}
}
}
- return false;
-}
-
-void LogManager::configFinished() {
if(loggers.empty())
registerLogger(consoleLogger);
diff --git a/src/Core/LogManager.h b/src/Core/LogManager.h
index a1f3d7d..5de38a9 100644
--- a/src/Core/LogManager.h
+++ b/src/Core/LogManager.h
@@ -96,8 +96,7 @@ class MAD_CORE_EXPORT LogManager : public Configurable {
~LogManager();
protected:
- virtual bool handleConfigEntry(const ConfigEntry &entry, bool handled);
- virtual void configFinished();
+ virtual void configure();
public:
static MessageLevel parseLevel(const String &str) throw (Exception);
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp
index 25e088a..a278ee5 100644
--- a/src/Server/ConnectionManager.cpp
+++ b/src/Server/ConnectionManager.cpp
@@ -114,7 +114,35 @@ void ConnectionManager::updateState(Common::HostInfo *hostInfo, Common::HostInfo
}
}
-bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
+void ConnectionManager::configure() {
+ x509TrustFile = application->getConfigManager()->get("X509TrustFile");
+ x509CrlFile = application->getConfigManager()->get("X509CrlFile");
+ x509CertFile = application->getConfigManager()->get("X509CertFile");
+ x509KeyFile = application->getConfigManager()->get("X509KeyFile");
+
+ std::vector<const Core::ConfigEntry*> listenEntries = application->getConfigManager()->getEntries("Listen");
+ if(!listenEntries.empty()) {
+ for(std::vector<const Core::ConfigEntry*>::iterator listenEntry = listenEntries.begin(); listenEntry != listenEntries.end(); ++listenEntry) {
+ try {
+ boost::shared_ptr<Net::Listener> listener(new Net::Listener(application, x509CertFile, x509KeyFile,
+ parseAddress((*listenEntry)->getValue().toString())));
+ listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
+ listeners.push_back(listener);
+ }
+ catch(Core::Exception &e) {
+ application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", (*listenEntry)->getValue().toLocale().c_str());
+ }
+ }
+ }
+ else {
+ boost::shared_ptr<Net::Listener> listener(new Net::Listener(application, x509CertFile, x509KeyFile,
+ boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), DEFAULT_PORT)));
+ listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
+ listeners.push_back(listener);
+ }
+}
+
+/*bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
if(handled)
return false;
@@ -179,7 +207,7 @@ void ConnectionManager::configFinished() {
// TODO Log error
}
}
-}
+}*/
void ConnectionManager::handleNewConnection(boost::shared_ptr<Net::Connection> con) {
boost::shared_ptr<ServerConnection> connection(new ServerConnection(application, con));
diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h
index 7e9dab0..28ddada 100644
--- a/src/Server/ConnectionManager.h
+++ b/src/Server/ConnectionManager.h
@@ -109,7 +109,6 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b
Core::String x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
- std::vector<boost::asio::ip::tcp::endpoint> listenerAddresses;
std::list<boost::shared_ptr<Net::Listener> > listeners;
std::set<boost::shared_ptr<ServerConnection> > connections;
@@ -131,8 +130,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b
~ConnectionManager();
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
- virtual void configFinished();
+ virtual void configure();
public:
boost::shared_ptr<Common::Connection> getDaemonConnection(const Core::String &name) const throw (Core::Exception);
diff --git a/src/Server/UserListManager.cpp b/src/Server/UserListManager.cpp
index a8794fe..04ba7d2 100644
--- a/src/Server/UserListManager.cpp
+++ b/src/Server/UserListManager.cpp
@@ -45,7 +45,7 @@ UserListManager::~UserListManager() {
}
-void UserListManager::configFinished() {
+void UserListManager::configure() {
userLists = application->getStorageManager()->list("UserList");
userListDiffs = application->getStorageManager()->list("UserListDiff");
diff --git a/src/Server/UserListManager.h b/src/Server/UserListManager.h
index 65e8fdf..bb5b4e3 100644
--- a/src/Server/UserListManager.h
+++ b/src/Server/UserListManager.h
@@ -57,7 +57,7 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo
std::set<Core::String> userListDiffs;
protected:
- virtual void configFinished();
+ virtual void configure();
public:
virtual int getPriority() const {return -1;}
diff --git a/src/mad-server.cpp b/src/mad-server.cpp
index 366ac61..3f8bdd6 100644
--- a/src/mad-server.cpp
+++ b/src/mad-server.cpp
@@ -39,7 +39,7 @@ int main() {
Server::Application application;
application.getConfigManager()->loadFile("mad-server.conf");
- application.getConfigManager()->finish();
+ application.getConfigManager()->configure();
while(true)
sleep(1000);
diff --git a/src/madc.cpp b/src/madc.cpp
index 7d8cb81..40138cd 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
Client::Application application;
- application.getConfigManager()->finish();
+ application.getConfigManager()->configure();
Common::ClientConnection *connection = new Common::ClientConnection(&application);
application.getRequestManager()->registerConnection(connection);
diff --git a/src/madd.cpp b/src/madd.cpp
index 0062d01..710e69f 100644
--- a/src/madd.cpp
+++ b/src/madd.cpp
@@ -38,7 +38,7 @@ int main() {
Daemon::Application application;
application.getConfigManager()->loadFile("madd.conf");
- application.getConfigManager()->finish();
+ application.getConfigManager()->configure();
application.getRequestManager()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>("Command");
application.getRequestManager()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>("FSInfo");
diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp
index 177d633..4522092 100644
--- a/src/modules/AuthProviderFile/AuthProviderFile.cpp
+++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp
@@ -88,33 +88,9 @@ void AuthProviderFile::readFile(const std::string &name) {
}
}
-bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(!entry[0].getKey().matches("AuthProviderFile"))
- return false;
+void AuthProviderFile::configure() {
+ filehash = application->getConfigManager()->get("AuthProviderFile.Hash");
- if(entry[1].isEmpty())
- return true;
-
- if(entry[1].getKey().matches("Hash")) {
- if(entry[2].isEmpty()) {
- filehash = entry[1][0];
-
- if(!Common::Hash::isHashSupported(filehash))
- application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Unsupported hash '%s'", filehash.toLocale().c_str());
- }
- }
- else if(entry[1].getKey().matches("File")) {
- if(entry[2].isEmpty()) {
- files.push_back(entry[1][0]);
- }
- }
- else if(!entry[2].isEmpty())
- return false;
-
- return true;
-}
-
-void AuthProviderFile::configFinished() {
if(filehash.isEmpty() || filehash.matches("clear")) {
hashes = Common::Hash::getHashList();
filehash.remove();
@@ -126,8 +102,10 @@ void AuthProviderFile::configFinished() {
hashes.push_back("Clear");
- for(std::vector<Core::String>::iterator file = files.begin(); file != files.end(); ++file)
- readFile(file->toLocale());
+ std::vector<const Core::ConfigEntry*> fileEntries = application->getConfigManager()->getEntries("AuthProviderFile.File");
+ for(std::vector<const Core::ConfigEntry*>::iterator fileEntry = fileEntries.begin(); fileEntry != fileEntries.end(); ++fileEntry) {
+ readFile((*fileEntry)->getValue().toLocale());
+ }
}
bool AuthProviderFile::checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception) {
diff --git a/src/modules/AuthProviderFile/AuthProviderFile.h b/src/modules/AuthProviderFile/AuthProviderFile.h
index 6ca907f..25a30b5 100644
--- a/src/modules/AuthProviderFile/AuthProviderFile.h
+++ b/src/modules/AuthProviderFile/AuthProviderFile.h
@@ -50,8 +50,7 @@ class MAD_MODULE_EXPORT AuthProviderFile : public Common::AuthProvider, private
std::vector<Core::String> hashes;
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/);
- virtual void configFinished();
+ virtual void configure();
virtual const std::vector<Core::String>& getHashes() const {
return hashes;
diff --git a/src/modules/FileLogger/Module.cpp b/src/modules/FileLogger/Module.cpp
index d8a302c..25a54b4 100644
--- a/src/modules/FileLogger/Module.cpp
+++ b/src/modules/FileLogger/Module.cpp
@@ -26,45 +26,38 @@ namespace Mad {
namespace Modules {
namespace FileLogger {
-bool Module::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
- if(handled)
- return false;
+void Module::configure() {
+ std::vector<const Core::ConfigEntry*> entries = application->getConfigManager()->getEntries("Log");
- if(entry[0].getKey().matches("Log")) {
- if(entry[0][0].matches("File")) {
- if(entry[1].isEmpty()) {
- if(!entry[0][1].isEmpty()) {
- lastLogger.reset(new FileLogger(entry[0][1].toLocale()));
+ for(std::vector<const Core::ConfigEntry*>::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
+ const std::vector<Core::String> &values = (*entry)->getValues();
- loggers.insert(lastLogger);
- application->getLogManager()->registerLogger(lastLogger);
- }
- else {
- lastLogger.reset();
- application->logf(Core::Logger::LOG_WARNING, "FileLogger: no filename given.");
- }
+ if(values.size() < 2 || !values.front().matches("File"))
+ continue;
- return true;
- }
- else if(entry[1].getKey().matches("Level")) {
- if(entry[2].isEmpty()) {
- try {
- if(entry[1][0].matches("remote"))
- lastLogger->setRemoteLevel(Core::LogManager::parseLevel(entry[1][1]));
- else
- lastLogger->setLevel(Core::LogManager::parseLevel(entry[1][0]));
- }
- catch(Core::Exception e) {
- application->logf(Core::Logger::LOG_WARNING, "Unknown log level '%s'.", entry[1][0].toLocale().c_str());
- }
+ boost::shared_ptr<FileLogger> logger(new FileLogger(values[1].toLocale()));
+ loggers.insert(logger);
+ application->getLogManager()->registerLogger(logger);
+
+ bool remote = false;
+ for(std::vector<Core::String>::const_iterator value = values.begin()+2; value != values.end(); ++value) {
+ if(value->matches("remote"))
+ remote = true;
+ }
- return true;
- }
+ Core::String level = (*entry)->get("Level");
+ if(!level.isEmpty()) {
+ try {
+ if(remote)
+ logger->setRemoteLevel(Core::LogManager::parseLevel(level));
+ else
+ logger->setLevel(Core::LogManager::parseLevel(level));
+ }
+ catch(Core::Exception e) {
+ application->logf(Core::Logger::LOG_WARNING, "Unknown log level '%s'.", level.toLocale().c_str());
}
}
}
-
- return false;
}
}
diff --git a/src/modules/FileLogger/Module.h b/src/modules/FileLogger/Module.h
index 8cf54a1..5cbd1df 100644
--- a/src/modules/FileLogger/Module.h
+++ b/src/modules/FileLogger/Module.h
@@ -39,10 +39,8 @@ class Module : public Common::Module, private Core::Configurable {
std::set<boost::shared_ptr<FileLogger> > loggers;
- boost::shared_ptr<FileLogger> lastLogger;
-
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
+ virtual void configure();
public:
Module(Common::Application *application0) : application(application0) {
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp
index e5da4e0..e801a64 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.cpp
+++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp
@@ -28,27 +28,10 @@ namespace Mad {
namespace Modules {
namespace StorageBackendFile {
-bool StorageBackendFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(!entry[0].getKey().matches("Storage"))
- return false;
-
+void StorageBackendFile::configure() {
boost::lock_guard<boost::shared_mutex> lock(mutex);
- if(entry[1].getKey().matches("Root")) {
- if(!entry[2].isEmpty())
- return false;
-
- storageRoot = entry[1][0].toLocale();
- }
- else if(!entry[1].isEmpty()) {
- return false;
- }
-
- return true;
-}
-
-void StorageBackendFile::configFinished() {
- boost::lock_guard<boost::shared_mutex> lock(mutex);
+ storageRoot = application->getConfigManager()->get("Storage.Root").toLocale();
if(!boost::filesystem::exists(storageRoot)) {
boost::filesystem::create_directories(storageRoot);
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.h b/src/modules/StorageBackendFile/StorageBackendFile.h
index f38e674..b1c685d 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.h
+++ b/src/modules/StorageBackendFile/StorageBackendFile.h
@@ -45,8 +45,7 @@ class StorageBackendFile : public Common::StorageBackend, private Core::Configur
boost::filesystem::path getFileName(const Core::String &type, const Core::String &name);
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
- virtual void configFinished();
+ virtual void configure();
virtual std::set<Core::String> listTypes() throw (Core::Exception);
virtual std::set<Core::String> list(const Core::String &type) throw (Core::Exception);
diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
index 4dca729..a19769c 100644
--- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
+++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
@@ -31,40 +31,16 @@ namespace Mad {
namespace Modules {
namespace UserConfigBackendHome {
-bool UserConfigBackendHome::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(entry[0].getKey().matches("UserManager")) {
- if(entry[1].getKey().matches("Skeleton")) {
- if(entry[2].isEmpty())
- skeleton = entry[1][0];
- }
- else if(entry[1].getKey().matches("HomeDir")) {
- if(entry[2].isEmpty())
- homeDir = entry[1][0];
- }
- else if(entry[1].getKey().matches("UserDirMode")) {
- if(entry[2].isEmpty()) {
- if(entry[1][0].isEmpty()) {
- dirMode = 0755;
- }
- else {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 8);
- if(*endptr || val > 07777) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: DirMode '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- dirMode = val;
- }
- }
- }
- }
- else if(!entry[1].isEmpty())
- return false;
-
- return true;
+void UserConfigBackendHome::configure() {
+ skeleton = application->getConfigManager()->get("UserManager.Skeleton");
+ homeDir = application->getConfigManager()->get("UserManager.HomeDir", "/home");
+
+ dirMode = std::strtoul(application->getConfigManager()->get("UserManager.UserDirMode", "775").toString().c_str(), 0, 8);
+ if(dirMode > 07777) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: UserDirMode '%s'",
+ application->getConfigManager()->get("UserManager.UserDirMode").toLocale().c_str());
+ dirMode = 0775;
}
-
- return false;
}
void UserConfigBackendHome::setOwnerAndCopyMode(const std::string &source, const std::string &dest, const Common::UserInfo &userInfo, bool isSymlink) {
diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
index e82795c..41370ff 100644
--- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
+++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
@@ -47,14 +47,14 @@ class UserConfigBackendHome : public Common::UserConfigBackend, private Core::Co
void migrateOwner(const std::string &path, const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo, bool isSymlink);
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
+ virtual void configure();
virtual void addUser(const Common::UserInfo &userInfo) throw(Core::Exception);
virtual void updateUser(const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo) throw(Core::Exception);
virtual void deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception);
public:
- UserConfigBackendHome(Common::Application *application0) : application(application0), homeDir("/home"), dirMode(0755) {
+ UserConfigBackendHome(Common::Application *application0) : application(application0) {
application->getConfigManager()->registerConfigurable(this);
}
diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
index f0c65b1..61ad996 100644
--- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
+++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
@@ -93,46 +93,15 @@ void UserConfigBackendKrb5::_connect() {
return;
}
-bool UserConfigBackendKrb5::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(!entry[0].getKey().matches("UserManager"))
- return false;
-
- if(entry[1].isEmpty())
- return true;
-
- if(!entry[1].getKey().matches("Krb5"))
- return false;
-
+void UserConfigBackendKrb5::configure() {
boost::lock_guard<boost::mutex> lock(mutex);
- if(entry[2].getKey().matches("Realm")) {
- if(entry[3].isEmpty())
- realm = entry[2][0];
- }
- else if(entry[2].getKey().matches("Principal")) {
- if(entry[3].isEmpty())
- principal = entry[2][0];
- }
- else if(entry[2].getKey().matches("Server")) {
- if(entry[3].isEmpty())
- server = entry[2][0];
- }
- else if(entry[2].getKey().matches("Password")) {
- if(entry[3].isEmpty())
- password = entry[2][0];
- }
- else if(entry[2].getKey().matches("Keytab")) {
- if(entry[3].isEmpty())
- keytab = entry[2][0];
- }
- else if(!entry[2].isEmpty())
- return false;
+ realm = application->getConfigManager()->get("UserManager.Krb5.Realm", realm);
+ principal = application->getConfigManager()->get("UserManager.Krb5.Principal");
+ server = application->getConfigManager()->get("UserManager.Krb5.Server");
+ password = application->getConfigManager()->get("UserManager.Krb5.Password");
+ keytab = application->getConfigManager()->get("UserManager.Krb5.Keytab");
- return true;
-}
-
-void UserConfigBackendKrb5::configFinished() {
- boost::lock_guard<boost::mutex> lock(mutex);
_connect();
}
diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
index eab8be4..64f8501 100644
--- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
+++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.h
@@ -50,8 +50,7 @@ class UserConfigBackendKrb5 : public Common::UserConfigBackend, private Core::Co
void _connect();
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
- virtual void configFinished();
+ virtual void configure();
virtual void checkUserInfo(const Common::UserInfo &userInfo) throw(Core::Exception);
diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
index 1d213a8..be5426d 100644
--- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
+++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
@@ -37,128 +37,32 @@ namespace UserDBBackendMysql {
const Core::String UserDBBackendMysql::name("UserDBBackendMysql");
-bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(!entry[0].getKey().matches("UserManager"))
- return false;
+void UserDBBackendMysql::configure() {
+ host = application->getConfigManager()->get("UserManager.Mysql.Host");
+ username = application->getConfigManager()->get("UserManager.Mysql.Username");
+ passwd = application->getConfigManager()->get("UserManager.Mysql.Password");
+ db = application->getConfigManager()->get("UserManager.Mysql.Database");
+ port = std::strtol(application->getConfigManager()->get("UserManager.Mysql.Port").toString().c_str(), 0, 10);
+ unixSocket = application->getConfigManager()->get("UserManager.Mysql.UnixSocket");
+
+ queryListUsers = application->getConfigManager()->get("UserManager.Mysql.Queries.ListUsers");
+ queryListGroups = application->getConfigManager()->get("UserManager.Mysql.Queries.ListGroups");
+ queryListUserGroups = application->getConfigManager()->get("UserManager.Mysql.Queries.ListUserGroups");
+ queryListGroupUsers = application->getConfigManager()->get("UserManager.Mysql.Queries.ListGroupUsers");
+ queryUserById = application->getConfigManager()->get("UserManager.Mysql.Queries.UserById");
+ queryUserByName = application->getConfigManager()->get("UserManager.Mysql.Queries.UserByName");
+ queryGroupById = application->getConfigManager()->get("UserManager.Mysql.Queries.GroupById");
+ queryGroupByName = application->getConfigManager()->get("UserManager.Mysql.Queries.GroupByName");
+ queryUserGroupTable = application->getConfigManager()->get("UserManager.Mysql.Queries.UserGroupTable");
+ queryAddUser = application->getConfigManager()->get("UserManager.Mysql.Queries.AddUser");
+ queryUpdateUser = application->getConfigManager()->get("UserManager.Mysql.Queries.UpdateUser");
+ queryDeleteUser = application->getConfigManager()->get("UserManager.Mysql.Queries.DeleteUser");
+ queryAddGroup = application->getConfigManager()->get("UserManager.Mysql.Queries.AddGroup");
+ queryUpdateGroup = application->getConfigManager()->get("UserManager.Mysql.Queries.UpdateGroup");
+ queryDeleteGroup = application->getConfigManager()->get("UserManager.Mysql.Queries.DeleteGroup");
+ queryAddUserToGroup = application->getConfigManager()->get("UserManager.Mysql.Queries.AddUserToGroup");
+ queryDeleteUserFromGroup = application->getConfigManager()->get("UserManager.Mysql.Queries.DeleteUserFromGroup");
- if(entry[1].isEmpty())
- return true;
-
- if(!entry[1].getKey().matches("Mysql"))
- return false;
-
- if(entry[2].getKey().matches("Host")) {
- if(entry[3].isEmpty())
- host = entry[2][0];
- }
- else if(entry[2].getKey().matches("Username")) {
- if(entry[3].isEmpty())
- username = entry[2][0];
- }
- else if(entry[2].getKey().matches("Password")) {
- if(entry[3].isEmpty())
- passwd = entry[2][0];
- }
- else if(entry[2].getKey().matches("Database")) {
- if(entry[3].isEmpty())
- db = entry[2][0];
- }
- else if(entry[2].getKey().matches("Port")) {
- if(entry[3].isEmpty()) {
- char *endptr;
- long val;
-
- val = strtol(entry[2][0].toString().c_str(), &endptr, 10);
-
- if(endptr != 0 || val < 0 || val > 65535)
- application->log(Core::Logger::LOG_WARNING, "UserDBBackendMysql: Invalid port");
- else
- port = val;
- }
- }
- else if(entry[2].getKey().matches("UnixSocket")) {
- if(entry[3].isEmpty())
- unixSocket = entry[2][0];
- }
- else if(entry[2].getKey().matches("Queries")) {
- if(entry[3].getKey().matches("ListUsers")) {
- if(entry[4].isEmpty())
- queryListUsers = entry[3][0];
- }
- else if(entry[3].getKey().matches("ListGroups")) {
- if(entry[4].isEmpty())
- queryListGroups = entry[3][0];
- }
- else if(entry[3].getKey().matches("ListUserGroups")) {
- if(entry[4].isEmpty())
- queryListUserGroups = entry[3][0];
- }
- else if(entry[3].getKey().matches("ListGroupUsers")) {
- if(entry[4].isEmpty())
- queryListGroupUsers = entry[3][0];
- }
- else if(entry[3].getKey().matches("UserById")) {
- if(entry[4].isEmpty())
- queryUserById = entry[3][0];
- }
- else if(entry[3].getKey().matches("UserByName")) {
- if(entry[4].isEmpty())
- queryUserByName = entry[3][0];
- }
- else if(entry[3].getKey().matches("GroupById")) {
- if(entry[4].isEmpty())
- queryGroupById = entry[3][0];
- }
- else if(entry[3].getKey().matches("GroupByName")) {
- if(entry[4].isEmpty())
- queryGroupByName = entry[3][0];
- }
- else if(entry[3].getKey().matches("UserGroupTable")) {
- if(entry[4].isEmpty())
- queryUserGroupTable = entry[3][0];
- }
- else if(entry[3].getKey().matches("AddUser")) {
- if(entry[4].isEmpty())
- queryAddUser = entry[3][0];
- }
- else if(entry[3].getKey().matches("UpdateUser")) {
- if(entry[4].isEmpty())
- queryUpdateUser = entry[3][0];
- }
- else if(entry[3].getKey().matches("DeleteUser")) {
- if(entry[4].isEmpty())
- queryDeleteUser = entry[3][0];
- }
- else if(entry[3].getKey().matches("AddGroup")) {
- if(entry[4].isEmpty())
- queryAddGroup = entry[3][0];
- }
- else if(entry[3].getKey().matches("UpdateGroup")) {
- if(entry[4].isEmpty())
- queryUpdateGroup = entry[3][0];
- }
- else if(entry[3].getKey().matches("DeleteGroup")) {
- if(entry[4].isEmpty())
- queryDeleteGroup = entry[3][0];
- }
- else if(entry[3].getKey().matches("AddUserToGroup")) {
- if(entry[4].isEmpty())
- queryAddUserToGroup = entry[3][0];
- }
- else if(entry[3].getKey().matches("DeleteUserFromGroup")) {
- if(entry[4].isEmpty())
- queryDeleteUserFromGroup = entry[3][0];
- }
- else if(!entry[3].isEmpty())
- return false;
- }
- else if(!entry[2].isEmpty())
- return false;
-
- return true;
-}
-
-void UserDBBackendMysql::configFinished() {
if(db.isEmpty()) {
application->log(Core::Logger::LOG_ERROR, "UserDBBackendMysql: No database name given");
return;
diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
index 9351ca1..10c069c 100644
--- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
+++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
@@ -107,8 +107,7 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura
boost::mutex mutex;
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
- virtual void configFinished();
+ virtual void configure();
virtual boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const Common::UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception);
@@ -134,7 +133,7 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura
virtual void deleteUserFromGroup(unsigned long uid, unsigned long gid) throw(Core::Exception);
public:
- UserDBBackendMysql(Common::Application *application0) : application(application0), port(0), mysql(0), lastUpdate(boost::posix_time::microsec_clock::universal_time()) {
+ UserDBBackendMysql(Common::Application *application0) : application(application0), mysql(0), lastUpdate(boost::posix_time::microsec_clock::universal_time()) {
application->getConfigManager()->registerConfigurable(this);
}