X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=aecb06e38e5c8e14f39cc838b3d5b63061f2c4cd;hp=aa5206330e83faf9b85c8a9489f40bde357e4e1f;hb=6422c61b11d97f905b6a27f2d280e9ec0d8bb3e2;hpb=8697a21faab21ae23646f559cba9a85bd95b2ad7 diff --git a/src/core/core.cpp b/src/core/core.cpp index aa520633..aecb06e3 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -239,7 +239,7 @@ void Core::init() if (Quassel::isOptionSet("oidentd")) { _oidentdConfigGenerator = new OidentdConfigGenerator(Quassel::isOptionSet("oidentd-strict"), this); if (Quassel::isOptionSet("oidentd-strict")) { - cacheSysident(); + cacheSysIdent(); } } } @@ -333,7 +333,7 @@ QString Core::setupCore(const QString &adminUser, const QString &adminPassword, quInfo() << qPrintable(tr("Creating admin user...")); _storage->addUser(adminUser, adminPassword); - cacheSysident(); + cacheSysIdent(); startListening(); // TODO check when we need this return QString(); } @@ -553,32 +553,35 @@ bool Core::reloadCerts() #endif } -void Core::cacheSysident() { - if(isConfigured()) { - instance()->_authusernames = instance()->_storage->getAllAuthusernames(); + +void Core::cacheSysIdent() +{ + if (isConfigured()) { + instance()->_authUserNames = instance()->_storage->getAllAuthUserNames(); } } -QString Core::strictSysident(UserId user) { - QMap *allAuthusernames = &instance()->_authusernames; - auto authusername = allAuthusernames->find(user); - if (authusername == allAuthusernames->end()) { - // A new user got added since we last pulled our cache from the database. - // There's no way to avoid a database hit - we don't even know the authname! - cacheSysident(); - authusername = allAuthusernames->find(user); - if (authusername == allAuthusernames->end()) { - // ...something very weird is going on if we ended up here (an active CoreSession without a corresponding database entry?) - QDebug d = qWarning(); - d << "Unable to find authusername for UserId" << user; - d.nospace(); - d << ", this should never happen!"; - return "unknown"; // Should we just terminate the program instead? - } + +QString Core::strictSysIdent(UserId user) const +{ + if (_authUserNames.contains(user)) { + return _authUserNames[user]; } - return *authusername; + + // A new user got added since we last pulled our cache from the database. + // There's no way to avoid a database hit - we don't even know the authname! + cacheSysIdent(); + + if (_authUserNames.contains(user)) { + return _authUserNames[user]; + } + + // ...something very weird is going on if we ended up here (an active CoreSession without a corresponding database entry?) + qWarning().nospace() << "Unable to find authusername for UserId " << user << ", this should never happen!"; + return "unknown"; // Should we just terminate the program instead? } + bool Core::startListening() { // in mono mode we only start a local port if a port is specified in the cli call