summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/CommLayer/CommLayerServer.h2
-rw-r--r--lib/CommLayer/CommLayerServerDBus.cpp8
-rw-r--r--lib/CommLayer/CommLayerServerDBus.h4
-rw-r--r--lib/MiddleWare/Makefile.am3
-rw-r--r--lib/MiddleWare/MiddleWare.cpp105
-rw-r--r--lib/MiddleWare/MiddleWare.h25
-rw-r--r--lib/MiddleWare/MiddleWareTypes.h2
-rw-r--r--lib/MiddleWare/PluginManager.cpp2
-rw-r--r--lib/Plugins/CCpp.cpp4
-rw-r--r--lib/Plugins/Kerneloops.cpp4
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp4
-rw-r--r--lib/Plugins/Logger.cpp4
-rw-r--r--lib/Plugins/Mailx.cpp4
-rw-r--r--lib/Plugins/Makefile.am12
-rw-r--r--lib/Plugins/PluginSettings.h41
-rw-r--r--lib/Plugins/SQLite3.cpp4
-rw-r--r--lib/Utils/Makefile.am2
-rw-r--r--src/Daemon/CrashWatcher.cpp66
-rw-r--r--src/Daemon/CrashWatcher.h10
-rw-r--r--src/Daemon/Daemon.cpp36
-rw-r--r--src/Daemon/Makefile.am5
-rw-r--r--src/Daemon/abrt.conf8
22 files changed, 180 insertions, 175 deletions
diff --git a/lib/CommLayer/CommLayerServer.h b/lib/CommLayer/CommLayerServer.h
index bc4082fa..fa8023a4 100644
--- a/lib/CommLayer/CommLayerServer.h
+++ b/lib/CommLayer/CommLayerServer.h
@@ -29,7 +29,7 @@ class CCommLayerServer{
public:
CMiddleWare *m_pMW;
CCommLayerServer(CMiddleWare *pMW);
- ~CCommLayerServer();
+ virtual ~CCommLayerServer();
/* observer */
void Attach(CObserver *pObs);
void Detach(CObserver *pObs);
diff --git a/lib/CommLayer/CommLayerServerDBus.cpp b/lib/CommLayer/CommLayerServerDBus.cpp
index a5eb4372..33bb2f9b 100644
--- a/lib/CommLayer/CommLayerServerDBus.cpp
+++ b/lib/CommLayer/CommLayerServerDBus.cpp
@@ -4,9 +4,9 @@
DBus::Connection *CCommLayerServerDBus::init_dbus(CCommLayerServerDBus *self)
{
CCommLayerServerDBus *server = (CCommLayerServerDBus*) self;
- server->dispatcher = new DBus::Glib::BusDispatcher();
- server->dispatcher->attach(NULL);
- DBus::default_dispatcher = self->dispatcher;
+ server->m_pDispatcher = new DBus::Glib::BusDispatcher();
+ server->m_pDispatcher->attach(NULL);
+ DBus::default_dispatcher = self->m_pDispatcher;
server->m_pConn = new DBus::Connection(DBus::Connection::SystemBus());
return server->m_pConn;
}
@@ -23,7 +23,7 @@ CCommLayerServerDBus::CCommLayerServerDBus(CMiddleWare *pMW)
CCommLayerServerDBus::~CCommLayerServerDBus()
{
std::cout << "Cleaning up dbus" << std::endl;
- delete dispatcher;
+ delete m_pDispatcher;
}
dbus_vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pUID)
diff --git a/lib/CommLayer/CommLayerServerDBus.h b/lib/CommLayer/CommLayerServerDBus.h
index 9bd29c73..175be21b 100644
--- a/lib/CommLayer/CommLayerServerDBus.h
+++ b/lib/CommLayer/CommLayerServerDBus.h
@@ -12,11 +12,11 @@ class CCommLayerServerDBus
{
private:
DBus::Connection *m_pConn;
- DBus::Glib::BusDispatcher *dispatcher;
+ DBus::Glib::BusDispatcher *m_pDispatcher;
static DBus::Connection *init_dbus(CCommLayerServerDBus *self);
public:
CCommLayerServerDBus(CMiddleWare *m_pMW);
- ~CCommLayerServerDBus();
+ virtual ~CCommLayerServerDBus();
virtual dbus_vector_crash_infos_t GetCrashInfos(const std::string &pUID);
virtual dbus_vector_map_crash_infos_t GetCrashInfosMap(const std::string &pDBusSender);
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
index 0a618a8b..f5280eaf 100644
--- a/lib/MiddleWare/Makefile.am
+++ b/lib/MiddleWare/Makefile.am
@@ -10,9 +10,6 @@ libMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libUtils.la $(RPM_LIBS)
libMiddleWare_la_LDFLAGS = -version-info 0:1:0
libMiddleWare_la_CPPFLAGS = -I$(srcdir)/../Utils $(RPM_CFLAGS)
-middlewareconfdir = $(CONF_DIR)
-dist_middlewareconf_DATA = abrt.conf
-
check_PROGRAMS = test
test_SOURCES = test.cpp
test_LDADD = ../Utils/libUtils.la libMiddleWare.la $(DL_LIBS) $(RPM_LIBS)
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
index 00eca794..109fc3a8 100644
--- a/lib/MiddleWare/MiddleWare.cpp
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -21,27 +21,14 @@
#include "MiddleWare.h"
#include "DebugDump.h"
-#include "Settings.h"
CMiddleWare::CMiddleWare(const std::string& pPlugisConfDir,
- const std::string& pPlugisLibDir,
- const std::string& pMiddleWareConfFile) :
+ const std::string& pPlugisLibDir) :
m_pPluginManager(NULL),
m_bOpenGPGCheck(true)
{
m_pPluginManager = new CPluginManager(pPlugisConfDir, pPlugisLibDir);
- if (m_pPluginManager == NULL)
- {
- throw std::string("Not enought memory.");
- }
m_pPluginManager->LoadPlugins();
- LoadSettings(pMiddleWareConfFile);
-
- set_enabled_plugins_t::iterator it_p;
- for (it_p = m_setEnabledPlugins.begin(); it_p != m_setEnabledPlugins.end(); it_p++)
- {
- m_pPluginManager->RegisterPlugin(*it_p);
- }
}
CMiddleWare::~CMiddleWare()
@@ -50,55 +37,6 @@ CMiddleWare::~CMiddleWare()
delete m_pPluginManager;
}
-void CMiddleWare::LoadSettings(const std::string& pPath)
-{
- map_settings_t settings;
- load_settings(pPath, settings);
- if (settings.find("BlackList") != settings.end())
- {
- parse_settings(settings["BlackList"], m_setBlackList);
- }
- if (settings.find("EnabledPlugins") != settings.end())
- {
- parse_settings(settings["EnabledPlugins"], m_setEnabledPlugins);
- }
- if (settings.find("OpenGPGPublicKeys") != settings.end())
- {
- parse_settings(settings["OpenGPGPublicKeys"], m_setOpenGPGKeys);
- set_opengpg_keys_t::iterator it_k;
- for (it_k = m_setOpenGPGKeys.begin(); it_k != m_setOpenGPGKeys.end(); it_k++)
- {
- m_RPM.LoadOpenGPGPublicKey(*it_k);
- }
- }
- if (settings.find("EnableOpenGPG") != settings.end())
- {
- m_bOpenGPGCheck = settings["EnableOpenGPG"] == "yes";
- }
- if (settings.find("Database") != settings.end())
- {
- m_sDatabase = settings["Database"];
- if (m_setEnabledPlugins.find(m_sDatabase) == m_setEnabledPlugins.end())
- {
- throw std::string("Database plugin '"+m_sDatabase+"' isn't enabled.");
- }
- }
- else
- {
- throw std::string("No database plugin is selected.");
- }
- set_enabled_plugins_t::iterator it_p;
- for (it_p = m_setEnabledPlugins.begin(); it_p != m_setEnabledPlugins.end(); it_p++)
- {
- if (settings.find(*it_p) != settings.end())
- {
- set_reporters_t reporters;
- parse_settings(settings[*it_p], reporters);
- m_mapPlugin2Reporters[*it_p] = reporters;
- }
- }
-}
-
void CMiddleWare::DebugDumpToCrashReport(const std::string& pDebugDumpDir, crash_report_t& pCrashReport)
{
CDebugDump dd;
@@ -109,7 +47,8 @@ void CMiddleWare::DebugDumpToCrashReport(const std::string& pDebugDumpDir, crash
if (!dd.Exist(FILENAME_UUID) ||
!dd.Exist(FILENAME_ARCHITECTURE) ||
!dd.Exist(FILENAME_KERNEL) ||
- !dd.Exist(FILENAME_PACKAGE))
+ !dd.Exist(FILENAME_PACKAGE) ||
+ !dd.Exist(FILENAME_EXECUTABLE))
{
dd.Close();
throw std::string("CMiddleWare::DebugDumpToCrashReport(): One or more of important file(s)'re missing.");
@@ -222,11 +161,11 @@ void CMiddleWare::Report(const crash_report_t& pCrashReport)
std::string UID = pCrashReport.find("_MWUID")->second.m_sContent;
std::string UUID = pCrashReport.find("_MWUUID")->second.m_sContent;;
- if (m_mapPlugin2Reporters.find(analyzer) != m_mapPlugin2Reporters.end())
+ if (m_mapAnalyzerReporters.find(analyzer) != m_mapAnalyzerReporters.end())
{
set_reporters_t::iterator it_r;
- for (it_r = m_mapPlugin2Reporters[analyzer].begin();
- it_r != m_mapPlugin2Reporters[analyzer].end();
+ for (it_r = m_mapAnalyzerReporters[analyzer].begin();
+ it_r != m_mapAnalyzerReporters[analyzer].end();
it_r++)
{
CReporter* reporter = m_pPluginManager->GetReporter(*it_r);
@@ -477,3 +416,35 @@ vector_crash_infos_t CMiddleWare::GetCrashInfos(const std::string& pUID)
return infos;
}
+void CMiddleWare::SetOpenGPGCheck(const bool& pCheck)
+{
+ m_bOpenGPGCheck = pCheck;
+}
+
+void CMiddleWare::SetDatabase(const std::string& pDatabase)
+{
+ m_sDatabase = pDatabase;
+}
+
+void CMiddleWare::AddOpenGPGPublicKey(const std::string& pKey)
+{
+ m_RPM.LoadOpenGPGPublicKey(pKey);
+}
+
+void CMiddleWare::AddBlackListedPackage(const std::string& pPackage)
+{
+ m_setBlackList.insert(pPackage);
+}
+
+void CMiddleWare::AddAnalyzerReporter(const std::string& pAnalyzer,
+ const std::string& pReporter)
+{
+ m_mapAnalyzerReporters[pAnalyzer].insert(pReporter);
+}
+
+void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer,
+ const std::string& pAction,
+ const vector_strings_t& pArgs)
+{
+ m_mapAnalyzerActions[pAnalyzer][pAction] = pArgs;
+}
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index 82b734b7..2986b7ef 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -35,16 +35,16 @@ class CMiddleWare
typedef set_strings_t set_blacklist_t;
typedef set_strings_t set_enabled_plugins_t;
typedef set_strings_t set_reporters_t;
- typedef set_strings_t set_opengpg_keys_t;
- typedef std::map<std::string, set_reporters_t> map_plugin2reporters_t;
+ typedef std::map<std::string, set_reporters_t> map_reporter_associations_t;
+ typedef std::map<std::string, vector_strings_t> map_single_actions_t;
+ typedef std::map<std::string, map_single_actions_t> map_action_associations_t;
CPluginManager* m_pPluginManager;
CRPM m_RPM;
set_blacklist_t m_setBlackList;
- set_enabled_plugins_t m_setEnabledPlugins;
- set_opengpg_keys_t m_setOpenGPGKeys;
std::string m_sDatabase;
- map_plugin2reporters_t m_mapPlugin2Reporters;
+ map_reporter_associations_t m_mapAnalyzerReporters;
+ map_action_associations_t m_mapAnalyzerActions;
bool m_bOpenGPGCheck;
@@ -55,8 +55,6 @@ class CMiddleWare
void CreateReport(const std::string& pAnalyzer,
const std::string& pDebugDumpDir);
- void LoadSettings(const std::string& pPath);
-
void DebugDumpToCrashReport(const std::string& pDebugDumpDir,
crash_report_t& pCrashReport);
@@ -70,8 +68,7 @@ class CMiddleWare
public:
CMiddleWare(const std::string& pPlugisConfDir,
- const std::string& pPlugisLibDir,
- const std::string& pMiddleWareConfFile);
+ const std::string& pPlugisLibDir);
~CMiddleWare();
@@ -93,6 +90,16 @@ class CMiddleWare
int SaveDebugDump(const std::string& pDebugDumpDir, crash_info_t& pCrashInfo);
vector_crash_infos_t GetCrashInfos(const std::string& pUID);
+
+ void SetOpenGPGCheck(const bool& pCheck);
+ void SetDatabase(const std::string& pDatabase);
+ void AddOpenGPGPublicKey(const std::string& pKey);
+ void AddBlackListedPackage(const std::string& pPackage);
+ void AddAnalyzerReporter(const std::string& pAnalyzer,
+ const std::string& pReporter);
+ void AddAnalyzerAction(const std::string& pAnalyzer,
+ const std::string& pAction,
+ const vector_strings_t& pArgs);
};
#endif /*MIDDLEWARE_H_*/
diff --git a/lib/MiddleWare/MiddleWareTypes.h b/lib/MiddleWare/MiddleWareTypes.h
index f2350560..5f8ee6ac 100644
--- a/lib/MiddleWare/MiddleWareTypes.h
+++ b/lib/MiddleWare/MiddleWareTypes.h
@@ -6,7 +6,7 @@
#include <vector>
#include <string>
-typedef std::vector<std::string> vector_string_t;
+typedef std::vector<std::string> vector_strings_t;
typedef std::map<std::string, std::string> map_string_string_t;
typedef std::set<std::string> set_strings_t;
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp
index 03e636ca..00c54fa6 100644
--- a/lib/MiddleWare/PluginManager.cpp
+++ b/lib/MiddleWare/PluginManager.cpp
@@ -24,7 +24,6 @@
#include <dirent.h>
#include <stdio.h>
#include <sys/types.h>
-#include "Settings.h"
CPluginManager::CPluginManager(const std::string& pPlugisConfDir,
const std::string& pPlugisLibDir) :
@@ -115,7 +114,6 @@ void CPluginManager::RegisterPlugin(const std::string& pName)
{
if (m_mapPlugins.find(pName) == m_mapPlugins.end())
{
- map_settings_t settings;
std::string path = m_sPlugisConfDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION;
CPlugin* plugin = m_mapABRTPlugins[pName]->PluginNew();
plugin->Init();
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 38f1a2a4..7a4fdc30 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -22,7 +22,7 @@
#include "CCpp.h"
#include <fstream>
#include "DebugDump.h"
-#include "Settings.h"
+#include "PluginSettings.h"
#include <sstream>
#include <iostream>
#include <hash_map>
@@ -388,7 +388,7 @@ void CAnalyzerCCpp::DeInit()
void CAnalyzerCCpp::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("MemoryMap")!= settings.end())
{
diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp
index cf65c9ee..b743a48a 100644
--- a/lib/Plugins/Kerneloops.cpp
+++ b/lib/Plugins/Kerneloops.cpp
@@ -27,7 +27,7 @@
#include "Kerneloops.h"
#include "KerneloopsSysLog.h"
#include "DebugDump.h"
-#include "Settings.h"
+#include "PluginSettings.h"
#include <sstream>
#include <assert.h>
@@ -221,7 +221,7 @@ void CAnalyzerKerneloops::ScanSysLogFile(const char *filename, int issyslog)
void CAnalyzerKerneloops::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("SysLogFile")!= settings.end())
{
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index fc0ab977..1bf485c2 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -26,7 +26,7 @@
#include "KerneloopsReporter.h"
#include "DebugDump.h"
-#include "Settings.h"
+#include "PluginSettings.h"
#include <stdlib.h>
#include <string.h>
@@ -85,7 +85,7 @@ void CKerneloopsReporter::Report(const crash_report_t& pCrashReport)
void CKerneloopsReporter::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("SubmitURL") != settings.end())
{
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
index 3b48d5e8..c17e85ed 100644
--- a/lib/Plugins/Logger.cpp
+++ b/lib/Plugins/Logger.cpp
@@ -21,7 +21,7 @@
#include "Logger.h"
#include <fstream>
-#include "Settings.h"
+#include "PluginSettings.h"
#include <sstream>
#include "DebugDump.h"
@@ -33,7 +33,7 @@ CLogger::CLogger() :
void CLogger::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("LogPath")!= settings.end())
{
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 8c0c4a6b..62e3d2bc 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <sstream>
#include "DebugDump.h"
-#include "Settings.h"
+#include "PluginSettings.h"
#define MAILX_COMMAND "/bin/mailx"
#define MAILX_SUBJECT "\"abrt automated bug report\""
@@ -126,7 +126,7 @@ void CMailx::Report(const crash_report_t& pCrashReport)
void CMailx::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("EmailFrom")!= settings.end())
{
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
index 7e02c19b..292918eb 100644
--- a/lib/Plugins/Makefile.am
+++ b/lib/Plugins/Makefile.am
@@ -12,33 +12,33 @@ pluginsconfdir=$(PLUGINS_CONF_DIR)
dist_pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf Logger.conf Kerneloops.conf KerneloopsReporter.conf
# CCpp
-libCCpp_la_SOURCES = CCpp.cpp CCpp.h
+libCCpp_la_SOURCES = CCpp.cpp CCpp.h PluginSettings.h
libCCpp_la_LDFLAGS = -avoid-version
libCCpp_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\"
# Kerneloops
-libKerneloops_la_SOURCES = Kerneloops.cpp Kerneloops.h KerneloopsSysLog.cpp KerneloopsSysLog.h
+libKerneloops_la_SOURCES = Kerneloops.cpp Kerneloops.h KerneloopsSysLog.cpp KerneloopsSysLog.h PluginSettings.h
libKerneloops_la_LDFLAGS = -avoid-version
libKerneloops_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" -DCCPP_HOOK_PATH=\"${libexecdir}/hookKerneloopsoops\"
# KerneloopsReporter
-libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h
+libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h PluginSettings.h
libKerneloopsReporter_la_LDFLAGS = -avoid-version
libKerneloopsReporter_la_LIBADD = $(CURL_LIBS)
libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(CURL_CFLAGS)
# Mailx
-libMailx_la_SOURCES = Mailx.cpp Mailx.h
+libMailx_la_SOURCES = Mailx.cpp Mailx.h PluginSettings.h
libMailx_la_LDFLAGS = -avoid-version
# SQLite3
-libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h
+libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h PluginSettings.h
libSQLite3_la_LDFLAGS = -avoid-version
libSQLite3_la_LIBADD = $(SQLITE3_LIBS)
libSQLite3_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(SQLITE3_CFLAGS)
# Logger
-libLogger_la_SOURCES = Logger.cpp Logger.h
+libLogger_la_SOURCES = Logger.cpp Logger.h PluginSettings.h
libLogger_la_LDFLAGS = -avoid-version
# RunApp
diff --git a/lib/Plugins/PluginSettings.h b/lib/Plugins/PluginSettings.h
index 31138d05..d331b353 100644
--- a/lib/Plugins/PluginSettings.h
+++ b/lib/Plugins/PluginSettings.h
@@ -1,5 +1,5 @@
/*
- Settings.h - header file for settings functions
+ PluginSettings.h - header file for plugin settings functions
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -19,8 +19,8 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef SETTINGSFUNC_H_
-#define SETTINGSFUNC_H_
+#ifndef PLUGINSETTINGSFUNC_H_
+#define PLUGINSETTINGSFUNC_H_
#include <fstream>
#include <map>
@@ -29,7 +29,7 @@
typedef std::map<std::string, std::string> map_settings_t;
typedef std::set<std::string> set_settings_t;
-inline void load_settings(const std::string& path, map_settings_t& settings)
+inline void plugin_load_settings(const std::string& path, map_settings_t& settings)
{
std::ifstream fIn;
fIn.open(path.c_str());
@@ -84,37 +84,4 @@ inline void load_settings(const std::string& path, map_settings_t& settings)
}
}
-inline void save_settings(const std::string& path, const map_settings_t& settings)
-{
- map_settings_t::const_iterator it;
- std::ofstream fOut;
- fOut.open(path.c_str());
- if (fOut.is_open())
- {
- fOut << "# !DO NOT EDIT THIS FILE BY HAND. IT IS GENERATED BY ABRT!" << std::endl;
- for (it = settings.begin(); it != settings.end(); it++)
- {
- fOut << it->first << " = " << it->second << std::endl << std::endl;
- }
- fOut.close();
- }
- else
- {
- throw std::string("save_settings(): Cannot write configuration file '"+path+"'.");
- }
-}
-
-inline void parse_settings(const std::string& pLine, set_settings_t& settings)
-{
- std::string::size_type ii_old = 0, ii_new = 0;
- ii_new = pLine.find(",");
- while (ii_new != std::string::npos)
- {
- settings.insert(pLine.substr(ii_old, ii_new - ii_old));
- ii_old = ii_new + 1;
- ii_new = pLine.find(",",ii_old);
- }
- settings.insert(pLine.substr(ii_old));
-}
-
#endif /* SETTINGSFUNC_H_ */
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp
index f48e71b2..9a5c6e0f 100644
--- a/lib/Plugins/SQLite3.cpp
+++ b/lib/Plugins/SQLite3.cpp
@@ -24,7 +24,7 @@
#include "SQLite3.h"
#include <string>
#include <iostream>
-#include "Settings.h"
+#include "PluginSettings.h"
#define ABRT_TABLE "abrt"
@@ -271,7 +271,7 @@ const database_row_t CSQLite3::GetUUIDData(const std::string& pUUID, const std::
void CSQLite3::LoadSettings(const std::string& pPath)
{
map_settings_t settings;
- load_settings(pPath, settings);
+ plugin_load_settings(pPath, settings);
if (settings.find("DBPath")!= settings.end())
{
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 5e255096..c791dc54 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -1,5 +1,5 @@
lib_LTLIBRARIES = libUtils.la
-libUtils_la_SOURCES = DebugDump.cpp DebugDump.h Settings.h
+libUtils_la_SOURCES = DebugDump.cpp DebugDump.h
libUtils_la_LDFLAGS = -version-info 0:1:0
libUtils_la_LIBADD = -lmagic
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 3426e929..783a6949 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -31,7 +31,7 @@
#include <dirent.h>
#include <cstring>
-/* just a helper function
+/* just a helper function
template< class T >
std::string
to_string( T x )
@@ -119,12 +119,60 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath,DBus::Connection &connecti
m_pGio = g_io_channel_unix_new(m_nFd);
}
*/
+
+void CCrashWatcher::SetUpMW()
+{
+ m_pMW->SetOpenGPGCheck(m_pSettings->GetOpenGPGCheck());
+ m_pMW->SetDatabase(m_pSettings->GetDatabase());
+ CSettings::set_strings_t openGPGPublicKeys = m_pSettings->GetOpenGPGPublicKeys();
+ CSettings::set_strings_t::iterator it_k;
+ for (it_k = openGPGPublicKeys.begin(); it_k != openGPGPublicKeys.end(); it_k++)
+ {
+ m_pMW->AddOpenGPGPublicKey(*it_k);
+ }
+ CSettings::set_strings_t blackList = m_pSettings->GetBlackList();
+ CSettings::set_strings_t::iterator it_b;
+ for (it_b = blackList.begin(); it_b != blackList.end(); it_b++)
+ {
+ m_pMW->AddBlackListedPackage(*it_b);
+ }
+ CSettings::set_strings_t enabledPlugins = m_pSettings->GetEnabledPlugins();
+ CSettings::set_strings_t::iterator it_p;
+ for (it_p = enabledPlugins.begin(); it_p != enabledPlugins.end(); it_p++)
+ {
+ m_pMW->RegisterPlugin(*it_p);
+ }
+ CSettings::map_reporters_t reporters = m_pSettings->GetReporters();
+ CSettings::map_reporters_t::iterator it_pr;
+ for (it_pr = reporters.begin(); it_pr != reporters.end(); it_pr++)
+ {
+ CSettings::set_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);
+ }
+ }
+ CSettings::map_actions_t actions = m_pSettings->GetActions();
+ CSettings::map_actions_t::iterator it_pa;
+ for (it_pa = actions.begin(); it_pa != actions.end(); it_pa++)
+ {
+ CSettings::map_single_actions_t::iterator it_sa;
+ for (it_sa = it_pa->second.begin(); it_sa != it_pa->second.end(); it_sa++)
+ {
+ m_pMW->AddAnalyzerAction(it_pa->first, it_sa->first, it_sa->second);
+ }
+ }
+}
+
CCrashWatcher::CCrashWatcher(const std::string& pPath)
{
int watch = 0;
m_sTarget = pPath;
// middleware object
- m_pMW = new CMiddleWare(PLUGINS_CONF_DIR,PLUGINS_LIB_DIR, std::string(CONF_DIR) + "/abrt.conf");
+ m_pSettings = new CSettings();
+ m_pSettings->LoadSettings(std::string(CONF_DIR) + "/abrt.conf");
+ m_pMW = new CMiddleWare(PLUGINS_CONF_DIR,PLUGINS_LIB_DIR);
+ SetUpMW();
FindNewDumps(pPath);
m_pMainloop = g_main_loop_new(NULL,FALSE);
#ifdef HAVE_DBUS
@@ -149,11 +197,15 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath)
CCrashWatcher::~CCrashWatcher()
{
- //delete dispatcher, connection, etc..
- //m_pConn->disconnect();
- delete m_pMW;
- g_io_channel_unref(m_pGio);
- g_main_loop_unref(m_pMainloop);
+ //delete dispatcher, connection, etc..
+ //m_pConn->disconnect();
+
+ g_io_channel_unref(m_pGio);
+ g_main_loop_unref(m_pMainloop);
+
+ delete m_pCommLayer;
+ delete m_pMW;
+ delete m_pSettings;
}
void CCrashWatcher::FindNewDumps(const std::string& pPath)
{
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index 667e5215..7ab70720 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -27,6 +27,7 @@
//#include "DBusManager.h"
//#include "DBusServerProxy.h"
#include "MiddleWare.h"
+#include "Settings.h"
#include "CommLayerServerDBus.h"
#ifdef HAVE_DBUS
@@ -50,9 +51,10 @@ class CCrashWatcher
void StartWatch();
void GStartWatch();
void Lock();
+ void SetUpMW();
/* finds dumps created when daemon wasn't running */
void FindNewDumps(const std::string& pPath);
-
+
int m_nFd;
GIOChannel* m_pGio;
GMainLoop *m_pMainloop;
@@ -61,16 +63,16 @@ class CCrashWatcher
CCommLayerServer *m_pCommLayer;
/*FIXME not needed */
//DBus::Connection *m_pConn;
-
+ CSettings *m_pSettings;
public:
//CCrashWatcher(const std::string& pPath,DBus::Connection &connection);
CCrashWatcher(const std::string& pPath);
- ~CCrashWatcher();
+ virtual ~CCrashWatcher();
//run as daemon
void Daemonize();
//don't go background - for debug
void Run();
-
+
/* methods exported on dbus */
public:
dbus_vector_crash_infos_t GetCrashInfos(const std::string &pUID);
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 1eca300b..5133902d 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -1,22 +1,22 @@
-/*
- Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
- Copyright (C) 2009 RedHat inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+/*
+ Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
#include "CrashWatcher.h"
#include <iostream>
#include <cstdio>
diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am
index 3eb2292c..fd079997 100644
--- a/src/Daemon/Makefile.am
+++ b/src/Daemon/Makefile.am
@@ -1,6 +1,6 @@
sbin_PROGRAMS = abrt
abrt_SOURCES = CrashWatcher.cpp CrashWatcher.h Daemon.cpp DBusServerProxy.h \
- DBusCommon.h
+ DBusCommon.h Settings.h Settings.cpp
abrt_CPPFLAGS = -Wall -Werror -I../../lib/MiddleWare -I../../lib/CommLayer\
-I../../lib/DBus \
-DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \
@@ -11,3 +11,6 @@ abrt_LDADD = ../../lib/MiddleWare/libMiddleWare.la ../../lib/CommLayer/libABRTCo
dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/
dist_dbusabrtconf_DATA = dbus-abrt.conf
+
+daemonconfdir = $(CONF_DIR)
+dist_daemonconf_DATA = abrt.conf
diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf
index af5b3956..90b33e20 100644
--- a/src/Daemon/abrt.conf
+++ b/src/Daemon/abrt.conf
@@ -1,4 +1,7 @@
# test conf file. it will be generated in the future
+
+# common abrt settings
+[ Common ]
# Enable GPG check
EnableOpenGPG = no
# GPG keys
@@ -9,6 +12,11 @@ BlackList = bash, bind, apache2
EnabledPlugins = SQLite3, CCpp, Mailx, Kerneloops, KerneloopsReporter
# selected DB plugin
Database = SQLite3
+
# reporters association
+[ Reporters ]
CCpp = Mailx
Kerneloops = KerneloopsReporter
+
+# actions association
+[ Actions ] \ No newline at end of file