summaryrefslogtreecommitdiffstats
path: root/src/Daemon/MiddleWare.cpp
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-11-06 15:11:55 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-11-06 15:11:55 +0100
commit3a62ede25114452938acb8e1a67006633b139efc (patch)
treed3a291e5dac5d7ddf14bae4a097ff5b298b71aa5 /src/Daemon/MiddleWare.cpp
parentfc571a9ac7aaa8802d3e8aacf9aefac12ca3c81c (diff)
parent80975b02ec1a2e8dfc6f7ce21e47cf71b16b5a6e (diff)
downloadabrt-3a62ede25114452938acb8e1a67006633b139efc.tar.gz
abrt-3a62ede25114452938acb8e1a67006633b139efc.tar.xz
abrt-3a62ede25114452938acb8e1a67006633b139efc.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src/Daemon/MiddleWare.cpp')
-rw-r--r--src/Daemon/MiddleWare.cpp167
1 files changed, 84 insertions, 83 deletions
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index e30a004..abf1381 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -20,6 +20,7 @@
*/
#include "abrtlib.h"
+#include "abrt_types.h"
#include "Daemon.h"
#include "Settings.h"
#include "RPM.h"
@@ -60,7 +61,7 @@ static map_analyzer_actions_and_reporters_t s_mapAnalyzerActionsAndReporters;
static vector_pair_string_string_t s_vectorActionsAndReporters;
-static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir);
+static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir);
/**
@@ -69,7 +70,7 @@ static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string&
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @param pCrashReport A created crash report.
*/
-static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_report_t& pCrashReport)
+static void DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_report_t& pCrashReport)
{
std::string fileName;
std::string content;
@@ -98,7 +99,8 @@ static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_r
fileName,
CD_BIN,
CD_ISNOTEDITABLE,
- pDebugDumpDir + "/" + fileName);
+ concat_path_file(pDebugDumpDir, fileName.c_str())
+ );
}
else
{
@@ -137,8 +139,8 @@ static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_r
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @return A local UUID.
*/
-static std::string GetLocalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir)
+static std::string GetLocalUUID(const char *pAnalyzer,
+ const char *pDebugDumpDir)
{
CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(pAnalyzer);
return analyzer->GetLocalUUID(pDebugDumpDir);
@@ -150,8 +152,8 @@ static std::string GetLocalUUID(const std::string& pAnalyzer,
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @return A global UUID.
*/
-static std::string GetGlobalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir)
+static std::string GetGlobalUUID(const char *pAnalyzer,
+ const char *pDebugDumpDir)
{
CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(pAnalyzer);
return analyzer->GetGlobalUUID(pDebugDumpDir);
@@ -164,32 +166,32 @@ static std::string GetGlobalUUID(const std::string& pAnalyzer,
* @param pAnalyzer A name of an analyzer plugin.
* @param pDebugDumpPath A debugdump dir containing all necessary data.
*/
-static void CreateReport(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir,
+static void CreateReport(const char *pAnalyzer,
+ const char *pDebugDumpDir,
int force)
{
CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(pAnalyzer);
analyzer->CreateReport(pDebugDumpDir, force);
}
-mw_result_t CreateCrashReport(const std::string& pUUID,
- const std::string& pUID,
+mw_result_t CreateCrashReport(const char *pUUID,
+ const char *pUID,
int force,
map_crash_report_t& pCrashReport)
{
- VERB2 log("CreateCrashReport('%s','%s',result)", pUUID.c_str(), pUID.c_str());
+ VERB2 log("CreateCrashReport('%s','%s',result)", pUUID, pUID);
database_row_t row;
- if (pUUID != "")
+ if (pUUID[0] != '\0')
{
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
database->Connect();
row = database->GetUUIDData(pUUID, pUID);
database->DisConnect();
}
- if (pUUID == "" || row.m_sUUID != pUUID)
+ if (pUUID[0] == '\0' || row.m_sUUID != pUUID)
{
- warn_client("CreateCrashReport(): UUID '"+pUUID+"' is not in database");
+ warn_client(ssprintf("CreateCrashReport(): UUID '%s' is not in database", pUUID));
return MW_IN_DB_ERROR;
}
@@ -202,7 +204,7 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
std::string reproduce = "1.\n2.\n3.\n";
VERB3 log(" LoadText(FILENAME_ANALYZER,'%s')", row.m_sDebugDumpDir.c_str());
- dd.Open(row.m_sDebugDumpDir);
+ dd.Open(row.m_sDebugDumpDir.c_str());
dd.LoadText(FILENAME_ANALYZER, analyzer);
if (dd.Exist(FILENAME_COMMENT))
{
@@ -215,15 +217,15 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
dd.Close();
VERB3 log(" CreateReport('%s')", analyzer.c_str());
- CreateReport(analyzer, row.m_sDebugDumpDir, force);
+ CreateReport(analyzer.c_str(), row.m_sDebugDumpDir.c_str(), force);
- gUUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir);
+ gUUID = GetGlobalUUID(analyzer.c_str(), row.m_sDebugDumpDir.c_str());
VERB3 log(" GetGlobalUUID:'%s'", gUUID.c_str());
VERB3 log(" RunAnalyzerActions");
- RunAnalyzerActions(analyzer, row.m_sDebugDumpDir);
+ RunAnalyzerActions(analyzer.c_str(), row.m_sDebugDumpDir.c_str());
VERB3 log(" DebugDumpToCrashReport");
- DebugDumpToCrashReport(row.m_sDebugDumpDir, pCrashReport);
+ DebugDumpToCrashReport(row.m_sDebugDumpDir.c_str(), pCrashReport);
add_crash_data_to_crash_report(pCrashReport, CD_UUID, CD_TXT, CD_ISNOTEDITABLE, gUUID);
add_crash_data_to_crash_report(pCrashReport, CD_MWANALYZER, CD_SYS, CD_ISNOTEDITABLE, analyzer);
@@ -239,11 +241,11 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
{
return MW_ERROR;
}
- else if (e.type() == EXCEP_DD_LOAD)
+ if (e.type() == EXCEP_DD_LOAD)
{
return MW_FILE_ERROR;
}
- else if (e.type() == EXCEP_PLUGIN)
+ if (e.type() == EXCEP_PLUGIN)
{
return MW_PLUGIN_ERROR;
}
@@ -253,24 +255,23 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
return MW_OK;
}
-void RunAction(const std::string& pActionDir,
- const std::string& pPluginName,
- const std::string& pPluginArgs)
+void RunAction(const char *pActionDir,
+ const char *pPluginName,
+ const char *pPluginArgs)
{
try
{
CAction* action = g_pPluginManager->GetAction(pPluginName);
-
action->Run(pActionDir, pPluginArgs);
}
catch (CABRTException& e)
{
- warn_client("RunAction(): " + e.what());
- update_client("Execution of '"+pPluginName+"' was not successful: " + e.what());
+ warn_client(ssprintf("RunAction(): %s", e.what().c_str()));
+ update_client(ssprintf("Execution of '%s' was not successful: %s", pPluginName, e.what().c_str()));
}
}
-void RunActionsAndReporters(const std::string& pDebugDumpDir)
+void RunActionsAndReporters(const char *pDebugDumpDir)
{
vector_pair_string_string_t::iterator it_ar = s_vectorActionsAndReporters.begin();
map_plugin_settings_t plugin_settings;
@@ -278,24 +279,24 @@ void RunActionsAndReporters(const std::string& pDebugDumpDir)
{
try
{
- if (g_pPluginManager->GetPluginType((*it_ar).first) == REPORTER)
+ if (g_pPluginManager->GetPluginType(it_ar->first) == REPORTER)
{
- CReporter* reporter = g_pPluginManager->GetReporter((*it_ar).first);
+ CReporter* reporter = g_pPluginManager->GetReporter(it_ar->first);
map_crash_report_t crashReport;
DebugDumpToCrashReport(pDebugDumpDir, crashReport);
- reporter->Report(crashReport, plugin_settings, (*it_ar).second);
+ reporter->Report(crashReport, plugin_settings, it_ar->second);
}
- else if (g_pPluginManager->GetPluginType((*it_ar).first) == ACTION)
+ else if (g_pPluginManager->GetPluginType(it_ar->first) == ACTION)
{
- CAction* action = g_pPluginManager->GetAction((*it_ar).first);
- action->Run(pDebugDumpDir, (*it_ar).second);
+ CAction* action = g_pPluginManager->GetAction(it_ar->first);
+ action->Run(pDebugDumpDir, it_ar->second.c_str());
}
}
catch (CABRTException& e)
{
warn_client("RunActionsAndReporters(): " + e.what());
- update_client("Activation of plugin '"+(*it_ar).first+"' was not successful: " + e.what());
+ update_client("Activation of plugin '" + it_ar->first + "' was not successful: " + e.what());
}
}
}
@@ -315,11 +316,11 @@ static bool CheckReport(const map_crash_report_t& pCrashReport)
map_crash_report_t::const_iterator it_executable = pCrashReport.find(FILENAME_EXECUTABLE);
map_crash_report_t::const_iterator end = pCrashReport.end();
-
+
// FIXME: bypass the test if it's kerneloops
- if(it_package->second[CD_CONTENT] == "kernel")
+ if (it_package->second[CD_CONTENT] == "kernel")
return true;
-
+
if (it_analyzer == end || it_mwuid == end ||
it_mwuuid == end || it_package == end ||
it_architecture == end || it_kernel == end ||
@@ -343,7 +344,7 @@ static bool CheckReport(const map_crash_report_t& pCrashReport)
report_status_t Report(const map_crash_report_t& pCrashReport,
map_map_string_t& pSettings,
- const std::string& pUID)
+ const char *pUID)
{
report_status_t ret;
@@ -361,18 +362,18 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
// Save comments and how to reproduciton
map_crash_report_t::const_iterator it_comment = pCrashReport.find(CD_COMMENT);
map_crash_report_t::const_iterator it_reproduce = pCrashReport.find(CD_REPRODUCE);
- std::string pDumpDir = getDebugDumpDir(UUID,UID);
+ std::string pDumpDir = getDebugDumpDir(UUID.c_str(), UID.c_str());
{
CDebugDump dd;
- dd.Open(pDumpDir);
+ dd.Open(pDumpDir.c_str());
if (it_comment != pCrashReport.end())
{
- dd.SaveText(FILENAME_COMMENT, it_comment->second[CD_CONTENT]);
+ dd.SaveText(FILENAME_COMMENT, it_comment->second[CD_CONTENT].c_str());
}
if (it_reproduce != pCrashReport.end())
{
- dd.SaveText(FILENAME_REPRODUCE, it_reproduce->second[CD_CONTENT]);
+ dd.SaveText(FILENAME_REPRODUCE, it_reproduce->second[CD_CONTENT].c_str());
}
}
@@ -448,15 +449,15 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
return ret;
}
-void DeleteDebugDumpDir(const std::string& pDebugDumpDir)
+void DeleteDebugDumpDir(const char *pDebugDumpDir)
{
CDebugDump dd;
dd.Open(pDebugDumpDir);
dd.Delete();
}
-std::string DeleteCrashInfo(const std::string& pUUID,
- const std::string& pUID)
+std::string DeleteCrashInfo(const char *pUUID,
+ const char *pUID)
{
database_row_t row;
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
@@ -476,8 +477,8 @@ std::string DeleteCrashInfo(const std::string& pUUID,
* @return It returns true if debugdump dir is already saved, otherwise
* it returns false.
*/
-static bool IsDebugDumpSaved(const std::string& pUID,
- const std::string& pDebugDumpDir)
+static bool IsDebugDumpSaved(const char *pUID,
+ const char *pDebugDumpDir)
{
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
database->Connect();
@@ -511,19 +512,19 @@ void LoadOpenGPGPublicKey(const char* key)
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @return It return results of operation. See mw_result_t.
*/
-static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecutable,
- const std::string& pDebugDumpDir)
+static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable,
+ const char *pDebugDumpDir)
{
std::string package;
std::string packageName;
- if (pExecutable == "kernel")
+ if (strcmp(pExecutable, "kernel") == 0)
{
packageName = package = "kernel";
}
else
{
- package = GetPackage(pExecutable.c_str());
+ package = GetPackage(pExecutable);
packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1));
if (packageName == "" ||
(g_setBlackList.find(packageName) != g_setBlackList.end()))
@@ -543,7 +544,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta
error_msg("package isn't signed with proper key");
return MW_GPG_ERROR;
}
- if (!CheckHash(packageName.c_str(), pExecutable.c_str()))
+ if (!CheckHash(packageName.c_str(), pExecutable))
{
error_msg("executable has bad hash");
return MW_GPG_ERROR;
@@ -552,15 +553,15 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta
}
std::string description = GetDescription(packageName.c_str());
- std::string component = GetComponent(pExecutable.c_str());
+ std::string component = GetComponent(pExecutable);
try
{
CDebugDump dd;
dd.Open(pDebugDumpDir);
- dd.SaveText(FILENAME_PACKAGE, package);
- dd.SaveText(FILENAME_DESCRIPTION, description);
- dd.SaveText(FILENAME_COMPONENT, component);
+ dd.SaveText(FILENAME_PACKAGE, package.c_str());
+ dd.SaveText(FILENAME_DESCRIPTION, description.c_str());
+ dd.SaveText(FILENAME_COMPONENT, component.c_str());
}
catch (CABRTException& e)
{
@@ -581,7 +582,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta
* @param pAnalyzer A name of an analyzer plugin.
* @param pDebugDumpPath A debugdump dir containing all necessary data.
*/
-static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir)
+static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir)
{
map_analyzer_actions_and_reporters_t::iterator analyzer = s_mapAnalyzerActionsAndReporters.find(pAnalyzer);
if (analyzer != s_mapAnalyzerActionsAndReporters.end())
@@ -595,7 +596,7 @@ static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string&
if (g_pPluginManager->GetPluginType(pluginName) == ACTION)
{
CAction* action = g_pPluginManager->GetAction(pluginName);
- action->Run(pDebugDumpDir, it_a->second);
+ action->Run(pDebugDumpDir, it_a->second.c_str());
}
}
catch (CABRTException& e)
@@ -618,10 +619,10 @@ static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string&
* @param pCrashInfo A filled crash info.
* @return It return results of operation. See mw_result_t.
*/
-static mw_result_t SaveDebugDumpToDatabase(const std::string& pUUID,
- const std::string& pUID,
- const std::string& pTime,
- const std::string& pDebugDumpDir,
+static mw_result_t SaveDebugDumpToDatabase(const char *pUUID,
+ const char *pUID,
+ const char *pTime,
+ const char *pDebugDumpDir,
map_crash_info_t& pCrashInfo)
{
mw_result_t res;
@@ -645,8 +646,8 @@ static mw_result_t SaveDebugDumpToDatabase(const std::string& pUUID,
return res;
}
-std::string getDebugDumpDir( const std::string& pUUID,
- const std::string& pUID)
+std::string getDebugDumpDir(const char *pUUID,
+ const char *pUID)
{
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
database_row_t row;
@@ -656,13 +657,13 @@ std::string getDebugDumpDir( const std::string& pUUID,
return row.m_sDebugDumpDir;
}
-mw_result_t SaveDebugDump(const std::string& pDebugDumpDir)
+mw_result_t SaveDebugDump(const char *pDebugDumpDir)
{
map_crash_info_t info;
return SaveDebugDump(pDebugDumpDir, info);
}
-mw_result_t SaveDebugDump(const std::string& pDebugDumpDir,
+mw_result_t SaveDebugDump(const char *pDebugDumpDir,
map_crash_info_t& pCrashInfo)
{
std::string lUUID;
@@ -691,23 +692,23 @@ mw_result_t SaveDebugDump(const std::string& pDebugDumpDir,
return MW_ERROR;
}
- if (IsDebugDumpSaved(UID, pDebugDumpDir))
+ if (IsDebugDumpSaved(UID.c_str(), pDebugDumpDir))
{
return MW_IN_DB;
}
- res = SavePackageDescriptionToDebugDump(executable, pDebugDumpDir);
+ res = SavePackageDescriptionToDebugDump(executable.c_str(), pDebugDumpDir);
if (res != MW_OK)
{
return res;
}
- lUUID = GetLocalUUID(analyzer, pDebugDumpDir);
+ lUUID = GetLocalUUID(analyzer.c_str(), pDebugDumpDir);
- return SaveDebugDumpToDatabase(lUUID, UID, time, pDebugDumpDir, pCrashInfo);
+ return SaveDebugDumpToDatabase(lUUID.c_str(), UID.c_str(), time.c_str(), pDebugDumpDir, pCrashInfo);
}
-mw_result_t GetCrashInfo(const std::string& pUUID,
- const std::string& pUID,
+mw_result_t GetCrashInfo(const char *pUUID,
+ const char *pUID,
map_crash_info_t& pCrashInfo)
{
pCrashInfo.clear();
@@ -725,7 +726,7 @@ mw_result_t GetCrashInfo(const std::string& pUUID,
try
{
CDebugDump dd;
- dd.Open(row.m_sDebugDumpDir);
+ dd.Open(row.m_sDebugDumpDir.c_str());
dd.LoadText(FILENAME_EXECUTABLE, executable);
dd.LoadText(FILENAME_PACKAGE, package);
dd.LoadText(FILENAME_DESCRIPTION, description);
@@ -755,7 +756,7 @@ mw_result_t GetCrashInfo(const std::string& pUUID,
return MW_OK;
}
-vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID)
+vector_pair_string_string_t GetUUIDsOfCrash(const char *pUID)
{
CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
vector_database_rows_t rows;
@@ -773,15 +774,15 @@ vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID)
return UUIDsUIDs;
}
-void AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
- const std::string& pAnalyzerOrReporter,
- const std::string& pArgs)
+void AddAnalyzerActionOrReporter(const char *pAnalyzer,
+ const char *pAnalyzerOrReporter,
+ const char *pArgs)
{
- s_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs));
+ s_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(std::string(pAnalyzerOrReporter), std::string(pArgs)));
}
-void AddActionOrReporter(const std::string& pActionOrReporter,
- const std::string& pArgs)
+void AddActionOrReporter(const char *pActionOrReporter,
+ const char *pArgs)
{
- s_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs));
+ s_vectorActionsAndReporters.push_back(make_pair(std::string(pActionOrReporter), std::string(pArgs)));
}