summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-09-07 15:21:29 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-09-07 15:21:29 +0200
commitcea9d8bb0b407f6675ed063e0fd4152ab2a9e128 (patch)
tree7c0ad14a20d2b711b035ce9e804140bafd5db52f
parent9a8effd59d69dc557f5e2931a3577a314697a259 (diff)
parentbb46fd1f7466df6a7f0c45ad50c661a36fec0caf (diff)
downloadabrt-cea9d8bb0b407f6675ed063e0fd4152ab2a9e128.tar.gz
abrt-cea9d8bb0b407f6675ed063e0fd4152ab2a9e128.tar.xz
abrt-cea9d8bb0b407f6675ed063e0fd4152ab2a9e128.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
-rw-r--r--src/Daemon/Daemon.cpp4
-rw-r--r--src/Daemon/Daemon.h7
-rw-r--r--src/Daemon/MiddleWare.cpp18
-rw-r--r--src/Daemon/MiddleWare.h2
-rw-r--r--src/Daemon/PluginManager.cpp73
5 files changed, 58 insertions, 46 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index b4e99140..781a1bc0 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -37,7 +37,6 @@
#endif
#include "abrtlib.h"
#include "ABRTException.h"
-#include "RPM.h"
#include "CrashWatcher.h"
#include "Daemon.h"
@@ -193,8 +192,7 @@ static void SetUpMW()
set_string_t::iterator it_k = g_settings_setOpenGPGPublicKeys.begin();
for (; it_k != g_settings_setOpenGPGPublicKeys.end(); it_k++)
{
- VERB1 log("Loading GPG key '%s'", it_k->c_str());
- g_RPM.LoadOpenGPGPublicKey(it_k->c_str());
+ LoadOpenGPGPublicKey(it_k->c_str());
}
set_string_t::iterator it_b = g_settings_mapBlackList.begin();
for (; it_b != g_settings_mapBlackList.end(); it_b++)
diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h
index b24955b1..dbcfc291 100644
--- a/src/Daemon/Daemon.h
+++ b/src/Daemon/Daemon.h
@@ -27,7 +27,6 @@
class CCrashWatcher;
class CCommLayerServer;
class CPluginManager;
-class CRPM;
/* Verbosity level */
extern int g_verbose;
@@ -46,12 +45,6 @@ extern CCommLayerServer *g_pCommLayer;
extern CPluginManager* g_pPluginManager;
/**
- * An instance of CRPM used for package checking.
- * @see RPM.h
- */
-extern CRPM g_RPM;
-
-/**
* A set of blacklisted packages.
*/
extern set_string_t g_setBlackList;
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 05e91fdd..e6c9187c 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -36,14 +36,14 @@
*/
CPluginManager* g_pPluginManager;
/**
- * An instance of CRPM used for package checking.
- * @see RPM.h
- */
-CRPM g_RPM;
-/**
* A set of blacklisted packages.
*/
set_string_t g_setBlackList;
+/**
+ * An instance of CRPM used for package checking.
+ * @see RPM.h
+ */
+static CRPM s_RPM;
/**
@@ -450,6 +450,12 @@ static bool IsDebugDumpSaved(const std::string& pUID,
return found;
}
+void LoadOpenGPGPublicKey(const char* key)
+{
+ VERB1 log("Loading GPG key '%s'", key);
+ s_RPM.LoadOpenGPGPublicKey(key);
+}
+
/**
* Get a package name from executable name and save
* package description to particular debugdump directory of a crash.
@@ -484,7 +490,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta
}
if (g_settings_bOpenGPGCheck)
{
- if (!g_RPM.CheckFingerprint(packageName))
+ if (!s_RPM.CheckFingerprint(packageName))
{
error_msg("package isn't signed with proper key");
return MW_GPG_ERROR;
diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h
index a127c230..86d59396 100644
--- a/src/Daemon/MiddleWare.h
+++ b/src/Daemon/MiddleWare.h
@@ -51,6 +51,8 @@ typedef enum {
} report_status_items_t;
+void LoadOpenGPGPublicKey(const char* key);
+
/**
* Takes care of getting all additional data needed
* for computing UUIDs and creating a report for particular analyzer
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index 5371dd47..5580cdf2 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -188,22 +188,24 @@ void CPluginManager::LoadPlugin(const std::string& pName)
void CPluginManager::UnLoadPlugin(const std::string& pName)
{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName);
+ if (abrt_plugin != m_mapABRTPlugins.end())
{
UnRegisterPlugin(pName);
- delete m_mapABRTPlugins[pName];
- m_mapABRTPlugins.erase(pName);
+ delete abrt_plugin->second;
+ m_mapABRTPlugins.erase(abrt_plugin);
log("Plugin %s successfully unloaded", pName.c_str());
}
}
void CPluginManager::RegisterPlugin(const std::string& pName)
{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName);
+ if (abrt_plugin != m_mapABRTPlugins.end())
{
if (m_mapPlugins.find(pName) == m_mapPlugins.end())
{
- CPlugin* plugin = m_mapABRTPlugins[pName]->PluginNew();
+ CPlugin* plugin = abrt_plugin->second->PluginNew();
map_plugin_settings_t pluginSettings;
LoadPluginSettings(PLUGINS_CONF_DIR"/" + pName + "."PLUGINS_CONF_EXTENSION, pluginSettings);
@@ -215,34 +217,37 @@ void CPluginManager::RegisterPlugin(const std::string& pName)
catch (CABRTException& e)
{
warn_client("Can not initialize plugin " + pName + "("
- + std::string(plugin_type_str[m_mapABRTPlugins[pName]->GetType()])
+ + std::string(plugin_type_str[abrt_plugin->second->GetType()])
+ "): " + e.what());
UnLoadPlugin(pName);
return;
}
m_mapPlugins[pName] = plugin;
- log("Registered plugin %s(%s)", pName.c_str(), plugin_type_str[m_mapABRTPlugins[pName]->GetType()]);
+ log("Registered plugin %s(%s)", pName.c_str(), plugin_type_str[abrt_plugin->second->GetType()]);
}
}
}
void CPluginManager::UnRegisterPlugin(const std::string& pName)
{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName);
+ if (abrt_plugin != m_mapABRTPlugins.end())
{
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin != m_mapPlugins.end())
{
- m_mapPlugins[pName]->DeInit();
- delete m_mapPlugins[pName];
- m_mapPlugins.erase(pName);
- log("UnRegistered plugin %s(%s)", pName.c_str(), plugin_type_str[m_mapABRTPlugins[pName]->GetType()]);
+ plugin->second->DeInit();
+ delete plugin->second;
+ m_mapPlugins.erase(plugin);
+ log("UnRegistered plugin %s(%s)", pName.c_str(), plugin_type_str[abrt_plugin->second->GetType()]);
}
}
}
CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin == m_mapPlugins.end())
{
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():"
"Analyzer plugin: '"+pName+"' is not registered.");
@@ -252,12 +257,13 @@ CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName)
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():"
"Plugin: '"+pName+"' is not analyzer plugin.");
}
- return (CAnalyzer*)(m_mapPlugins[pName]);
+ return (CAnalyzer*)(plugin->second);
}
CReporter* CPluginManager::GetReporter(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin == m_mapPlugins.end())
{
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():"
"Reporter plugin: '"+pName+"' is not registered.");
@@ -267,12 +273,13 @@ CReporter* CPluginManager::GetReporter(const std::string& pName)
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():"
"Plugin: '"+pName+"' is not reporter plugin.");
}
- return (CReporter*)(m_mapPlugins[pName]);
+ return (CReporter*)(plugin->second);
}
CAction* CPluginManager::GetAction(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin == m_mapPlugins.end())
{
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():"
"Action plugin: '"+pName+"' is not registered.");
@@ -282,12 +289,13 @@ CAction* CPluginManager::GetAction(const std::string& pName)
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():"
"Plugin: '"+pName+"' is not action plugin.");
}
- return (CAction*)(m_mapPlugins[pName]);
+ return (CAction*)(plugin->second);
}
CDatabase* CPluginManager::GetDatabase(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin == m_mapPlugins.end())
{
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():"
"Database plugin: '"+pName+"' is not registered.");
@@ -297,12 +305,13 @@ CDatabase* CPluginManager::GetDatabase(const std::string& pName)
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():"
"Plugin: '"+pName+"' is not database plugin.");
}
- return (CDatabase*)(m_mapPlugins[pName]);
+ return (CDatabase*)(plugin->second);
}
plugin_type_t CPluginManager::GetPluginType(const std::string& pName)
{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin == m_mapPlugins.end())
{
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetPluginType():"
"Plugin: '"+pName+"' is not registered.");
@@ -336,13 +345,15 @@ void CPluginManager::SetPluginSettings(const std::string& pName,
const std::string& pUID,
const map_plugin_settings_t& pSettings)
{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName);
+ if (abrt_plugin != m_mapABRTPlugins.end())
{
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin != m_mapPlugins.end())
{
- m_mapPlugins[pName]->SetSettings(pSettings);
+ plugin->second->SetSettings(pSettings);
- if (m_mapABRTPlugins[pName]->GetType() == REPORTER)
+ if (abrt_plugin->second->GetType() == REPORTER)
{
std::string home = get_home_dir(atoi(pUID.c_str()));
if (home != "")
@@ -395,13 +406,15 @@ map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName
const std::string& pUID)
{
map_plugin_settings_t ret;
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
+ map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName);
+ if (abrt_plugin != m_mapABRTPlugins.end())
{
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
+ map_plugins_t::iterator plugin = m_mapPlugins.find(pName);
+ if (plugin != m_mapPlugins.end())
{
- ret = m_mapPlugins[pName]->GetSettings();
+ ret = plugin->second->GetSettings();
- if (m_mapABRTPlugins[pName]->GetType() == REPORTER)
+ if (abrt_plugin->second->GetType() == REPORTER)
{
std::string home = get_home_dir(atoi(pUID.c_str()));
if (home != "")