[11736] Hide passwords from logs

* DB connection
* chat/console password changes commands.
This commit is contained in:
VladimirMangos 2011-07-13 05:38:43 +04:00
parent f4802ab4c4
commit a0ff5f4536
9 changed files with 68 additions and 57 deletions

View file

@ -137,44 +137,41 @@ bool MySQLConnection::Initialize(const char *infoString)
mMysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),
password.c_str(), database.c_str(), port, unix_socket, 0);
if (mMysql)
{
DETAIL_LOG( "Connected to MySQL database at %s",
host.c_str());
sLog.outString( "MySQL client library: %s", mysql_get_client_info());
sLog.outString( "MySQL server ver: %s ", mysql_get_server_info( mMysql));
/*----------SET AUTOCOMMIT ON---------*/
// It seems mysql 5.0.x have enabled this feature
// by default. In crash case you can lose data!!!
// So better to turn this off
// ---
// This is wrong since mangos use transactions,
// autocommit is turned of during it.
// Setting it to on makes atomic updates work
// ---
// LEAVE 'AUTOCOMMIT' MODE ALWAYS ENABLED!!!
// W/O IT EVEN 'SELECT' QUERIES WOULD REQUIRE TO BE WRAPPED INTO 'START TRANSACTION'<>'COMMIT' CLAUSES!!!
if (!mysql_autocommit(mMysql, 1))
DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1");
else
DETAIL_LOG("AUTOCOMMIT NOT SET TO 1");
/*-------------------------------------*/
// set connection properties to UTF8 to properly handle locales for different
// server configs - core sends data in UTF8, so MySQL must expect UTF8 too
Execute("SET NAMES `utf8`");
Execute("SET CHARACTER SET `utf8`");
return true;
}
else
if (!mMysql)
{
sLog.outError( "Could not connect to MySQL database at %s: %s\n",
host.c_str(),mysql_error(mysqlInit));
mysql_close(mysqlInit);
return false;
}
DETAIL_LOG("Connected to MySQL database %s@%s:%s/%s", user.c_str(), host.c_str(), port_or_socket.c_str(), database.c_str());
sLog.outString("MySQL client library: %s", mysql_get_client_info());
sLog.outString("MySQL server ver: %s ", mysql_get_server_info( mMysql));
/*----------SET AUTOCOMMIT ON---------*/
// It seems mysql 5.0.x have enabled this feature
// by default. In crash case you can lose data!!!
// So better to turn this off
// ---
// This is wrong since mangos use transactions,
// autocommit is turned of during it.
// Setting it to on makes atomic updates work
// ---
// LEAVE 'AUTOCOMMIT' MODE ALWAYS ENABLED!!!
// W/O IT EVEN 'SELECT' QUERIES WOULD REQUIRE TO BE WRAPPED INTO 'START TRANSACTION'<>'COMMIT' CLAUSES!!!
if (!mysql_autocommit(mMysql, 1))
DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1");
else
DETAIL_LOG("AUTOCOMMIT NOT SET TO 1");
/*-------------------------------------*/
// set connection properties to UTF8 to properly handle locales for different
// server configs - core sends data in UTF8, so MySQL must expect UTF8 too
Execute("SET NAMES `utf8`");
Execute("SET CHARACTER SET `utf8`");
return true;
}
bool MySQLConnection::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **pFields, uint64* pRowCount, uint32* pFieldCount)

View file

@ -92,8 +92,8 @@ bool PostgreSQLConnection::Initialize(const char *infoString)
return false;
}
sLog.outDetail( "Connected to Postgre database at %s", host.c_str());
sLog.outString( "PostgreSQL server ver: %d", PQserverVersion(mPGconn));
DETAIL_LOG("Connected to Postgre database %s@%s:%s/%s", user.c_str(), host.c_str(), port_or_socket_dir.c_str(), database.c_str());
sLog.outString("PostgreSQL server ver: %d", PQserverVersion(mPGconn));
return true;
}