X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=aecb06e38e5c8e14f39cc838b3d5b63061f2c4cd;hp=73fde97c99ecb113c276599a81d5e187b39a390c;hb=092e6b212637ffbf68800584b7c1f32d1931b602;hpb=f932e5c8a0ec3ff689686a71c32ee61a428c4340 diff --git a/src/core/core.cpp b/src/core/core.cpp index 73fde97c..aecb06e3 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -236,8 +236,12 @@ void Core::init() connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); if (!startListening()) exit(1); // TODO make this less brutal - if (Quassel::isOptionSet("oidentd")) + if (Quassel::isOptionSet("oidentd")) { _oidentdConfigGenerator = new OidentdConfigGenerator(Quassel::isOptionSet("oidentd-strict"), this); + if (Quassel::isOptionSet("oidentd-strict")) { + cacheSysIdent(); + } + } } @@ -329,6 +333,7 @@ QString Core::setupCore(const QString &adminUser, const QString &adminPassword, quInfo() << qPrintable(tr("Creating admin user...")); _storage->addUser(adminUser, adminPassword); + cacheSysIdent(); startListening(); // TODO check when we need this return QString(); } @@ -549,6 +554,34 @@ bool Core::reloadCerts() } +void Core::cacheSysIdent() +{ + if (isConfigured()) { + instance()->_authUserNames = instance()->_storage->getAllAuthUserNames(); + } +} + + +QString Core::strictSysIdent(UserId user) const +{ + if (_authUserNames.contains(user)) { + return _authUserNames[user]; + } + + // 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