1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Merge branch 'develop-1.1' into DataRedundancy-MCOLs

This commit is contained in:
benthompson15
2017-10-26 09:03:19 -05:00
committed by GitHub
29 changed files with 593 additions and 413 deletions

View File

@ -8768,22 +8768,10 @@ namespace oam
* purpose: check and get mysql user password
*
******************************************************************************************/
std::string Oam::getMySQLPassword(bool bypassConfig)
std::string Oam::getMySQLPassword()
{
if ( !bypassConfig )
{
string MySQLPasswordConfig;
try {
getSystemConfig("MySQLPasswordConfig", MySQLPasswordConfig);
}
catch(...) {
MySQLPasswordConfig = "n";
}
string mysqlUser = "root";
if ( MySQLPasswordConfig == "n" )
return oam::UnassignedName;
}
string USER = "root";
char* p= getenv("USER");
if (p && *p)
@ -8796,10 +8784,15 @@ namespace oam
string fileName = HOME + "/.my.cnf";
writeLog("getMySQLPassword: checking: " + fileName, LOG_TYPE_DEBUG);
ifstream file (fileName.c_str());
if (!file)
{
writeLog("getMySQLPassword: doesn't exist: " + fileName, LOG_TYPE_DEBUG);
exceptionControl("getMySQLPassword", API_FILE_OPEN_ERROR);
}
char line[400];
string buf;
@ -8807,8 +8800,8 @@ namespace oam
while (file.getline(line, 400))
{
buf = line;
string::size_type pos = buf.find(USER,0);
string::size_type pos = buf.find(mysqlUser,0);
if (pos != string::npos)
{
file.getline(line, 400);
@ -8820,24 +8813,23 @@ namespace oam
string::size_type pos1 = buf.find("=",pos);
if (pos1 != string::npos) {
//password found
if ( bypassConfig )
{
try {
setSystemConfig("MySQLPasswordConfig", "y");
}
catch(...) {}
}
string password = buf.substr(pos1+2, 80);
string password = buf.substr(pos1+1, 80);
password.erase(remove_if(password.begin(), password.end(), ::isspace), password.end());
writeLog("getMySQLPassword: password found", LOG_TYPE_DEBUG);
return password;
}
}
break;
}
}
file.close();
writeLog("getMySQLPassword: no password found", LOG_TYPE_DEBUG);
exceptionControl("getMySQLPassword", API_FAILURE);
return oam::UnassignedName;
}