/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
if (!startListening()) exit(1); // TODO make this less brutal
- if (Quassel::isOptionSet("oidentd"))
- _oidentdConfigGenerator = new OidentdConfigGenerator(this);
+ if (Quassel::isOptionSet("oidentd")) {
+ _oidentdConfigGenerator = new OidentdConfigGenerator(Quassel::isOptionSet("oidentd-strict"), this);
+ if (Quassel::isOptionSet("oidentd-strict")) {
+ cacheSysident();
+ }
+ }
}
quInfo() << qPrintable(tr("Creating admin user..."));
_storage->addUser(adminUser, adminPassword);
+ cacheSysident();
startListening(); // TODO check when we need this
return QString();
}
return false; // trigger setup process
if (storage->setup(settings))
return initStorage(backend, settings, false);
+ return false;
+
// if initialization wasn't successful, we quit to keep from coming up unconfigured
case Storage::NotAvailable:
qCritical() << "FATAL: Selected storage backend is not available:" << backend;
- exit(EXIT_FAILURE);
+ if (!setup)
+ exit(EXIT_FAILURE);
+ return false;
+
case Storage::IsReady:
// delete all other backends
_registeredStorageBackends.clear();
return false; // trigger setup process
if (auth->setup(settings))
return initAuthenticator(backend, settings, false);
+ return false;
+
// if initialization wasn't successful, we quit to keep from coming up unconfigured
case Authenticator::NotAvailable:
qCritical() << "FATAL: Selected auth backend is not available:" << backend;
- exit(EXIT_FAILURE);
+ if (!setup)
+ exit(EXIT_FAILURE);
+ return false;
+
case Authenticator::IsReady:
// delete all other backends
_registeredAuthenticators.clear();
#endif
}
+void Core::cacheSysident() {
+ if(isConfigured()) {
+ instance()->_authusernames = instance()->_storage->getAllAuthusernames();
+ }
+}
+
+QString Core::strictSysident(UserId user) {
+ QMap<UserId, QString> *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?
+ }
+ }
+ return *authusername;
+}
bool Core::startListening()
{