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();
+ }
+ }
}
void Core::saveState()
{
- CoreSettings s;
- QVariantMap state;
QVariantList activeSessions;
foreach(UserId user, instance()->_sessions.keys())
activeSessions << QVariant::fromValue<UserId>(user);
- state["CoreStateVersion"] = 1;
- state["ActiveSessions"] = activeSessions;
- s.setCoreState(state);
+ instance()->_storage->setCoreState(activeSessions);
}
}
*/
- QVariantList activeSessions = s.coreState().toMap()["ActiveSessions"].toList();
+ const QList<QVariant> &activeSessionsFallback = s.coreState().toMap()["ActiveSessions"].toList();
+ QVariantList activeSessions = instance()->_storage->getCoreState(activeSessionsFallback);
+
if (activeSessions.count() > 0) {
quInfo() << "Restoring previous core state...";
foreach(QVariant v, activeSessions) {
quInfo() << qPrintable(tr("Creating admin user..."));
_storage->addUser(adminUser, adminPassword);
+ cacheSysIdent();
startListening(); // TODO check when we need this
return QString();
}
}
+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