mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11736] Hide passwords from logs
* DB connection * chat/console password changes commands.
This commit is contained in:
parent
f4802ab4c4
commit
a0ff5f4536
9 changed files with 68 additions and 57 deletions
|
|
@ -1223,22 +1223,7 @@ void ChatHandler::ExecuteCommand(const char* text)
|
||||||
if ((this->*(command->Handler))((char*)text)) // text content destroyed at call
|
if ((this->*(command->Handler))((char*)text)) // text content destroyed at call
|
||||||
{
|
{
|
||||||
if (command->SecurityLevel > SEC_PLAYER)
|
if (command->SecurityLevel > SEC_PLAYER)
|
||||||
{
|
LogCommand(fullcmd.c_str());
|
||||||
// chat case
|
|
||||||
if (m_session)
|
|
||||||
{
|
|
||||||
Player* p = m_session->GetPlayer();
|
|
||||||
ObjectGuid sel_guid = p->GetSelectionGuid();
|
|
||||||
sLog.outCommand(GetAccountId(),"Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s]",
|
|
||||||
fullcmd.c_str(),p->GetName(),GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(),
|
|
||||||
sel_guid.GetString().c_str());
|
|
||||||
}
|
|
||||||
else // 0 account -> console
|
|
||||||
{
|
|
||||||
sLog.outCommand(GetAccountId(),"Command: %s [Account: %u from %s]",
|
|
||||||
fullcmd.c_str(),GetAccountId(),GetAccountId() ? "RA-connection" : "Console");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// some commands have custom error messages. Don't send the default one in these cases.
|
// some commands have custom error messages. Don't send the default one in these cases.
|
||||||
else if (!HasSentErrorMessage())
|
else if (!HasSentErrorMessage())
|
||||||
|
|
@ -3571,6 +3556,24 @@ std::string ChatHandler::PrepareStringNpcOrGoSpawnInformation(uint32 guid)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatHandler::LogCommand(char const* fullcmd)
|
||||||
|
{
|
||||||
|
// chat case
|
||||||
|
if (m_session)
|
||||||
|
{
|
||||||
|
Player* p = m_session->GetPlayer();
|
||||||
|
ObjectGuid sel_guid = p->GetSelectionGuid();
|
||||||
|
sLog.outCommand(GetAccountId(),"Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s]",
|
||||||
|
fullcmd, p->GetName(), GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(),
|
||||||
|
sel_guid.GetString().c_str());
|
||||||
|
}
|
||||||
|
else // 0 account -> console
|
||||||
|
{
|
||||||
|
sLog.outCommand(GetAccountId(),"Command: %s [Account: %u from %s]",
|
||||||
|
fullcmd, GetAccountId(), GetAccountId() ? "RA-connection" : "Console");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Instantiate template for helper function
|
// Instantiate template for helper function
|
||||||
template void ChatHandler::ShowNpcOrGoSpawnInformation<Creature>(uint32 guid);
|
template void ChatHandler::ShowNpcOrGoSpawnInformation<Creature>(uint32 guid);
|
||||||
template void ChatHandler::ShowNpcOrGoSpawnInformation<GameObject>(uint32 guid);
|
template void ChatHandler::ShowNpcOrGoSpawnInformation<GameObject>(uint32 guid);
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,8 @@ class MANGOS_DLL_SPEC ChatHandler
|
||||||
|
|
||||||
bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help);
|
bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help);
|
||||||
void ExecuteCommand(const char* text);
|
void ExecuteCommand(const char* text);
|
||||||
|
void LogCommand(char const* fullcmd);
|
||||||
|
|
||||||
bool ShowHelpForCommand(ChatCommand *table, const char* cmd);
|
bool ShowHelpForCommand(ChatCommand *table, const char* cmd);
|
||||||
bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd);
|
bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd);
|
||||||
ChatCommandSearchResult FindCommand(ChatCommand* table, char const*& text, ChatCommand*& command, ChatCommand** parentCommand = NULL, std::string* cmdNamePtr = NULL, bool allAvailable = false, bool exactlyName = false);
|
ChatCommandSearchResult FindCommand(ChatCommand* table, char const*& text, ChatCommand*& command, ChatCommand** parentCommand = NULL, std::string* cmdNamePtr = NULL, bool allAvailable = false, bool exactlyName = false);
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,10 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// OK, but avoid normal report for hide passwords, but log use command for anyone
|
||||||
|
LogCommand(".account password *** *** ***");
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleAccountLockCommand(char* args)
|
bool ChatHandler::HandleAccountLockCommand(char* args)
|
||||||
|
|
|
||||||
|
|
@ -1226,7 +1226,12 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// OK, but avoid normal report for hide passwords, but log use command for anyone
|
||||||
|
char msg[100];
|
||||||
|
snprintf( msg, 100, ".account set password %s *** ***", account_name.c_str());
|
||||||
|
LogCommand(msg);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ bool Master::_StartDB()
|
||||||
sLog.outError("Database not specified in configuration file");
|
sLog.outError("Database not specified in configuration file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sLog.outString("World Database: %s, total connections: %i", dbstring.c_str(), nConnections + 1);
|
sLog.outString("World Database total connections: %i", nConnections + 1);
|
||||||
|
|
||||||
///- Initialise the world database
|
///- Initialise the world database
|
||||||
if(!WorldDatabase.Initialize(dbstring.c_str(), nConnections))
|
if(!WorldDatabase.Initialize(dbstring.c_str(), nConnections))
|
||||||
|
|
@ -457,7 +457,7 @@ bool Master::_StartDB()
|
||||||
WorldDatabase.HaltDelayThread();
|
WorldDatabase.HaltDelayThread();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sLog.outString("Character Database: %s, total connections: %i", dbstring.c_str(), nConnections + 1);
|
sLog.outString("Character Database total connections: %i", nConnections + 1);
|
||||||
|
|
||||||
///- Initialise the Character database
|
///- Initialise the Character database
|
||||||
if(!CharacterDatabase.Initialize(dbstring.c_str(), nConnections))
|
if(!CharacterDatabase.Initialize(dbstring.c_str(), nConnections))
|
||||||
|
|
@ -491,7 +491,7 @@ bool Master::_StartDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
///- Initialise the login database
|
///- Initialise the login database
|
||||||
sLog.outString("Login Database: %s, total connections: %i", dbstring.c_str(), nConnections + 1);
|
sLog.outString("Login Database total connections: %i", nConnections + 1);
|
||||||
if(!LoginDatabase.Initialize(dbstring.c_str(), nConnections))
|
if(!LoginDatabase.Initialize(dbstring.c_str(), nConnections))
|
||||||
{
|
{
|
||||||
sLog.outError("Cannot connect to login database %s",dbstring.c_str());
|
sLog.outError("Cannot connect to login database %s",dbstring.c_str());
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,8 @@ bool StartDB()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog.outString("Database: %s", dbstring.c_str() );
|
sLog.outString("Login Database total connections: %i", 1 + 1);
|
||||||
|
|
||||||
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
||||||
{
|
{
|
||||||
sLog.outError("Cannot connect to database");
|
sLog.outError("Cannot connect to database");
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,17 @@ bool MySQLConnection::Initialize(const char *infoString)
|
||||||
mMysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),
|
mMysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),
|
||||||
password.c_str(), database.c_str(), port, unix_socket, 0);
|
password.c_str(), database.c_str(), port, unix_socket, 0);
|
||||||
|
|
||||||
if (mMysql)
|
if (!mMysql)
|
||||||
{
|
{
|
||||||
DETAIL_LOG( "Connected to MySQL database at %s",
|
sLog.outError( "Could not connect to MySQL database at %s: %s\n",
|
||||||
host.c_str());
|
host.c_str(),mysql_error(mysqlInit));
|
||||||
sLog.outString( "MySQL client library: %s", mysql_get_client_info());
|
mysql_close(mysqlInit);
|
||||||
sLog.outString( "MySQL server ver: %s ", mysql_get_server_info( mMysql));
|
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---------*/
|
/*----------SET AUTOCOMMIT ON---------*/
|
||||||
// It seems mysql 5.0.x have enabled this feature
|
// It seems mysql 5.0.x have enabled this feature
|
||||||
|
|
@ -167,14 +172,6 @@ bool MySQLConnection::Initialize(const char *infoString)
|
||||||
Execute("SET CHARACTER SET `utf8`");
|
Execute("SET CHARACTER SET `utf8`");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sLog.outError( "Could not connect to MySQL database at %s: %s\n",
|
|
||||||
host.c_str(),mysql_error(mysqlInit));
|
|
||||||
mysql_close(mysqlInit);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MySQLConnection::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **pFields, uint64* pRowCount, uint32* pFieldCount)
|
bool MySQLConnection::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **pFields, uint64* pRowCount, uint32* pFieldCount)
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ bool PostgreSQLConnection::Initialize(const char *infoString)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog.outDetail( "Connected to Postgre database at %s", host.c_str());
|
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));
|
sLog.outString("PostgreSQL server ver: %d", PQserverVersion(mPGconn));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11735"
|
#define REVISION_NR "11736"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue