summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/MiddleWare/MiddleWare.cpp20
-rw-r--r--lib/MiddleWare/MiddleWare.h15
-rw-r--r--lib/MiddleWare/Plugin.h2
-rw-r--r--lib/MiddleWare/PluginManager.cpp154
-rw-r--r--lib/MiddleWare/Reporter.h4
-rw-r--r--lib/Plugins/Bugzilla.cpp2
-rw-r--r--lib/Plugins/Bugzilla.h3
-rw-r--r--lib/Plugins/CCpp.h12
-rw-r--r--lib/Plugins/Kerneloops.h10
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp2
-rw-r--r--lib/Plugins/KerneloopsReporter.h4
-rw-r--r--lib/Plugins/Logger.cpp2
-rw-r--r--lib/Plugins/Logger.h4
-rw-r--r--lib/Plugins/Mailx.conf3
-rw-r--r--lib/Plugins/Mailx.cpp21
-rw-r--r--lib/Plugins/Mailx.h9
-rw-r--r--lib/Plugins/PluginSettings.h15
-rw-r--r--lib/Plugins/SQLite3.h22
-rw-r--r--src/Daemon/CrashWatcher.cpp12
-rw-r--r--src/Daemon/Settings.cpp64
-rw-r--r--src/Daemon/Settings.h14
-rw-r--r--src/Daemon/abrt.conf18
22 files changed, 224 insertions, 188 deletions
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
index e1e679a8..bc8e9de9 100644
--- a/lib/MiddleWare/MiddleWare.cpp
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -182,8 +182,8 @@ void CMiddleWare::Report(const std::string& pDebugDumpDir)
set_reporters_t::iterator it_r;
for (it_r = m_setReporters.begin(); it_r != m_setReporters.end(); it_r++)
{
- CReporter* reporter = m_pPluginManager->GetReporter(*it_r);
- reporter->Report(crashReport);
+ CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first);
+ reporter->Report(crashReport, (*it_r).second);
}
}
@@ -206,8 +206,8 @@ void CMiddleWare::Report(const map_crash_report_t& pCrashReport)
it_r != m_mapAnalyzerReporters[analyzer].end();
it_r++)
{
- CReporter* reporter = m_pPluginManager->GetReporter(*it_r);
- reporter->Report(pCrashReport);
+ CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first);
+ reporter->Report(pCrashReport, (*it_r).second);
}
}
@@ -337,7 +337,7 @@ void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::st
{
if (m_mapAnalyzerActions.find(pAnalyzer) != m_mapAnalyzerActions.end())
{
- set_actions_t::iterator it_a;
+ set_pairt_strings_t::iterator it_a;
for (it_a = m_mapAnalyzerActions[pAnalyzer].begin();
it_a != m_mapAnalyzerActions[pAnalyzer].end();
it_a++)
@@ -491,9 +491,10 @@ void CMiddleWare::AddBlackListedPackage(const std::string& pPackage)
}
void CMiddleWare::AddAnalyzerReporter(const std::string& pAnalyzer,
- const std::string& pReporter)
+ const std::string& pReporter,
+ const std::string& pArgs)
{
- m_mapAnalyzerReporters[pAnalyzer].insert(pReporter);
+ m_mapAnalyzerReporters[pAnalyzer].insert(make_pair(pReporter, pArgs));
}
void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer,
@@ -503,7 +504,8 @@ void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer,
m_mapAnalyzerActions[pAnalyzer].insert(make_pair(pAction, pArgs));
}
-void CMiddleWare::AddReporter(const std::string& pReporter)
+void CMiddleWare::AddReporter(const std::string& pReporter,
+ const std::string& pArgs)
{
- m_setReporters.insert(pReporter);
+ m_setReporters.insert(make_pair(pReporter, pArgs));
}
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index 28afb2a5..4ec3df3a 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -34,10 +34,11 @@ class CMiddleWare
private:
typedef set_strings_t set_blacklist_t;
typedef set_strings_t set_enabled_plugins_t;
- typedef set_strings_t set_reporters_t;
- typedef std::map<std::string, set_reporters_t> map_reporter_associations_t;
- typedef std::set<pair_string_string_t> set_actions_t;
- typedef std::map<std::string, set_actions_t> map_action_associations_t;
+
+ typedef std::set<pair_string_string_t> set_pairt_strings_t;
+ typedef std::map<std::string, set_pairt_strings_t> map_reporter_associations_t;
+ typedef std::map<std::string, set_pairt_strings_t> map_action_associations_t;
+ typedef set_pairt_strings_t set_reporters_t;
CPluginManager* m_pPluginManager;
CRPM m_RPM;
@@ -98,11 +99,13 @@ class CMiddleWare
void AddOpenGPGPublicKey(const std::string& pKey);
void AddBlackListedPackage(const std::string& pPackage);
void AddAnalyzerReporter(const std::string& pAnalyzer,
- const std::string& pReporter);
+ const std::string& pReporter,
+ const std::string& pArgs);
void AddAnalyzerAction(const std::string& pAnalyzer,
const std::string& pAction,
const std::string& pArgs);
- void AddReporter(const std::string& pReporter);
+ void AddReporter(const std::string& pReporter,
+ const std::string& pArgs);
};
#endif /*MIDDLEWARE_H_*/
diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h
index e4ebc3cb..9fd59291 100644
--- a/lib/MiddleWare/Plugin.h
+++ b/lib/MiddleWare/Plugin.h
@@ -26,7 +26,7 @@
#include <string>
#include <map>
-#define PLUGINS_MAGIC_NUMBER 1
+#define PLUGINS_MAGIC_NUMBER 2
#define PLUGINS_CONF_EXTENSION "conf"
#define PLUGINS_LIB_EXTENSION "so"
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp
index 2f103f26..cbdd2c1f 100644
--- a/lib/MiddleWare/PluginManager.cpp
+++ b/lib/MiddleWare/PluginManager.cpp
@@ -27,8 +27,8 @@
CPluginManager::CPluginManager(const std::string& pPlugisConfDir,
const std::string& pPlugisLibDir) :
- m_sPlugisConfDir(pPlugisConfDir),
- m_sPlugisLibDir(pPlugisLibDir)
+ m_sPlugisConfDir(pPlugisConfDir),
+ m_sPlugisLibDir(pPlugisLibDir)
{}
CPluginManager::~CPluginManager()
@@ -36,26 +36,26 @@ CPluginManager::~CPluginManager()
void CPluginManager::LoadPlugins()
{
- DIR *dir = opendir(m_sPlugisLibDir.c_str());
- struct dirent *dent = NULL;
- if (dir != NULL)
- {
- while ((dent = readdir(dir)) != NULL)
- {
- if (dent->d_type == DT_REG)
- {
- std::string name = dent->d_name;
- std::string extension = name.substr(name.length()-sizeof(PLUGINS_LIB_EXTENSION)+1);
- if (extension == PLUGINS_LIB_EXTENSION)
- {
- name.erase(0, sizeof(PLUGINS_LIB_PREFIX) - 1);
- name.erase(name.length() - sizeof(PLUGINS_LIB_EXTENSION));
- LoadPlugin(name);
- }
- }
- }
- closedir(dir);
- }
+ DIR *dir = opendir(m_sPlugisLibDir.c_str());
+ struct dirent *dent = NULL;
+ if (dir != NULL)
+ {
+ while ((dent = readdir(dir)) != NULL)
+ {
+ if (dent->d_type == DT_REG)
+ {
+ std::string name = dent->d_name;
+ std::string extension = name.substr(name.length()-sizeof(PLUGINS_LIB_EXTENSION)+1);
+ if (extension == PLUGINS_LIB_EXTENSION)
+ {
+ name.erase(0, sizeof(PLUGINS_LIB_PREFIX) - 1);
+ name.erase(name.length() - sizeof(PLUGINS_LIB_EXTENSION));
+ LoadPlugin(name);
+ }
+ }
+ }
+ closedir(dir);
+ }
}
void CPluginManager::UnLoadPlugins()
@@ -70,41 +70,41 @@ void CPluginManager::UnLoadPlugins()
void CPluginManager::LoadPlugin(const std::string& pName)
{
- if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end())
- {
- CABRTPlugin* abrtPlugin = NULL;
- try
- {
- std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION;
- abrtPlugin = new CABRTPlugin(libPath);
- if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER ||
- (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE))
- {
- throw std::string("non-compatible plugin");
- }
- std::cerr << "Plugin " << pName << " (" << abrtPlugin->GetVersion() << ") " << "succesfully loaded." << std::endl;
- m_mapABRTPlugins[pName] = abrtPlugin;
- }
- catch (std::string sError)
- {
- if (abrtPlugin != NULL)
- {
- delete abrtPlugin;
- }
- std::cerr << "Failed to load plugin " << pName << " (" << sError << ")." << std::endl;
- }
- }
+ if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end())
+ {
+ CABRTPlugin* abrtPlugin = NULL;
+ try
+ {
+ std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION;
+ abrtPlugin = new CABRTPlugin(libPath);
+ if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER ||
+ (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE))
+ {
+ throw std::string("non-compatible plugin");
+ }
+ std::cerr << "Plugin " << pName << " (" << abrtPlugin->GetVersion() << ") " << "succesfully loaded." << std::endl;
+ m_mapABRTPlugins[pName] = abrtPlugin;
+ }
+ catch (std::string sError)
+ {
+ if (abrtPlugin != NULL)
+ {
+ delete abrtPlugin;
+ }
+ std::cerr << "Failed to load plugin " << pName << " (" << sError << ")." << std::endl;
+ }
+ }
}
void CPluginManager::UnLoadPlugin(const std::string& pName)
{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
- {
- UnRegisterPlugin(pName);
- delete m_mapABRTPlugins[pName];
- m_mapABRTPlugins.erase(pName);
- std::cerr << "Plugin " << pName << " sucessfully unloaded." << std::endl;
- }
+ if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ {
+ UnRegisterPlugin(pName);
+ delete m_mapABRTPlugins[pName];
+ m_mapABRTPlugins.erase(pName);
+ std::cerr << "Plugin " << pName << " sucessfully unloaded." << std::endl;
+ }
}
@@ -155,41 +155,41 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName)
CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw std::string("CPluginManager::GetAnalyzer():"
- "Analyzer plugin: '"+pName+"' is not loaded.");
- }
- return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]);
+ if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ {
+ throw std::string("CPluginManager::GetAnalyzer():"
+ "Analyzer plugin: '"+pName+"' is not loaded.");
+ }
+ return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]);
}
CReporter* CPluginManager::GetReporter(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw std::string("CPluginManager::GetReporter():"
- "Reporter plugin: '"+pName+"' is not loaded.");
- }
- return dynamic_cast<CReporter*>(m_mapPlugins[pName]);
+ if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ {
+ throw std::string("CPluginManager::GetReporter():"
+ "Reporter plugin: '"+pName+"' is not loaded.");
+ }
+ return dynamic_cast<CReporter*>(m_mapPlugins[pName]);
}
CAction* CPluginManager::GetAction(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw std::string("CPluginManager::GetAction():"
- "Action plugin: '"+pName+"' is not loaded.");
- }
- return dynamic_cast<CAction*>(m_mapPlugins[pName]);
+ if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ {
+ throw std::string("CPluginManager::GetAction():"
+ "Action plugin: '"+pName+"' is not loaded.");
+ }
+ return dynamic_cast<CAction*>(m_mapPlugins[pName]);
}
CDatabase* CPluginManager::GetDatabase(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw std::string("CPluginManager::GetDatabase():"
- "Database plugin: '"+pName+"' is not loaded.");
- }
- return dynamic_cast<CDatabase*>(m_mapPlugins[pName]);
+ if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ {
+ throw std::string("CPluginManager::GetDatabase():"
+ "Database plugin: '"+pName+"' is not loaded.");
+ }
+ return dynamic_cast<CDatabase*>(m_mapPlugins[pName]);
}
diff --git a/lib/MiddleWare/Reporter.h b/lib/MiddleWare/Reporter.h
index 02fae123..76680df7 100644
--- a/lib/MiddleWare/Reporter.h
+++ b/lib/MiddleWare/Reporter.h
@@ -29,9 +29,9 @@
class CReporter : public CPlugin
{
public:
-
virtual ~CReporter() {}
- virtual void Report(const map_crash_report_t& pCrashReport) = 0;
+ virtual void Report(const map_crash_report_t& pCrashReport,
+ const std::string& pArgs) = 0;
};
#endif /* REPORTER_H_ */
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index 2a1c1bb5..b4f44b04 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -162,7 +162,7 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport)
}
-void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport)
+void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs)
{
std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT];
std::string component = package.substr(0, package.rfind("-", package.rfind("-")-1));
diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h
index ff6d5510..075484af 100644
--- a/lib/Plugins/Bugzilla.h
+++ b/lib/Plugins/Bugzilla.h
@@ -31,7 +31,8 @@ class CReporterBugzilla : public CReporter
CReporterBugzilla();
virtual ~CReporterBugzilla();
virtual void LoadSettings(const std::string& pPath);
- virtual void Report(const map_crash_report_t& pCrashReport);
+ virtual void Report(const map_crash_report_t& pCrashReport,
+ const std::string& pArgs);
};
PLUGIN_INFO(REPORTER,
diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h
index 1011b707..222bcbff 100644
--- a/lib/Plugins/CCpp.h
+++ b/lib/Plugins/CCpp.h
@@ -42,12 +42,12 @@ class CAnalyzerCCpp : public CAnalyzer
public:
CAnalyzerCCpp();
virtual ~CAnalyzerCCpp();
- std::string GetLocalUUID(const std::string& pDebugDumpDir);
- std::string GetGlobalUUID(const std::string& pDebugDumpDir);
- void CreateReport(const std::string& pDebugDumpDir);
- void Init();
- void DeInit();
- void LoadSettings(const std::string& pPath);
+ virtual std::string GetLocalUUID(const std::string& pDebugDumpDir);
+ virtual std::string GetGlobalUUID(const std::string& pDebugDumpDir);
+ virtual void CreateReport(const std::string& pDebugDumpDir);
+ virtual void Init();
+ virtual void DeInit();
+ virtual void LoadSettings(const std::string& pPath);
};
diff --git a/lib/Plugins/Kerneloops.h b/lib/Plugins/Kerneloops.h
index 0eccb080..2fa9026b 100644
--- a/lib/Plugins/Kerneloops.h
+++ b/lib/Plugins/Kerneloops.h
@@ -45,11 +45,11 @@ class CAnalyzerKerneloops : public CAnalyzer
public:
CAnalyzerKerneloops();
virtual ~CAnalyzerKerneloops() {}
- std::string GetLocalUUID(const std::string& pDebugDumpDir);
- std::string GetGlobalUUID(const std::string& pDebugDumpDir);
- void Init();
- void CreateReport(const std::string& pDebugDumpDir) {}
- void LoadSettings(const std::string& pPath);
+ virtual std::string GetLocalUUID(const std::string& pDebugDumpDir);
+ virtual std::string GetGlobalUUID(const std::string& pDebugDumpDir);
+ virtual void Init();
+ virtual void CreateReport(const std::string& pDebugDumpDir) {}
+ virtual void LoadSettings(const std::string& pPath);
void ScanDmesg();
void ScanSysLogFile(const char *filename, int issyslog);
};
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index 71219104..15af3ac0 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -57,7 +57,7 @@ size_t writefunction(void *ptr, size_t size, size_t nmemb, void __attribute((unu
return size * nmemb;
}
-void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport)
+void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs)
{
CURL *handle;
struct curl_httppost *post = NULL;
diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h
index 7c06d990..dc01b533 100644
--- a/lib/Plugins/KerneloopsReporter.h
+++ b/lib/Plugins/KerneloopsReporter.h
@@ -41,8 +41,8 @@ class CKerneloopsReporter : public CReporter
CKerneloopsReporter();
virtual ~CKerneloopsReporter() {}
- void LoadSettings(const std::string& pPath);
- void Report(const map_crash_report_t& pCrashReport);
+ virtual void LoadSettings(const std::string& pPath);
+ virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs);
};
PLUGIN_INFO(REPORTER,
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
index 8f89838f..d340b2d6 100644
--- a/lib/Plugins/Logger.cpp
+++ b/lib/Plugins/Logger.cpp
@@ -45,7 +45,7 @@ void CLogger::LoadSettings(const std::string& pPath)
}
}
-void CLogger::Report(const map_crash_report_t& pCrashReport)
+void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs)
{
std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile;
std::ofstream fOut;
diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h
index f5db73f3..62b6a1d1 100644
--- a/lib/Plugins/Logger.h
+++ b/lib/Plugins/Logger.h
@@ -35,8 +35,8 @@ class CLogger : public CReporter
CLogger();
virtual ~CLogger() {}
- void LoadSettings(const std::string& pPath);
- void Report(const map_crash_report_t& pCrashReport);
+ virtual void LoadSettings(const std::string& pPath);
+ virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs);
};
diff --git a/lib/Plugins/Mailx.conf b/lib/Plugins/Mailx.conf
index c1bddfff..73f669bb 100644
--- a/lib/Plugins/Mailx.conf
+++ b/lib/Plugins/Mailx.conf
@@ -1,4 +1,7 @@
# Configuration to Email reporter plugin
+# Subject of an emain
+Subject = "[abrt] crash report"
+
# Parameters
Parameters =
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 8aacef3f..b7cdcfe0 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -26,23 +26,23 @@
#include "PluginSettings.h"
#define MAILX_COMMAND "/bin/mailx"
-#define MAILX_SUBJECT "\"abrt automated bug report\""
CMailx::CMailx() :
m_sEmailFrom("user@localhost"),
m_sEmailTo("root@localhost"),
m_sParameters(""),
m_sAttachments(""),
+ m_sSubject("[abrt] full crash report"),
m_bSendBinaryData(false)
{}
-void CMailx::SendEmail(const std::string& pText)
+void CMailx::SendEmail(const std::string& pSubject, const std::string& pText)
{
FILE* command;
std::string mailx_command = MAILX_COMMAND + m_sAttachments +
" " + m_sParameters +
- " -s " + MAILX_SUBJECT +
+ " -s " + pSubject +
" -r " + m_sEmailFrom + " " + m_sEmailTo;
command = popen(mailx_command.c_str(), "w");
@@ -58,7 +58,7 @@ void CMailx::SendEmail(const std::string& pText)
}
-void CMailx::Report(const map_crash_report_t& pCrashReport)
+void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs)
{
std::stringstream emailBody;
std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile;
@@ -118,7 +118,14 @@ void CMailx::Report(const map_crash_report_t& pCrashReport)
m_sAttachments += binaryFiles.str();
}
- SendEmail(emailBody.str());
+ if (pArgs != "")
+ {
+ SendEmail(pArgs, emailBody.str());
+ }
+ else
+ {
+ SendEmail(m_sSubject, emailBody.str());
+ }
}
void CMailx::LoadSettings(const std::string& pPath)
@@ -126,6 +133,10 @@ void CMailx::LoadSettings(const std::string& pPath)
map_settings_t settings;
plugin_load_settings(pPath, settings);
+ if (settings.find("Subject")!= settings.end())
+ {
+ m_sSubject = settings["Subject"];
+ }
if (settings.find("EmailFrom")!= settings.end())
{
m_sEmailFrom = settings["EmailFrom"];
diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h
index 3100a173..2f5c343d 100644
--- a/lib/Plugins/Mailx.h
+++ b/lib/Plugins/Mailx.h
@@ -34,23 +34,24 @@ class CMailx : public CReporter
std::string m_sEmailTo;
std::string m_sParameters;
std::string m_sAttachments;
+ std::string m_sSubject;
bool m_bSendBinaryData;
- void SendEmail(const std::string& pText);
+ void SendEmail(const std::string& pSubject, const std::string& pText);
public:
CMailx();
virtual ~CMailx() {}
- void LoadSettings(const std::string& pPath);
- void Report(const map_crash_report_t& pCrashReport);
+ virtual void LoadSettings(const std::string& pPath);
+ virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs);
};
PLUGIN_INFO(REPORTER,
CMailx,
"Mailx",
- "0.0.1",
+ "0.0.2",
"Sends an email with a report via mailx command",
"zprikryl@redhat.com",
"https://fedorahosted.org/crash-catcher/wiki");
diff --git a/lib/Plugins/PluginSettings.h b/lib/Plugins/PluginSettings.h
index d331b353..92af525e 100644
--- a/lib/Plugins/PluginSettings.h
+++ b/lib/Plugins/PluginSettings.h
@@ -43,23 +43,28 @@ inline void plugin_load_settings(const std::string& path, map_settings_t& settin
int ii;
bool is_value = false;
bool valid = false;
+ bool in_quote = false;
std::string key = "";
std::string value = "";
for (ii = 0; ii < line.length(); ii++)
{
- if (isspace(line[ii]))
+ if (line[ii] == '\"')
+ {
+ in_quote = in_quote == true ? false : true;
+ }
+ if (isspace(line[ii]) && !in_quote)
{
continue;
}
- if (line[ii] == '#')
+ if (line[ii] == '#' && !in_quote)
{
break;
}
- else if (line[ii] == '=')
+ else if (line[ii] == '=' && !in_quote)
{
is_value = true;
}
- else if (line[ii] == '=' && is_value)
+ else if (line[ii] == '=' && is_value && !in_quote)
{
key = "";
value = "";
@@ -75,7 +80,7 @@ inline void plugin_load_settings(const std::string& path, map_settings_t& settin
value += line[ii];
}
}
- if (valid)
+ if (valid && !in_quote)
{
settings[key] = value;
}
diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h
index 055c059f..2280f332 100644
--- a/lib/Plugins/SQLite3.h
+++ b/lib/Plugins/SQLite3.h
@@ -45,20 +45,20 @@ class CSQLite3 : public CDatabase
CSQLite3();
virtual ~CSQLite3() {}
- void Connect();
- void DisConnect();
+ virtual void Connect();
+ virtual void DisConnect();
- void Insert(const std::string& pUUID,
- const std::string& pUID,
- const std::string& pDebugDumpPath,
- const std::string& pTime);
+ virtual void Insert(const std::string& pUUID,
+ const std::string& pUID,
+ const std::string& pDebugDumpPath,
+ const std::string& pTime);
- void Delete(const std::string& pUUID, const std::string& pUID);
- void SetReported(const std::string& pUUID, const std::string& pUID);
- const vector_database_rows_t GetUIDData(const std::string& pUID);
- const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID);
+ virtual void Delete(const std::string& pUUID, const std::string& pUID);
+ virtual void SetReported(const std::string& pUUID, const std::string& pUID);
+ virtual const vector_database_rows_t GetUIDData(const std::string& pUID);
+ virtual const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID);
- void LoadSettings(const std::string& pPath);
+ virtual void LoadSettings(const std::string& pPath);
};
PLUGIN_INFO(DATABASE,
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 7c043c20..48d18dbf 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -132,27 +132,27 @@ void CCrashWatcher::SetUpMW()
{
m_pMW->RegisterPlugin(*it_p);
}
- CSettings::set_strings_t reporters = m_pSettings->GetReporters();
- CSettings::set_strings_t::iterator it_r;
+ CSettings::set_pair_strings_t reporters = m_pSettings->GetReporters();
+ CSettings::set_pair_strings_t::iterator it_r;
for (it_r = reporters.begin(); it_r != reporters.end(); it_r++)
{
- m_pMW->AddReporter(*it_r);
+ m_pMW->AddReporter((*it_r).first, (*it_r).second);
}
CSettings::map_analyzer_reporters_t analyzer_reporters = m_pSettings->GetAnalyzerReporters();
CSettings::map_analyzer_reporters_t::iterator it_pr;
for (it_pr = analyzer_reporters.begin(); it_pr != analyzer_reporters.end(); it_pr++)
{
- CSettings::set_strings_t::iterator it_r;
+ CSettings::set_pair_strings_t::iterator it_r;
for (it_r = it_pr->second.begin(); it_r != it_pr->second.end(); it_r++)
{
- m_pMW->AddAnalyzerReporter(it_pr->first, *it_r);
+ m_pMW->AddAnalyzerReporter(it_pr->first, (*it_r).first, (*it_r).second);
}
}
CSettings::map_analyzer_actions_t analyser_actions = m_pSettings->GetAnalyzerActions();
CSettings::map_analyzer_actions_t::iterator it_pa;
for (it_pa = analyser_actions.begin(); it_pa != analyser_actions.end(); it_pa++)
{
- CSettings::set_actions_t::iterator it_a;
+ CSettings::set_pair_strings_t::iterator it_a;
for (it_a = it_pa->second.begin(); it_a != it_pa->second.end(); it_a++)
{
m_pMW->AddAnalyzerAction(it_pa->first, (*it_a).first, (*it_a).second);
diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp
index 240a6f66..6555e8d5 100644
--- a/src/Daemon/Settings.cpp
+++ b/src/Daemon/Settings.cpp
@@ -3,8 +3,8 @@
#include <stdlib.h>
#define SECTION_COMMON "Common"
-#define SECTION_REPORTERS "Reporters"
-#define SECTION_ACTIONS "Actions"
+#define SECTION_REPORTERS "AnalyzerReporters"
+#define SECTION_ACTIONS "AnalyzerActions"
void CSettings::LoadSettings(const std::string& pPath)
{
@@ -30,11 +30,11 @@ void CSettings::LoadSettings(const std::string& pPath)
{
continue;
}
- else if (line[ii] == '#')
+ else if (line[ii] == '#' && !is_quote)
{
break;
}
- else if (line[ii] == '[')
+ else if (line[ii] == '[' && !is_quote)
{
is_section = true;
section = "";
@@ -52,7 +52,7 @@ void CSettings::LoadSettings(const std::string& pPath)
}
section += line[ii];
}
- else if (line[ii] == '=')
+ else if (line[ii] == '=' && !is_quote)
{
is_key = false;
key = value;
@@ -63,7 +63,7 @@ void CSettings::LoadSettings(const std::string& pPath)
value += line[ii];
}
}
- if (!is_key)
+ if (!is_key && !is_quote)
{
if (section == SECTION_COMMON)
{
@@ -100,13 +100,13 @@ void CSettings::ParseCommon()
{
m_setBlackList = ParseList(m_mapSettingsCommon["BlackList"]);
}
- if (m_mapSettingsCommon.find("EnabledPlugins") != m_mapSettingsCommon.end())
+ if (m_mapSettingsCommon.find("Database") != m_mapSettingsCommon.end())
{
- m_setEnabledPlugins = ParseList(m_mapSettingsCommon["EnabledPlugins"]);
+ m_sDatabase =m_mapSettingsCommon["Database"];
}
- if (m_mapSettingsCommon.find("Database") != m_mapSettingsCommon.end())
+ if (m_mapSettingsCommon.find("EnabledPlugins") != m_mapSettingsCommon.end())
{
- m_sDatabase = m_mapSettingsCommon["Database"];
+ m_setEnabledPlugins = ParseList(m_mapSettingsCommon["EnabledPlugins"]);
}
if (m_mapSettingsCommon.find("MaxCrashReportsSize") != m_mapSettingsCommon.end())
{
@@ -114,7 +114,7 @@ void CSettings::ParseCommon()
}
if (m_mapSettingsCommon.find("Reporters") != m_mapSettingsCommon.end())
{
- m_setReporters = ParseList(m_mapSettingsCommon["Reporters"]);
+ m_setReporters = ParseListWithArgs(m_mapSettingsCommon["Reporters"]);
}
}
@@ -124,7 +124,7 @@ void CSettings::ParseReporters()
map_settings_t::iterator it;
for (it = m_mapSettingsReporters.begin(); it != m_mapSettingsReporters.end(); it++)
{
- m_mapAnalyzerReporters[it->first] = ParseList(it->second);
+ m_mapAnalyzerReporters[it->first] = ParseListWithArgs(it->second);
}
}
@@ -133,8 +133,8 @@ void CSettings::ParseActions()
map_settings_t::iterator it;
for (it = m_mapSettingsActions.begin(); it != m_mapSettingsActions.end(); it++)
{
- set_strings_t keys = ParseActionKey(it->first);
- set_actions_t singleActions = ParseActionValue(it->second);
+ set_strings_t keys = ParseKey(it->first);
+ set_pair_strings_t singleActions = ParseListWithArgs(it->second);
set_strings_t::iterator it_keys;
for (it_keys = keys.begin(); it_keys != keys.end(); it_keys++)
{
@@ -144,9 +144,9 @@ void CSettings::ParseActions()
}
-CSettings::set_actions_t CSettings::ParseActionValue(const std::string& pValue)
+CSettings::set_pair_strings_t CSettings::ParseListWithArgs(const std::string& pValue)
{
- set_actions_t singleActions;
+ set_pair_strings_t pluginArgs;
unsigned int ii;
std::string item = "";
std::string action = "";
@@ -167,7 +167,7 @@ CSettings::set_actions_t CSettings::ParseActionValue(const std::string& pValue)
}
else if (pValue[ii] == ')' && is_arg && !is_quote)
{
- singleActions.insert(make_pair(action, item));
+ pluginArgs.insert(make_pair(action, item));
item = "";
is_arg = false;
action = "";
@@ -176,7 +176,7 @@ CSettings::set_actions_t CSettings::ParseActionValue(const std::string& pValue)
{
if (item != "")
{
- singleActions.insert(make_pair(item, ""));
+ pluginArgs.insert(make_pair(item, ""));
item = "";
}
}
@@ -187,12 +187,12 @@ CSettings::set_actions_t CSettings::ParseActionValue(const std::string& pValue)
}
if (item != "")
{
- singleActions.insert(make_pair(item, ""));
+ pluginArgs.insert(make_pair(item, ""));
}
- return singleActions;
+ return pluginArgs;
}
-CSettings::set_strings_t CSettings::ParseActionKey(const std::string& Key)
+CSettings::set_strings_t CSettings::ParseKey(const std::string& Key)
{
unsigned int ii;
std::string item = "";
@@ -205,12 +205,12 @@ CSettings::set_strings_t CSettings::ParseActionKey(const std::string& Key)
{
is_quote = is_quote == true ? false : true;
}
- else if (Key[ii] == '(' && !is_quote)
+ else if (Key[ii] == ':' && !is_quote)
{
key = item;
item = "";
}
- else if ((Key[ii] == ',' || Key[ii] == ')') && !is_quote)
+ else if ((Key[ii] == ',') && !is_quote)
{
set.insert(key + ":" + item);
item = "";
@@ -222,7 +222,14 @@ CSettings::set_strings_t CSettings::ParseActionKey(const std::string& Key)
}
if (item != "" && !is_quote)
{
- set.insert(item);
+ if (key == "")
+ {
+ set.insert(item);
+ }
+ else
+ {
+ set.insert(key + ":" + item);
+ }
}
return set;
}
@@ -286,11 +293,12 @@ const unsigned int& CSettings::GetMaxCrashReportsSize()
return m_nMaxCrashReportsSize;
}
-const std::string& CSettings::GetDatabase()
+const CSettings::set_pair_strings_t& CSettings::GetReporters()
{
- return m_sDatabase;
+ return m_setReporters;
}
-const CSettings::set_strings_t& CSettings::GetReporters()
+
+const std::string& CSettings::GetDatabase()
{
- return m_setReporters;
+ return m_sDatabase;
}
diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h
index 7a8723af..04a16d77 100644
--- a/src/Daemon/Settings.h
+++ b/src/Daemon/Settings.h
@@ -12,9 +12,9 @@ class CSettings
typedef std::map<std::string, std::string> map_settings_t;
typedef std::set<std::string> set_strings_t;
typedef std::pair<std::string, std::string> pair_string_string_t;
- typedef std::map<std::string, set_strings_t> map_analyzer_reporters_t;
- typedef std::set<pair_string_string_t> set_actions_t;
- typedef std::map<std::string, set_actions_t> map_analyzer_actions_t;
+ typedef std::set<pair_string_string_t> set_pair_strings_t;
+ typedef std::map<std::string, set_pair_strings_t> map_analyzer_reporters_t;
+ typedef std::map<std::string, set_pair_strings_t> map_analyzer_actions_t;
private:
map_settings_t m_mapSettingsCommon;
@@ -24,8 +24,8 @@ class CSettings
set_strings_t m_setOpenGPGPublicKeys;
set_strings_t m_setBlackList;
set_strings_t m_setEnabledPlugins;
- set_strings_t m_setReporters;
std::string m_sDatabase;
+ set_pair_strings_t m_setReporters;
bool m_bOpenGPGCheck;
unsigned int m_nMaxCrashReportsSize;
map_analyzer_reporters_t m_mapAnalyzerReporters;
@@ -35,8 +35,8 @@ class CSettings
void ParseReporters();
void ParseActions();
set_strings_t ParseList(const std::string& pList);
- set_strings_t ParseActionKey(const std::string& pKey);
- set_actions_t ParseActionValue(const std::string& pValue);
+ set_pair_strings_t ParseListWithArgs(const std::string& pList);
+ set_strings_t ParseKey(const std::string& pKey);
public:
void LoadSettings(const std::string& pPath);
@@ -47,8 +47,8 @@ class CSettings
const map_analyzer_reporters_t& GetAnalyzerReporters();
const map_analyzer_actions_t& GetAnalyzerActions();
const unsigned int& GetMaxCrashReportsSize();
+ const set_pair_strings_t& GetReporters();
const std::string& GetDatabase();
- const set_strings_t& GetReporters();
};
#endif
diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf
index 51367db8..ff0e854e 100644
--- a/src/Daemon/abrt.conf
+++ b/src/Daemon/abrt.conf
@@ -7,20 +7,22 @@ EnableOpenGPG = no
# GPG keys
OpenGPGPublicKeys = /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
# blacklisted packages
-BlackList = bash, bind, apache2
+BlackList = bash, bind
# enabled plugins
+# there has to be exactly one database plugin
EnabledPlugins = SQLite3, CCpp, Mailx, Logger, Kerneloops, KerneloopsReporter
-# selected DB plugin
+# Database
Database = SQLite3
-# max size for coredumps storage
+# max size for crash storage
MaxCrashReportsSize = 1000
-# set of reporters which are activated in crash time
-Reporters = Mailx
+# set of reporters which are activated immediately after a crash occurs
+Reporters = Mailx("[abrt] new crash was detected")
-# reporters association with alanyzers
-[ Reporters ]
+# reporters association with analyzers
+[ AnalyzerReporters ]
CCpp = Logger
Kerneloops = KerneloopsReporter
# actions association
-[ Actions ] \ No newline at end of file
+[ AnalyzerActions ]
+# CCpp : xorg-x11-apps = RunApp("date", "RunApp") \ No newline at end of file