diff options
Diffstat (limited to 'src/Common/UserManager.cpp')
-rw-r--r-- | src/Common/UserManager.cpp | 81 |
1 files changed, 26 insertions, 55 deletions
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) { |