mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 17:45:09 -07:00
[Servatrice] Treat failed strict-mode check as boot error
This commit is contained in:
parent
de3e01e8d8
commit
b3c3bad9fc
2 changed files with 22 additions and 6 deletions
|
|
@ -99,7 +99,24 @@ bool Servatrice_DatabaseInterface::openDatabase()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStrictModeEnabled()) {
|
if (sqlDatabase.driverName() != "QMYSQL") {
|
||||||
|
qCCritical(DatabaseInterfaceLog)
|
||||||
|
<< poolStr
|
||||||
|
<< "Error opening database: connection is not a MySQL/MariaDB database, Servatrice only "
|
||||||
|
"supports the QMYSQL driver (actual driver:"
|
||||||
|
<< sqlDatabase.driverName() << ").";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool strictModeCheckOk = false;
|
||||||
|
const bool strictModeEnabled = isStrictModeEnabled(strictModeCheckOk);
|
||||||
|
if (!strictModeCheckOk) {
|
||||||
|
qCCritical(DatabaseInterfaceLog) << poolStr
|
||||||
|
<< "Error opening database: unable to determine whether MySQL/MariaDB strict "
|
||||||
|
"mode is enabled";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strictModeEnabled) {
|
||||||
qCCritical(DatabaseInterfaceLog) << poolStr
|
qCCritical(DatabaseInterfaceLog) << poolStr
|
||||||
<< "Error opening database: MySQL/MariaDB strict mode is enabled, which "
|
<< "Error opening database: MySQL/MariaDB strict mode is enabled, which "
|
||||||
"breaks most Servatrice database operations. Please disable strict mode "
|
"breaks most Servatrice database operations. Please disable strict mode "
|
||||||
|
|
@ -116,14 +133,13 @@ bool Servatrice_DatabaseInterface::openDatabase()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Servatrice_DatabaseInterface::isStrictModeEnabled() const
|
bool Servatrice_DatabaseInterface::isStrictModeEnabled(bool &ok) const
|
||||||
{
|
{
|
||||||
if (sqlDatabase.driverName() != "QMYSQL") {
|
ok = true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSqlQuery query(sqlDatabase);
|
QSqlQuery query(sqlDatabase);
|
||||||
if (!query.exec("SELECT @@GLOBAL.sql_mode")) {
|
if (!query.exec("SELECT @@GLOBAL.sql_mode")) {
|
||||||
|
ok = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ private:
|
||||||
bool checkUserIsIpBanned(const QString &ipAddress, QString &banReason, int &banSecondsRemaining);
|
bool checkUserIsIpBanned(const QString &ipAddress, QString &banReason, int &banSecondsRemaining);
|
||||||
/** Must be called after checkSql and server is known to be in auth mode. */
|
/** Must be called after checkSql and server is known to be in auth mode. */
|
||||||
bool checkUserIsNameBanned(QString const &userName, QString &banReason, int &banSecondsRemaining);
|
bool checkUserIsNameBanned(QString const &userName, QString &banReason, int &banSecondsRemaining);
|
||||||
bool isStrictModeEnabled() const;
|
bool isStrictModeEnabled(bool &ok) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler,
|
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue