masks MySQL password from console startup messages

0.6.0-stable
Dahlia Trimble 2008-07-18 03:23:40 +00:00
parent 263633e274
commit 230a7ecaec
2 changed files with 47 additions and 3 deletions

View File

@ -113,7 +113,28 @@ namespace OpenSim.Data.MySQL
m_dataSet = new DataSet(); m_dataSet = new DataSet();
this.persistPrimInventories = persistPrimInventories; this.persistPrimInventories = persistPrimInventories;
m_log.Info("[REGION DB]: MySql - connecting: " + m_connectionString); int passPosition = 0;
int passEndPosition = 0;
string displayConnectionString = null;
try
{ // hide the password in the connection string
passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase);
passPosition = m_connectionString.IndexOf("=", passPosition);
if (passPosition < m_connectionString.Length)
passPosition += 1;
passEndPosition = m_connectionString.IndexOf(";", passPosition);
displayConnectionString = m_connectionString.Substring(0, passPosition);
displayConnectionString += "***";
displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition);
}
catch (Exception e )
{
m_log.Debug("Exception: password not found in connection string\n" + e.ToString());
}
m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString);
m_connection = new MySqlConnection(m_connectionString); m_connection = new MySqlConnection(m_connectionString);
m_connection.Open(); m_connection.Open();

View File

@ -59,9 +59,32 @@ namespace OpenSim.Data.MySQL
public void Initialise(string connectionString) public void Initialise(string connectionString)
{ {
m_connectionString = connectionString; m_connectionString = connectionString;
int passPosition = 0;
int passEndPosition = 0;
string displayConnectionString = null;
try
{ // hide the password in the connection string
passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase);
passPosition = m_connectionString.IndexOf("=", passPosition);
if (passPosition < m_connectionString.Length)
passPosition += 1;
passEndPosition = m_connectionString.IndexOf(";", passPosition);
displayConnectionString = m_connectionString.Substring(0, passPosition);
displayConnectionString += "***";
displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition);
}
catch (Exception e)
{
m_log.Debug("Exception: password not found in connection string\n" + e.ToString());
}
m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString);
m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString);
m_connection = new MySqlConnection(m_connectionString); m_connection = new MySqlConnection(m_connectionString);
m_connection.Open(); m_connection.Open();