summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-08-06 16:19:07 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-08-06 16:19:07 +0200
commit84348ccea878d509f838927e1bf393e5443d3ac8 (patch)
treed7dc8bdc80b18a6137f94415761ec95c1df8e005 /lib
parent9a3268d970142f0dfb4e3e77c66c9637bf87fbda (diff)
parent26c6665308b5a99d02308099118b23b2716dacc0 (diff)
downloadabrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.gz
abrt-84348ccea878d509f838927e1bf393e5443d3ac8.tar.xz
abrt-84348ccea878d509f838927e1bf393e5443d3ac8.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Conflicts: lib/CommLayer/DBusServerProxy.h
Diffstat (limited to 'lib')
-rw-r--r--lib/CommLayer/DBusClientProxy.cpp238
-rw-r--r--lib/CommLayer/DBusClientProxy.h247
-rw-r--r--lib/CommLayer/DBusServerProxy.cpp206
-rw-r--r--lib/CommLayer/DBusServerProxy.h197
-rw-r--r--lib/CommLayer/Makefile.am41
-rw-r--r--lib/MiddleWare/Makefile.am51
-rw-r--r--lib/MiddleWare/MiddleWare.cpp615
-rw-r--r--lib/MiddleWare/MiddleWare.h349
-rw-r--r--lib/MiddleWare/PluginManager.cpp283
-rw-r--r--lib/MiddleWare/PluginManager.h156
-rw-r--r--lib/Plugins/CCpp.cpp27
-rw-r--r--lib/Plugins/FileTransfer.conf2
-rw-r--r--lib/Plugins/KerneloopsScanner.cpp2
-rw-r--r--lib/Plugins/Makefile.am18
-rw-r--r--lib/Plugins/abrt-Bugzilla.712
-rw-r--r--lib/Plugins/abrt-FileTransfer.716
-rw-r--r--lib/Plugins/abrt-KerneloopsReporter.76
-rw-r--r--lib/Plugins/abrt-KerneloopsScanner.78
-rw-r--r--lib/Plugins/abrt-Logger.76
-rw-r--r--lib/Plugins/abrt-Mailx.76
-rw-r--r--lib/Plugins/abrt-RunApp.76
-rw-r--r--lib/Plugins/abrt-SQLite3.74
-rw-r--r--lib/Plugins/abrt-plugins.74
-rw-r--r--lib/Python/PyDebugDump.cpp10
-rw-r--r--lib/Utils/CrashTypesSocket.cpp185
-rw-r--r--lib/Utils/DebugDump.cpp28
-rw-r--r--lib/Utils/DebugDump.h2
-rw-r--r--lib/Utils/Makefile.am4
-rw-r--r--lib/Utils/copyfd.cpp107
-rw-r--r--lib/Utils/xfuncs.cpp30
30 files changed, 971 insertions, 1895 deletions
diff --git a/lib/CommLayer/DBusClientProxy.cpp b/lib/CommLayer/DBusClientProxy.cpp
new file mode 100644
index 00000000..4f51172d
--- /dev/null
+++ b/lib/CommLayer/DBusClientProxy.cpp
@@ -0,0 +1,238 @@
+/*
+ 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 "DBusClientProxy.h"
+#include <iostream>
+
+namespace org {
+namespace freedesktop {
+namespace DBus {
+
+/* class DaemonWatcher_proxy */
+
+/* public: */
+
+DaemonWatcher_proxy::DaemonWatcher_proxy()
+: ::DBus::InterfaceProxy("org.freedesktop.DBus")
+{
+ m_pStateChangeHandler_cb_data = NULL;
+ m_pStateChangeHandler = NULL;
+ connect_signal(DaemonWatcher_proxy, NameOwnerChanged , _DaemonStateChanged);
+}
+
+void DaemonWatcher_proxy::ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data)
+{
+ m_pStateChangeHandler_cb_data = cb_data;
+ m_pStateChangeHandler = pStateChangeHandler;
+}
+
+/* private: */
+
+/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
+ */
+void DaemonWatcher_proxy::_DaemonStateChanged(const ::DBus::SignalMessage &sig)
+{
+ ::DBus::MessageIter ri = sig.reader();
+ std::string name;
+ std::string old_owner;
+ std::string new_owner;
+ ri >> name;
+ ri >> old_owner;
+ ri >> new_owner;
+ if(name.compare("com.redhat.abrt") == 0)
+ {
+ if(new_owner.length() > 0)
+ {
+ if(m_pStateChangeHandler)
+ {
+ m_pStateChangeHandler(true,m_pStateChangeHandler_cb_data);
+ }
+ else
+ {
+ std::cout << "Daemon appeared!" << std::endl;
+ }
+ }
+ if(new_owner.length() == 0)
+ {
+ if(m_pStateChangeHandler)
+ {
+ m_pStateChangeHandler(false, m_pStateChangeHandler_cb_data);
+ }
+ else
+ {
+ std::cout << "Daemon dissapeared!" << std::endl;
+ }
+ }
+ }
+}
+
+} } } /* closing namespaces */
+
+
+/* class DaemonWatcher */
+
+/* public: */
+
+DaemonWatcher::DaemonWatcher(DBus::Connection &connection, const char *path, const char *name)
+: ::DBus::ObjectProxy(connection, path, name)
+{
+}
+DaemonWatcher::~DaemonWatcher()
+{
+ std::cout << "~DaemonWatcher" << std::endl;
+}
+
+
+/* class CDBusClient_proxy */
+
+/* public: */
+
+CDBusClient_proxy::CDBusClient_proxy()
+: DBus::InterfaceProxy(CC_DBUS_IFACE)
+{
+ connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
+ connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
+ m_sConnName = "";
+}
+
+CDBusClient_proxy::CDBusClient_proxy(::DBus::Connection &pConnection)
+: DBus::InterfaceProxy(CC_DBUS_IFACE)
+{
+ gloop = g_main_loop_new(NULL, false);
+ //# define connect_signal(interface, signal, callback)
+ connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
+ connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
+ m_sConnName = pConnection.unique_name();
+}
+
+/* methods exported by this interface,
+ * this functions will invoke the corresponding methods on the remote objects
+ */
+ /*
+
+ <
+ <m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
+ <m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
+ <m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
+ ...
+ >
+ */
+vector_crash_infos_t CDBusClient_proxy::GetCrashInfos()
+{
+ DBus::CallMessage call;
+ DBus::MessageIter wi = call.writer();
+
+ call.member("GetCrashInfos");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+
+ vector_crash_infos_t argout;
+ ri >> argout;
+ return argout;
+}
+
+bool CDBusClient_proxy::DeleteDebugDump(const std::string& pUUID)
+{
+ DBus::CallMessage call;
+
+ DBus::MessageIter wi = call.writer();
+
+ wi << pUUID;
+ call.member("DeleteDebugDump");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+
+ bool argout;
+ ri >> argout;
+ return argout;
+}
+
+map_crash_report_t CDBusClient_proxy::CreateReport(const std::string& pUUID)
+{
+ m_bJobDone = false;
+ DBus::CallMessage call;
+
+ DBus::MessageIter wi = call.writer();
+
+ wi << pUUID;
+ call.member("CreateReport");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+ ri >> m_iPendingJobID;
+ //FIXME: what if the report is created before we start the loop? (we miss the signal and get stuck in the loop)
+ g_main_loop_run(gloop);
+ return GetJobResult(m_iPendingJobID);
+};
+
+void CDBusClient_proxy::Report(map_crash_report_t pReport)
+{
+ DBus::CallMessage call;
+
+ DBus::MessageIter wi = call.writer();
+
+ wi << pReport;
+ call.member("Report");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+}
+
+map_crash_report_t CDBusClient_proxy::GetJobResult(uint64_t pJobID)
+{
+ DBus::CallMessage call;
+
+ DBus::MessageIter wi = call.writer();
+
+ wi << pJobID;
+ call.member("GetJobResult");
+ DBus::Message ret = invoke_method(call);
+ DBus::MessageIter ri = ret.reader();
+ map_crash_report_t argout;
+ ri >> argout;
+ return argout;
+}
+
+/* signal handlers for this interface
+ */
+void CDBusClient_proxy::Crash(std::string& value)
+{
+}
+
+/* private: */
+
+/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
+ */
+void CDBusClient_proxy::_Crash_stub(const ::DBus::SignalMessage &sig)
+{
+ DBus::MessageIter ri = sig.reader();
+
+ std::string value; ri >> value;
+ Crash(value);
+}
+
+void CDBusClient_proxy::_JobDone_stub(const ::DBus::SignalMessage &sig)
+{
+ DBus::MessageIter ri = sig.reader();
+ std::string dest;
+ ri >> dest;
+ if(m_sConnName == dest)
+ {
+ ri >> m_iPendingJobID;
+ g_main_loop_quit(gloop);
+ }
+}
diff --git a/lib/CommLayer/DBusClientProxy.h b/lib/CommLayer/DBusClientProxy.h
index 52ba75d5..5b5c1fde 100644
--- a/lib/CommLayer/DBusClientProxy.h
+++ b/lib/CommLayer/DBusClientProxy.h
@@ -1,26 +1,28 @@
-/*
- 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.
*/
-
+#ifndef DBUSCLIENTPROXY_H_
+#define DBUSCLIENTPROXY_H_
+
#include <dbus-c++/dbus.h>
#include <dbus-c++/glib-integration.h>
#include "DBusCommon.h"
-#include <iostream>
+
#define ABRT_NOT_RUNNING 0
#define ABRT_RUNNING 1
@@ -29,68 +31,25 @@ namespace freedesktop {
namespace DBus {
class DaemonWatcher_proxy
- : public ::DBus::InterfaceProxy
+: public ::DBus::InterfaceProxy
{
private:
void *m_pStateChangeHandler_cb_data;
void (*m_pStateChangeHandler)(bool running, void* data);
-public:
- DaemonWatcher_proxy()
- : ::DBus::InterfaceProxy("org.freedesktop.DBus")
- {
- m_pStateChangeHandler_cb_data = NULL;
- m_pStateChangeHandler = NULL;
- connect_signal(DaemonWatcher_proxy, NameOwnerChanged , _DaemonStateChanged);
- }
+public:
+ DaemonWatcher_proxy();
+ void ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data);
- void ConnectStateChangeHandler(void (*pStateChangeHandler)(bool running, void* data), void *cb_data)
- {
- m_pStateChangeHandler_cb_data = cb_data;
- m_pStateChangeHandler = pStateChangeHandler;
- }
private:
-
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
- void _DaemonStateChanged(const ::DBus::SignalMessage &sig)
- {
- ::DBus::MessageIter ri = sig.reader();
- std::string name;
- std::string old_owner;
- std::string new_owner;
- ri >> name;
- ri >> old_owner;
- ri >> new_owner;
- if(name.compare("com.redhat.abrt") == 0){
- if(new_owner.length() > 0)
- {
- if(m_pStateChangeHandler)
- {
- m_pStateChangeHandler(true,m_pStateChangeHandler_cb_data);
- }
- else
- {
- std::cout << "Daemon appeared!" << std::endl;
- }
- }
- if(new_owner.length() == 0)
- {
- if(m_pStateChangeHandler)
- {
- m_pStateChangeHandler(false, m_pStateChangeHandler_cb_data);
- }
- else
- {
- std::cout << "Daemon dissapeared!" << std::endl;
- }
- }
- }
- }
+ void _DaemonStateChanged(const ::DBus::SignalMessage &sig);
};
} } }
+
class DaemonWatcher
: public org::freedesktop::DBus::DaemonWatcher_proxy,
public DBus::IntrospectableProxy,
@@ -98,162 +57,52 @@ class DaemonWatcher
{
public:
- DaemonWatcher(DBus::Connection &connection, const char *path, const char *name)
- : ::DBus::ObjectProxy(connection, path, name)
- {
- }
- ~DaemonWatcher()
- {
- std::cout << "~DaemonWatcher" << std::endl;
- }
+ DaemonWatcher(DBus::Connection &connection, const char *path, const char *name);
+ ~DaemonWatcher();
};
-
+
class CDBusClient_proxy
- : public DBus::InterfaceProxy
+: public DBus::InterfaceProxy
{
private:
bool m_bJobDone;
uint64_t m_iPendingJobID;
GMainLoop *gloop;
std::string m_sConnName;
-public:
-
-
- CDBusClient_proxy()
- : DBus::InterfaceProxy(CC_DBUS_IFACE)
- {
- connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
- connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
- m_sConnName = "";
- }
-
- CDBusClient_proxy(::DBus::Connection &pConnection)
- : DBus::InterfaceProxy(CC_DBUS_IFACE)
- {
- gloop = g_main_loop_new(NULL, false);
- //# define connect_signal(interface, signal, callback)
- connect_signal(CDBusClient_proxy, Crash, _Crash_stub);
- connect_signal(CDBusClient_proxy, JobDone, _JobDone_stub);
- m_sConnName = pConnection.unique_name();
- }
public:
+ CDBusClient_proxy();
+ CDBusClient_proxy(::DBus::Connection &pConnection);
+public:
/* methods exported by this interface,
* this functions will invoke the corresponding methods on the remote objects
*/
- /*
-
- <
+ /*
+ <
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
<m_sUUID;m_sUID;m_sCount;m_sExecutable;m_sPackage>
...
>
- */
- vector_crash_infos_t GetCrashInfos()
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- call.member("GetCrashInfos");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
-
- vector_crash_infos_t argout;
- ri >> argout;
- return argout;
- }
-
- bool DeleteDebugDump(const std::string& pUUID)
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pUUID;
- call.member("DeleteDebugDump");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
-
- bool argout;
- ri >> argout;
- return argout;
- }
-
- map_crash_report_t CreateReport(const std::string& pUUID)
- {
- m_bJobDone = false;
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pUUID;
- call.member("CreateReport");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
- ri >> m_iPendingJobID;
- //FIXME: what if the report is created before we start the loop? (we miss the signal and get stuck in the loop)
- g_main_loop_run(gloop);
- return GetJobResult(m_iPendingJobID);
- };
-
- void Report(map_crash_report_t pReport)
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
-
- wi << pReport;
- call.member("Report");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
- }
-
- map_crash_report_t GetJobResult(uint64_t pJobID)
- {
- DBus::CallMessage call;
-
- DBus::MessageIter wi = call.writer();
+ */
+ vector_crash_infos_t GetCrashInfos();
+ bool DeleteDebugDump(const std::string& pUUID);
+ map_crash_report_t CreateReport(const std::string& pUUID);
+ void Report(map_crash_report_t pReport);
+ map_crash_report_t GetJobResult(uint64_t pJobID);
- wi << pJobID;
- call.member("GetJobResult");
- DBus::Message ret = invoke_method(call);
- DBus::MessageIter ri = ret.reader();
- map_crash_report_t argout;
- ri >> argout;
- return argout;
- }
-
public:
-
/* signal handlers for this interface
*/
- virtual void Crash(std::string& value){}
-
-private:
+ virtual void Crash(std::string& value);
+private:
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
- void _Crash_stub(const ::DBus::SignalMessage &sig)
- {
- DBus::MessageIter ri = sig.reader();
-
- std::string value; ri >> value;
- Crash(value);
- }
-
- void _JobDone_stub(const ::DBus::SignalMessage &sig)
- {
- DBus::MessageIter ri = sig.reader();
- std::string dest;
- ri >> dest;
- if(m_sConnName == dest)
- {
- ri >> m_iPendingJobID;
- g_main_loop_quit(gloop);
- }
- }
+ void _Crash_stub(const ::DBus::SignalMessage &sig);
+ void _JobDone_stub(const ::DBus::SignalMessage &sig);
};
+
+#endif
diff --git a/lib/CommLayer/DBusServerProxy.cpp b/lib/CommLayer/DBusServerProxy.cpp
new file mode 100644
index 00000000..6bf0fbde
--- /dev/null
+++ b/lib/CommLayer/DBusServerProxy.cpp
@@ -0,0 +1,206 @@
+/*
+ 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 "DBusServerProxy.h"
+#include <stdlib.h>
+
+/* public: */
+
+CDBusServer_adaptor::CDBusServer_adaptor()
+: DBus::InterfaceAdaptor(CC_DBUS_IFACE)
+{
+ register_method(CDBusServer_adaptor, GetCrashInfos, _GetCrashInfos_stub);
+ register_method(CDBusServer_adaptor, CreateReport, _CreateReport_stub);
+ register_method(CDBusServer_adaptor, Report, _Report_stub);
+ register_method(CDBusServer_adaptor, DeleteDebugDump, _DeleteDebugDump_stub);
+ register_method(CDBusServer_adaptor, GetJobResult, _GetJobResult_stub);
+ register_method(CDBusServer_adaptor, GetPluginsInfo, _GetPluginsInfo_stub);
+}
+/* reveal Interface introspection when we stabilize the API */
+/*
+DBus::IntrospectedInterface *const CDBusServer_adaptor::introspect() const
+{
+ static DBus::IntrospectedArgument GetCrashInfos_args[] =
+ {
+ //{ "uid", "i", true},
+ { "info", "a{ss}", false },
+ { 0, 0, 0 }
+ };
+ static DBus::IntrospectedArgument Crash_args[] =
+ {
+ { "package", "s", false },
+ { 0, 0, 0 }
+ };
+ static DBus::IntrospectedMethod CDBusServer_adaptor_methods[] =
+ {
+ { "GetCrashInfos", GetCrashInfos_args },
+ { 0, 0 },
+ { "GetCrashInfosMap", GetCrashInfos_args },
+ { 0, 0 }
+ };
+ static DBus::IntrospectedMethod CDBusServer_adaptor_signals[] =
+ {
+ { "Crash", Crash_args },
+ { 0, 0 }
+ };
+ static DBus::IntrospectedProperty CDBusServer_adaptor_properties[] =
+ {
+ { 0, 0, 0, 0 }
+ };
+ static DBus::IntrospectedInterface CDBusServer_adaptor_interface =
+ {
+ "com.redhat.abrt",
+ CDBusServer_adaptor_methods,
+ CDBusServer_adaptor_signals,
+ CDBusServer_adaptor_properties
+ };
+ return &CDBusServer_adaptor_interface;
+}
+*/
+
+/* public: */
+
+/* signal emitters for this interface */
+
+/* Notify the clients (UI) about a new crash */
+void CDBusServer_adaptor::Crash(const std::string& arg1)
+{
+ ::DBus::SignalMessage sig("Crash");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << arg1;
+ emit_signal(sig);
+}
+
+/* Notify the clients that creating a report has finished */
+void CDBusServer_adaptor::AnalyzeComplete(map_crash_report_t arg1)
+{
+ ::DBus::SignalMessage sig("AnalyzeComplete");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << arg1;
+ emit_signal(sig);
+}
+
+void CDBusServer_adaptor::JobDone(const std::string &pDest, uint64_t job_id)
+{
+ ::DBus::SignalMessage sig("JobDone");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << pDest;
+ wi << job_id;
+ emit_signal(sig);
+}
+
+void CDBusServer_adaptor::Error(const std::string& arg1)
+{
+ ::DBus::SignalMessage sig("Error");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << arg1;
+ emit_signal(sig);
+}
+
+void CDBusServer_adaptor::Update(const std::string pDest, const std::string& pMessage)
+{
+ ::DBus::SignalMessage sig("Update");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << pDest;
+ wi << pMessage;
+ emit_signal(sig);
+}
+
+void CDBusServer_adaptor::Warning(const std::string& arg1)
+{
+ ::DBus::SignalMessage sig("Warning");
+ ::DBus::MessageIter wi = sig.writer();
+ wi << arg1;
+ emit_signal(sig);
+}
+
+/* private: */
+
+/* unmarshalers (to unpack the DBus message before calling the actual interface method)
+ */
+DBus::Message CDBusServer_adaptor::_GetCrashInfos_stub(const DBus::CallMessage &call)
+{
+ DBus::MessageIter ri = call.reader();
+ //FIXME: @@@REMOVE!!
+ vector_crash_infos_t argout1 = GetCrashInfos(call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+}
+
+DBus::Message CDBusServer_adaptor::_CreateReport_stub(const DBus::CallMessage &call)
+{
+ DBus::MessageIter ri = call.reader();
+
+ std::string argin1; ri >> argin1;
+ uint64_t argout1 = CreateReport_t(argin1, call.sender());
+ if(sizeof (uint64_t) != 8) abort ();
+ //map_crash_report_t argout1 = CreateReport(argin1,call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+}
+
+DBus::Message CDBusServer_adaptor::_Report_stub(const DBus::CallMessage &call)
+{
+ DBus::MessageIter ri = call.reader();
+
+ map_crash_report_t argin1; ri >> argin1;
+ bool argout1 = Report(argin1, call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+}
+
+DBus::Message CDBusServer_adaptor::_DeleteDebugDump_stub(const DBus::CallMessage &call)
+{
+ DBus::MessageIter ri = call.reader();
+
+ std::string argin1; ri >> argin1;
+ bool argout1 = DeleteDebugDump(argin1, call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+}
+
+DBus::Message CDBusServer_adaptor::_GetJobResult_stub(const DBus::CallMessage &call)
+{
+ DBus::MessageIter ri = call.reader();
+ uint64_t job_id;
+ ri >> job_id;
+ map_crash_report_t report = GetJobResult(job_id, call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << report;
+ return reply;
+}
+
+DBus::Message CDBusServer_adaptor::_GetPluginsInfo_stub(const DBus::CallMessage &call)
+{
+ vector_map_string_string_t plugins_info;
+ plugins_info = GetPluginsInfo();
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << plugins_info;
+ return reply;
+}
diff --git a/lib/CommLayer/DBusServerProxy.h b/lib/CommLayer/DBusServerProxy.h
index 157a95f9..78fb28b3 100644
--- a/lib/CommLayer/DBusServerProxy.h
+++ b/lib/CommLayer/DBusServerProxy.h
@@ -16,83 +16,35 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifndef DBUSSERVERPROXY_H_
+#define DBUSSERVERPROXY_H_
+
#include <dbus-c++/dbus.h>
#include <dbus-c++/glib-integration.h>
#include "DBusCommon.h"
-#include <map>
-#include <iostream>
-#include <stdlib.h>
class CDBusServer_adaptor
: public DBus::InterfaceAdaptor
{
public:
-
- CDBusServer_adaptor()
- : DBus::InterfaceAdaptor(CC_DBUS_IFACE)
- {
- register_method(CDBusServer_adaptor, GetCrashInfos, _GetCrashInfos_stub);
- register_method(CDBusServer_adaptor, CreateReport, _CreateReport_stub);
- register_method(CDBusServer_adaptor, Report, _Report_stub);
- register_method(CDBusServer_adaptor, DeleteDebugDump, _DeleteDebugDump_stub);
- register_method(CDBusServer_adaptor, GetJobResult, _GetJobResult_stub);
- register_method(CDBusServer_adaptor, GetPluginsInfo, _GetPluginsInfo_stub);
- }
+ CDBusServer_adaptor();
/* reveal Interface introspection when we stabilize the API */
/*
- DBus::IntrospectedInterface *const introspect() const
- {
- static DBus::IntrospectedArgument GetCrashInfos_args[] =
- {
- //{ "uid", "i", true},
- { "info", "a{ss}", false },
- { 0, 0, 0 }
- };
- static DBus::IntrospectedArgument Crash_args[] =
- {
- { "package", "s", false },
- { 0, 0, 0 }
- };
- static DBus::IntrospectedMethod CDBusServer_adaptor_methods[] =
- {
- { "GetCrashInfos", GetCrashInfos_args },
- { 0, 0 },
- { "GetCrashInfosMap", GetCrashInfos_args },
- { 0, 0 }
- };
- static DBus::IntrospectedMethod CDBusServer_adaptor_signals[] =
- {
- { "Crash", Crash_args },
- { 0, 0 }
- };
- static DBus::IntrospectedProperty CDBusServer_adaptor_properties[] =
- {
- { 0, 0, 0, 0 }
- };
- static DBus::IntrospectedInterface CDBusServer_adaptor_interface =
- {
- "com.redhat.abrt",
- CDBusServer_adaptor_methods,
- CDBusServer_adaptor_signals,
- CDBusServer_adaptor_properties
- };
- return &CDBusServer_adaptor_interface;
- }
+ DBus::IntrospectedInterface *const introspect() const;
*/
-public:
+public:
/* properties exposed by this interface, use
* property() and property(value) to get and set a particular property
*/
public:
-
/* methods exported by this interface,
* you will have to implement them in your ObjectAdaptor
*/
virtual vector_crash_infos_t GetCrashInfos(const std::string &pDBusSender) = 0;
- virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pDBusSender) = 0;
- virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pDBusSender) = 0;
+ virtual map_crash_report_t CreateReport(const std::string &pUUID, const std::string &pDBusSender) = 0;
+ virtual uint64_t CreateReport_t(const std::string &pUUID, const std::string &pDBusSender) = 0;
virtual bool Report(map_crash_report_t pReport, const std::string &pDBusSender) = 0;
virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender) = 0;
virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pDBusSender) = 0;
@@ -102,130 +54,23 @@ public:
/* signal emitters for this interface
*/
/* Notify the clients (UI) about a new crash */
- void Crash(const std::string& arg1)
- {
- ::DBus::SignalMessage sig("Crash");
- ::DBus::MessageIter wi = sig.writer();
- wi << arg1;
- emit_signal(sig);
- }
+ void Crash(const std::string& arg1);
/* Notify the clients that creating a report has finished */
- void AnalyzeComplete(map_crash_report_t arg1)
- {
- ::DBus::SignalMessage sig("AnalyzeComplete");
- ::DBus::MessageIter wi = sig.writer();
- wi << arg1;
- emit_signal(sig);
- }
-
-
- void JobDone(const std::string &pDest, uint64_t job_id)
- {
- ::DBus::SignalMessage sig("JobDone");
- ::DBus::MessageIter wi = sig.writer();
- wi << pDest;
- wi << job_id;
- emit_signal(sig);
- }
-
- void Error(const std::string& arg1)
- {
- ::DBus::SignalMessage sig("Error");
- ::DBus::MessageIter wi = sig.writer();
- wi << arg1;
- emit_signal(sig);
- }
-
- void Update(const std::string pDest, const std::string& pMessage)
- {
- ::DBus::SignalMessage sig("Update");
- ::DBus::MessageIter wi = sig.writer();
- wi << pDest;
- wi << pMessage;
- emit_signal(sig);
- }
-
- void Warning(const std::string& arg1)
- {
- ::DBus::SignalMessage sig("Warning");
- ::DBus::MessageIter wi = sig.writer();
- wi << arg1;
- emit_signal(sig);
- }
+ void AnalyzeComplete(map_crash_report_t arg1);
+ void JobDone(const std::string &pDest, uint64_t job_id);
+ void Error(const std::string& arg1);
+ void Update(const std::string pDest, const std::string& pMessage);
+ void Warning(const std::string& arg1);
private:
-
/* unmarshalers (to unpack the DBus message before calling the actual interface method)
*/
- DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call)
- {
- DBus::MessageIter ri = call.reader();
- //FIXME: @@@REMOVE!!
- vector_crash_infos_t argout1 = GetCrashInfos(call.sender());
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << argout1;
- return reply;
- }
-
- DBus::Message _CreateReport_stub(const DBus::CallMessage &call)
- {
- DBus::MessageIter ri = call.reader();
-
- std::string argin1; ri >> argin1;
- uint64_t argout1 = CreateReport_t(argin1,call.sender());
- if(sizeof (uint64_t) != 8) abort ();
- //map_crash_report_t argout1 = CreateReport(argin1,call.sender());
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << argout1;
- return reply;
- }
-
- DBus::Message _Report_stub(const DBus::CallMessage &call)
- {
- DBus::MessageIter ri = call.reader();
-
- map_crash_report_t argin1; ri >> argin1;
- bool argout1 = Report(argin1, call.sender());
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << argout1;
- return reply;
- }
-
- DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call)
- {
- DBus::MessageIter ri = call.reader();
-
- std::string argin1; ri >> argin1;
- bool argout1 = DeleteDebugDump(argin1,call.sender());
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << argout1;
- return reply;
- }
-
- DBus::Message _GetJobResult_stub(const DBus::CallMessage &call)
- {
- DBus::MessageIter ri = call.reader();
- uint64_t job_id;
- ri >> job_id;
- map_crash_report_t report = GetJobResult(job_id,call.sender());
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << report;
- return reply;
- }
-
- DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call)
- {
- vector_map_string_string_t plugins_info;
- plugins_info = GetPluginsInfo();
- DBus::ReturnMessage reply(call);
- DBus::MessageIter wi = reply.writer();
- wi << plugins_info;
- return reply;
- }
+ DBus::Message _GetCrashInfos_stub(const DBus::CallMessage &call);
+ DBus::Message _CreateReport_stub(const DBus::CallMessage &call);
+ DBus::Message _Report_stub(const DBus::CallMessage &call);
+ DBus::Message _DeleteDebugDump_stub(const DBus::CallMessage &call);
+ DBus::Message _GetJobResult_stub(const DBus::CallMessage &call);
+ DBus::Message _GetPluginsInfo_stub(const DBus::CallMessage &call);
};
+#endif
diff --git a/lib/CommLayer/Makefile.am b/lib/CommLayer/Makefile.am
index 5a1fa503..f80683b3 100644
--- a/lib/CommLayer/Makefile.am
+++ b/lib/CommLayer/Makefile.am
@@ -1,20 +1,31 @@
lib_LTLIBRARIES = libABRTCommLayer.la
-libABRTCommLayer_la_SOURCES = CommLayerServer.h CommLayerServer.cpp \
- CommLayerServerSocket.h CommLayerServerSocket.cpp \
- CommLayerServerDBus.h CommLayerServerDBus.cpp \
- DBusServerProxy.h Observer.h DBusCommon.h \
- CommLayerInner.h CommLayerInner.cpp \
- DBusClientProxy.h CommLayerClientDBus.h CommLayerClientDBus.cpp
-
-libABRTCommLayer_la_LIBADD = ../../lib/MiddleWare/libABRTMiddleWare.la $(DL_LIBS) $(DBUSCPP_LIBS)
+
+libABRTCommLayer_la_SOURCES = \
+ CommLayerServer.h CommLayerServer.cpp \
+ CommLayerServerSocket.h CommLayerServerSocket.cpp \
+ CommLayerServerDBus.h CommLayerServerDBus.cpp \
+ DBusServerProxy.h DBusServerProxy.cpp \
+ DBusClientProxy.h DBusClientProxy.cpp \
+ CommLayerInner.h CommLayerInner.cpp \
+ CommLayerClientDBus.h CommLayerClientDBus.cpp \
+ Observer.h \
+ DBusCommon.h
+libABRTCommLayer_la_LIBADD = \
+ ../../lib/MiddleWare/libABRTMiddleWare.la \
+ $(DL_LIBS) $(DBUSCPP_LIBS)
libABRTCommLayer_la_LDFLAGS = -version-info 0:1:0
-libABRTCommLayer_la_CPPFLAGS = -Wall -Werror -I$(srcdir)/../../lib/MiddleWare\
- -I$(srcdir)/../../lib/DBus -I$(srcdir)/../../inc\
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DCONF_DIR=\"$(CONF_DIR)\" -D_GNU_SOURCE \
- -DVAR_RUN=\"$(VAR_RUN)\"
+libABRTCommLayer_la_CPPFLAGS = \
+ -Wall -Werror \
+ -I$(srcdir)/../../inc \
+ -I$(srcdir)/../../lib/MiddleWare \
+ -I$(srcdir)/../../lib/DBus \
+ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
+ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
+ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
+ -DCONF_DIR=\"$(CONF_DIR)\" \
+ -DVAR_RUN=\"$(VAR_RUN)\" \
+ $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \
+ -D_GNU_SOURCE
#check_PROGRAMS = test
#test_SOURCES = test.cpp
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
index 016d6ead..b84dcba1 100644
--- a/lib/MiddleWare/Makefile.am
+++ b/lib/MiddleWare/Makefile.am
@@ -1,20 +1,37 @@
lib_LTLIBRARIES = libABRTMiddleWare.la
-libABRTMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \
- PluginManager.h ABRTPlugin.cpp \
- ABRTPlugin.h DynamicLibrary.cpp \
- DynamicLibrary.h \
- RPM.cpp RPM.h Plugin.h \
- MiddleWareTypes.h Action.h Database.h \
- Reporter.h Analyzer.h
-libABRTMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libABRTUtils.la $(RPM_LIBS)
+
+libABRTMiddleWare_la_SOURCES = \
+ ABRTPlugin.cpp ABRTPlugin.h \
+ DynamicLibrary.cpp DynamicLibrary.h \
+ RPM.cpp RPM.h \
+ Plugin.h MiddleWareTypes.h Action.h Database.h \
+ Reporter.h Analyzer.h
+libABRTMiddleWare_la_LIBADD = \
+ $(DL_LIBS) \
+ ../Utils/libABRTUtils.la \
+ $(RPM_LIBS)
libABRTMiddleWare_la_LDFLAGS = -version-info 0:1:0
-libABRTMiddleWare_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils -I$(srcdir)/../CommLayer $(RPM_CFLAGS)
+libABRTMiddleWare_la_CPPFLAGS = \
+ -I$(srcdir)/../../inc \
+ -I$(srcdir)/../Utils \
+ -I$(srcdir)/../CommLayer \
+ $(RPM_CFLAGS)
-check_PROGRAMS = test
-test_SOURCES = test.cpp
-test_LDADD = ../Utils/libABRTUtils.la libABRTMiddleWare.la $(DL_LIBS) $(RPM_LIBS) ../CommLayer/libABRTCommLayer.la
-test_CPPFLAGS = -I$(srcdir)/../Utils -I$(srcdir)/../../inc -I$(srcdir)/../CommLayer\
- -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
- -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
- -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
- -DCONF_DIR=\"$(CONF_DIR)\"
+# disabled: MiddleWare.* is moved to src/Daemon/ now
+#
+#check_PROGRAMS = test
+#
+#test_SOURCES = test.cpp
+#test_LDADD = \
+# ../Utils/libABRTUtils.la \
+# ../CommLayer/libABRTCommLayer.la \
+# libABRTMiddleWare.la \
+# $(DL_LIBS) $(RPM_LIBS)
+#test_CPPFLAGS = \
+# -I$(srcdir)/../../inc \
+# -I$(srcdir)/../Utils \
+# -I$(srcdir)/../CommLayer\
+# -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
+# -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
+# -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \
+# -DCONF_DIR=\"$(CONF_DIR)\"
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
deleted file mode 100644
index 7f1250cd..00000000
--- a/lib/MiddleWare/MiddleWare.cpp
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- MiddleWare.cpp
-
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@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 "MiddleWare.h"
-#include "DebugDump.h"
-#include "ABRTException.h"
-#include "CommLayerInner.h"
-
-CMiddleWare::CMiddleWare(const std::string& pPluginsConfDir,
- const std::string& pPluginsLibDir) :
- m_pPluginManager(NULL),
- m_bOpenGPGCheck(true),
- m_sPluginsConfDir(pPluginsConfDir)
-{
- m_pPluginManager = new CPluginManager(pPluginsConfDir, pPluginsLibDir);
- m_pPluginManager->LoadPlugins();
-}
-
-CMiddleWare::~CMiddleWare()
-{
- m_pPluginManager->UnLoadPlugins();
- delete m_pPluginManager;
-}
-
-void CMiddleWare::DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_report_t& pCrashReport)
-{
- std::string fileName;
- std::string content;
- bool isTextFile;
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
-
- if (!dd.Exist(FILENAME_ARCHITECTURE) ||
- !dd.Exist(FILENAME_KERNEL) ||
- !dd.Exist(FILENAME_PACKAGE) ||
- !dd.Exist(FILENAME_RELEASE) ||
- !dd.Exist(FILENAME_EXECUTABLE))
- {
- dd.Close();
- throw CABRTException(EXCEP_ERROR, "CMiddleWare::DebugDumpToCrashReport(): One or more of important file(s)'re missing.");
- }
- pCrashReport.clear();
- dd.InitGetNextFile();
- while (dd.GetNextFile(fileName, content, isTextFile))
- {
- if (!isTextFile)
- {
- add_crash_data_to_crash_report(pCrashReport,
- fileName,
- CD_BIN,
- CD_ISNOTEDITABLE,
- pDebugDumpDir + "/" + fileName);
- }
- else
- {
- if (fileName == FILENAME_ARCHITECTURE ||
- fileName == FILENAME_KERNEL ||
- fileName == FILENAME_PACKAGE ||
- fileName == FILENAME_RELEASE ||
- fileName == FILENAME_EXECUTABLE)
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISNOTEDITABLE, content);
- }
- else if (fileName != FILENAME_UID &&
- fileName != FILENAME_ANALYZER &&
- fileName != FILENAME_TIME &&
- fileName != FILENAME_DESCRIPTION )
- {
- if (content.length() < CD_ATT_SIZE)
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISEDITABLE, content);
- }
- else
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_ATT, CD_ISEDITABLE, content);
- }
- }
- }
- }
- dd.Close();
-}
-
-void CMiddleWare::RegisterPlugin(const std::string& pName)
-{
- m_pPluginManager->RegisterPlugin(pName);
-}
-
-void CMiddleWare::UnRegisterPlugin(const std::string& pName)
-{
- m_pPluginManager->UnRegisterPlugin(pName);
-}
-
-void CMiddleWare::SetPluginSettings(const std::string& pName,
- const map_plugin_settings_t& pSettings)
-{
- m_pPluginManager->SetPluginSettings(pName, pSettings);
-}
-
-map_plugin_settings_t CMiddleWare::GetPluginSettings(const std::string& pName)
-{
- return m_pPluginManager->GetPluginSettings(pName);
-}
-
-std::string CMiddleWare::GetLocalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir)
-{
- CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
- return analyzer->GetLocalUUID(pDebugDumpDir);
-}
-
-std::string CMiddleWare::GetGlobalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir)
-{
- CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
- return analyzer->GetGlobalUUID(pDebugDumpDir);
-}
-
-void CMiddleWare::CreateReport(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir)
-{
- CAnalyzer* analyzer = m_pPluginManager->GetAnalyzer(pAnalyzer);
- analyzer->CreateReport(pDebugDumpDir);
-}
-
-CMiddleWare::mw_result_t CMiddleWare::CreateCrashReport(const std::string& pUUID,
- const std::string& pUID,
- map_crash_report_t& pCrashReport)
-{
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- database_row_t row;
- database->Connect();
- row = database->GetUUIDData(pUUID, pUID);
- database->DisConnect();
- CDebugDump dd;
-
- if (pUUID == "" || row.m_sUUID != pUUID)
- {
- comm_layer_inner_warning("CMiddleWare::CreateCrashReport(): UUID '"+pUUID+"' is not in database.");
- return MW_IN_DB_ERROR;
- }
-
- try
- {
- std::string analyzer;
- std::string gUUID;
-
- dd.Open(row.m_sDebugDumpDir);
- dd.LoadText(FILENAME_ANALYZER, analyzer);
- dd.Close();
-
- CreateReport(analyzer, row.m_sDebugDumpDir);
-
- gUUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir);
-
- RunAnalyzerActions(analyzer, row.m_sDebugDumpDir);
- DebugDumpToCrashReport(row.m_sDebugDumpDir, 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);
- add_crash_data_to_crash_report(pCrashReport, CD_MWUID, CD_SYS, CD_ISNOTEDITABLE, pUID);
- add_crash_data_to_crash_report(pCrashReport, CD_MWUUID, CD_SYS, CD_ISNOTEDITABLE, pUUID);
- add_crash_data_to_crash_report(pCrashReport, CD_COMMENT, CD_TXT, CD_ISEDITABLE, "");
- add_crash_data_to_crash_report(pCrashReport, CD_REPRODUCE, CD_TXT, CD_ISEDITABLE, "1.\n2.\n3.\n");
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::CreateCrashReport(): " + e.what());
- if (e.type() == EXCEP_DD_OPEN)
- {
- return MW_ERROR;
- }
- else if (e.type() == EXCEP_DD_LOAD)
- {
- return MW_FILE_ERROR;
- }
- return MW_CORRUPTED;
- }
-
- return MW_OK;
-}
-
-void CMiddleWare::RunAction(const std::string& pActionDir,
- const std::string& pPluginName,
- const std::string& pPluginArgs)
-{
- try
- {
- CAction* action = m_pPluginManager->GetAction(pPluginName);
-
- action->Run(pActionDir, pPluginArgs);
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::RunAction(): " + e.what());
- comm_layer_inner_status("Execution of '"+pPluginName+"' was not successful: " + e.what());
- }
-
-}
-
-void CMiddleWare::RunActionsAndReporters(const std::string& pDebugDumpDir)
-{
- vector_actions_and_reporters_t::iterator it_ar;
- for (it_ar = m_vectorActionsAndReporters.begin(); it_ar != m_vectorActionsAndReporters.end(); it_ar++)
- {
- try
- {
- if (m_pPluginManager->GetPluginType((*it_ar).first) == REPORTER)
- {
- CReporter* reporter = m_pPluginManager->GetReporter((*it_ar).first);
-
- map_crash_report_t crashReport;
- DebugDumpToCrashReport(pDebugDumpDir, crashReport);
- reporter->Report(crashReport, (*it_ar).second);
- }
- else if (m_pPluginManager->GetPluginType((*it_ar).first) == ACTION)
- {
- CAction* action = m_pPluginManager->GetAction((*it_ar).first);
- action->Run(pDebugDumpDir, (*it_ar).second);
- }
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::RunActionsAndReporters(): " + e.what());
- comm_layer_inner_status("Activation of plugin '"+(*it_ar).first+"' was not successful: " + e.what());
- }
- }
-}
-
-void CMiddleWare::Report(const map_crash_report_t& pCrashReport)
-{
- Report(pCrashReport, m_sPluginsConfDir);
-}
-
-void CMiddleWare::Report(const map_crash_report_t& pCrashReport,
- const std::string& pPluginsConfDir)
-{
- if (pCrashReport.find(CD_MWANALYZER) == pCrashReport.end() ||
- pCrashReport.find(CD_MWUID) == pCrashReport.end() ||
- pCrashReport.find(CD_MWUUID) == pCrashReport.end())
- {
- throw CABRTException(EXCEP_ERROR, "CMiddleWare::Report(): System data are missing in crash report.");
- }
- std::string analyzer = pCrashReport.find(CD_MWANALYZER)->second[CD_CONTENT];
- std::string UID = pCrashReport.find(CD_MWUID)->second[CD_CONTENT];
- std::string UUID = pCrashReport.find(CD_MWUUID)->second[CD_CONTENT];
-
- if (m_mapAnalyzerActionsAndReporters.find(analyzer) != m_mapAnalyzerActionsAndReporters.end())
- {
- vector_actions_and_reporters_t::iterator it_r;
- for (it_r = m_mapAnalyzerActionsAndReporters[analyzer].begin();
- it_r != m_mapAnalyzerActionsAndReporters[analyzer].end();
- it_r++)
- {
- try
- {
- if (m_pPluginManager->GetPluginType((*it_r).first) == REPORTER)
- {
- CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first);
-
- if (pPluginsConfDir == m_sPluginsConfDir)
- {
- reporter->Report(pCrashReport, (*it_r).second);
- }
- else
- {
- reporter->LoadSettings(pPluginsConfDir + "/" + (*it_r).first + "." + PLUGINS_CONF_EXTENSION);
- reporter->Report(pCrashReport, (*it_r).second);
- reporter->LoadSettings(m_sPluginsConfDir + "/" + (*it_r).first + "." + PLUGINS_CONF_EXTENSION);
- }
- }
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::Report(): " + e.what());
- comm_layer_inner_status("Reporting via '"+(*it_r).first+"' was not successful: " + e.what());
- }
- }
- }
-
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- database->Connect();
- database->SetReported(UUID, UID);
- database->DisConnect();
-}
-
-void CMiddleWare::DeleteDebugDumpDir(const std::string& pDebugDumpDir)
-{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.Delete();
- dd.Close();
-}
-
-std::string CMiddleWare::DeleteCrashInfo(const std::string& pUUID,
- const std::string& pUID)
-{
- database_row_t row;
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- database->Connect();
- row = database->GetUUIDData(pUUID, pUID);
- database->Delete(pUUID, pUID);
- database->DisConnect();
-
- return row.m_sDebugDumpDir;
-}
-
-
-bool CMiddleWare::IsDebugDumpSaved(const std::string& pUID,
- const std::string& pDebugDumpDir)
-{
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- vector_database_rows_t rows;
- database->Connect();
- rows = database->GetUIDData(pUID);
- database->DisConnect();
-
- int ii;
- bool found = false;
- for (ii = 0; ii < rows.size(); ii++)
- {
- if (rows[ii].m_sDebugDumpDir == pDebugDumpDir)
- {
- found = true;
- break;
- }
- }
-
- return found;
-}
-
-CMiddleWare::mw_result_t CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutable,
- const std::string& pDebugDumpDir)
-{
- std::string package;
- std::string packageName;
-
- if (pExecutable == "kernel")
- {
- packageName = package = "kernel";
- }
- else
- {
- package = m_RPM.GetPackage(pExecutable);
- packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1));
- if (packageName == "" ||
- (m_setBlackList.find(packageName) != m_setBlackList.end()))
- {
- if (packageName == "")
- {
- comm_layer_inner_debug("Executable doesn't belong to any package");
- return MW_PACKAGE_ERROR;
- }
- comm_layer_inner_debug("Blacklisted package");
- return MW_BLACKLISTED;
- }
- if (m_bOpenGPGCheck)
- {
- if (!m_RPM.CheckFingerprint(packageName) ||
- !m_RPM.CheckHash(packageName, pExecutable))
- {
- comm_layer_inner_debug("Can not find package");
- return MW_GPG_ERROR;
- }
- }
- }
-
- std::string description = m_RPM.GetDescription(packageName);
-
- CDebugDump dd;
- try
- {
- dd.Open(pDebugDumpDir);
- dd.SaveText(FILENAME_PACKAGE, package);
- dd.SaveText(FILENAME_DESCRIPTION, description);
- dd.Close();
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::SavePackageDescriptionToDebugDump(): " + e.what());
- if (e.type() == EXCEP_DD_SAVE)
- {
- dd.Close();
- return MW_FILE_ERROR;
- }
- return MW_ERROR;
- }
-
- return MW_OK;
-}
-
-void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir)
-{
- if (m_mapAnalyzerActionsAndReporters.find(pAnalyzer) != m_mapAnalyzerActionsAndReporters.end())
- {
- vector_actions_and_reporters_t::iterator it_a;
- for (it_a = m_mapAnalyzerActionsAndReporters[pAnalyzer].begin();
- it_a != m_mapAnalyzerActionsAndReporters[pAnalyzer].end();
- it_a++)
- {
- try
- {
- if (m_pPluginManager->GetPluginType((*it_a).first) == ACTION)
- {
- CAction* action = m_pPluginManager->GetAction((*it_a).first);
-
- action->Run(pDebugDumpDir, (*it_a).second);
- }
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::RunAnalyzerActions(): " + e.what());
- comm_layer_inner_status("Action performed by '"+(*it_a).first+"' was not successful: " + e.what());
- }
- }
- }
-}
-
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDumpToDatabase(const std::string& pUUID,
- const std::string& pUID,
- const std::string& pTime,
- const std::string& pDebugDumpDir,
- map_crash_info_t& pCrashInfo)
-{
- mw_result_t res;
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- database_row_t row;
- database->Connect();
- database->Insert(pUUID, pUID, pDebugDumpDir, pTime);
- row = database->GetUUIDData(pUUID, pUID);
- database->DisConnect();
- res = GetCrashInfo(pUUID, pUID, pCrashInfo);
- if (row.m_sReported == "1")
- {
- comm_layer_inner_debug("Crash is already reported");
- return MW_REPORTED;
- }
- if (row.m_sCount != "1")
- {
- comm_layer_inner_debug("Crash is in database already");
- return MW_OCCURED;
- }
- return res;
-}
-
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir)
-{
- map_crash_info_t info;
- return SaveDebugDump(pDebugDumpDir, info);
-}
-
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir,
- map_crash_info_t& pCrashInfo)
-{
- std::string lUUID;
- std::string UID;
- std::string time;
- std::string analyzer;
- std::string executable;
- CDebugDump dd;
- mw_result_t res;
-
- try
- {
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_TIME, time);
- dd.LoadText(FILENAME_UID, UID);
- dd.LoadText(FILENAME_ANALYZER, analyzer);
- dd.LoadText(FILENAME_EXECUTABLE, executable);
- dd.Close();
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::SaveDebugDump(): " + e.what());
- if (e.type() == EXCEP_DD_SAVE)
- {
- dd.Close();
- return MW_FILE_ERROR;
- }
- return MW_ERROR;
- }
-
- if (IsDebugDumpSaved(UID, pDebugDumpDir))
- {
- return MW_IN_DB;
- }
- if ((res = SavePackageDescriptionToDebugDump(executable, pDebugDumpDir)) != MW_OK)
- {
- return res;
- }
-
- lUUID = GetLocalUUID(analyzer, pDebugDumpDir);
-
- return SaveDebugDumpToDatabase(lUUID, UID, time, pDebugDumpDir, pCrashInfo);
-}
-
-CMiddleWare::mw_result_t CMiddleWare::GetCrashInfo(const std::string& pUUID,
- const std::string& pUID,
- map_crash_info_t& pCrashInfo)
-{
- pCrashInfo.clear();
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- database_row_t row;
- database->Connect();
- row = database->GetUUIDData(pUUID, pUID);
- database->DisConnect();
-
- CDebugDump dd;
- std::string package;
- std::string executable;
- std::string description;
-
- try
- {
- dd.Open(row.m_sDebugDumpDir);
- dd.LoadText(FILENAME_EXECUTABLE, executable);
- dd.LoadText(FILENAME_PACKAGE, package);
- dd.LoadText(FILENAME_DESCRIPTION, description);
- dd.Close();
- }
- catch (CABRTException& e)
- {
- comm_layer_inner_warning("CMiddleWare::GetCrashInfo(): " + e.what());
- if (e.type() == EXCEP_DD_LOAD)
- {
- dd.Close();
- return MW_FILE_ERROR;
- }
- return MW_ERROR;
- }
- add_crash_data_to_crash_info(pCrashInfo, CD_EXECUTABLE, executable);
- add_crash_data_to_crash_info(pCrashInfo, CD_PACKAGE, package);
- add_crash_data_to_crash_info(pCrashInfo, CD_DESCRIPTION, description);
- add_crash_data_to_crash_info(pCrashInfo, CD_UUID, row.m_sUUID);
- add_crash_data_to_crash_info(pCrashInfo, CD_UID, row.m_sUID);
- add_crash_data_to_crash_info(pCrashInfo, CD_COUNT, row.m_sCount);
- add_crash_data_to_crash_info(pCrashInfo, CD_TIME, row.m_sTime);
- add_crash_data_to_crash_info(pCrashInfo, CD_REPORTED, row.m_sReported);
- add_crash_data_to_crash_info(pCrashInfo, CD_MWDDD, row.m_sDebugDumpDir);
-
- return MW_OK;
-}
-
-vector_pair_string_string_t CMiddleWare::GetUUIDsOfCrash(const std::string& pUID)
-{
- CDatabase* database = m_pPluginManager->GetDatabase(m_sDatabase);
- vector_database_rows_t rows;
- database->Connect();
- rows = database->GetUIDData(pUID);
- database->DisConnect();
-
- vector_pair_string_string_t UUIDsUIDs;
- int ii;
- for (ii = 0; ii < rows.size(); ii++)
- {
- UUIDsUIDs.push_back(make_pair(rows[ii].m_sUUID, rows[ii].m_sUID));
- }
-
- return UUIDsUIDs;
-}
-
-vector_map_string_string_t CMiddleWare::GetPluginsInfo()
-{
- return m_pPluginManager->GetPluginsInfo();
-}
-
-void CMiddleWare::SetOpenGPGCheck(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::AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
- const std::string& pAnalyzerOrReporter,
- const std::string& pArgs)
-{
- m_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs));
-}
-
-void CMiddleWare::AddActionOrReporter(const std::string& pActionOrReporter,
- const std::string& pArgs)
-{
- m_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs));
-}
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
deleted file mode 100644
index 8b7376d3..00000000
--- a/lib/MiddleWare/MiddleWare.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- MiddleWare.h - header file for MiddleWare library. It wraps plugins and
- take case of them.
-
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@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.
- */
-
-
-#ifndef MIDDLEWARE_H_
-#define MIDDLEWARE_H_
-
-#include "PluginManager.h"
-#include "CrashTypes.h"
-#include "MiddleWareTypes.h"
-#include "RPM.h"
-
-/**
- * A very important class :-). It manages part of user demands like creating
- * reports, or reporting stuff somewhere etc.
- */
-class CMiddleWare
-{
- public:
- /**
- * An emun contains all return codes.
- */
- typedef enum { MW_ERROR, /**< Common error.*/
- MW_OK, /**< No error.*/
- MW_BLACKLISTED, /**< Package is blacklisted.*/
- MW_CORRUPTED, /**< Debugdump directory is corrupted.*/
- MW_PACKAGE_ERROR, /**< Cannot determine package name.*/
- MW_GPG_ERROR, /**< Package is not signed properly.*/
- MW_REPORTED, /**< Crash is already reported.*/
- MW_OCCURED, /**< Crash occurred in the past, but it is not reported yet.*/
- MW_IN_DB, /**< Debugdump directory is already saved in a database.*/
- MW_IN_DB_ERROR, /**< Error while working with a database.*/
- MW_FILE_ERROR /**< Error when trying open debugdump directory or
- when trying open file in debug dump directory..*/
- } mw_result_t;
-
- private:
- typedef set_strings_t set_blacklist_t;
- typedef set_strings_t set_enabled_plugins_t;
- typedef std::vector<pair_string_string_t> vector_pairt_strings_t;
- typedef vector_pairt_strings_t vector_actions_and_reporters_t;
- typedef std::map<std::string, vector_actions_and_reporters_t> map_analyzer_actions_and_reporters_t;
-
- /**
- * An instance of CPluginManager. When MiddleWare wants to do something
- * with plugins, it calls the plugin manager.
- * @see PluginManager.h
- */
- CPluginManager* m_pPluginManager;
- /**
- * An instance of CRPM used for package checking.
- * @see RPM.h
- */
- CRPM m_RPM;
- /**
- * A set of blacklisted packages.
- */
- set_blacklist_t m_setBlackList;
- /**
- * A name of database plugin, which is used for metadata.
- */
- std::string m_sDatabase;
- /**
- * A map, which associates particular analyzer to one or more
- * action or reporter plugins. These are activated when a crash, which
- * is maintained by particular analyzer, occurs.
- */
- map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters;
- /**
- * A vector of one or more action or reporter plugins. These are
- * activated when any crash occurs.
- */
- vector_actions_and_reporters_t m_vectorActionsAndReporters;
- /**
- * Plugins configuration directory (e.g. /etc/abrt/plugins, ...).
- */
- std::string m_sPluginsConfDir;
- /**
- * Check GPG finger print?
- */
- bool m_bOpenGPGCheck;
- /**
- * A method, which gets a local UUID from particular analyzer plugin.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- * @return A local UUID.
- */
- std::string GetLocalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir);
- /**
- * A method, which gets a global UUID from particular analyzer plugin.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- * @return A global UUID.
- */
- std::string GetGlobalUUID(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir);
- /**
- * A method, which takes care of getting all additional data needed
- * for computing UUIDs and creating a report for particular analyzer
- * plugin. This report could be send somewhere afterwards.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pDebugDumpPath A debugdump dir containing all necessary data.
- */
- void CreateReport(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir);
- /**
- * A method, which executes all action plugins, which are associated to
- * particular analyzer plugin.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pDebugDumpPath A debugdump dir containing all necessary data.
- */
- void RunAnalyzerActions(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir);
- /**
- * A method, which transforms a debugdump direcortry to inner crash
- * report form. This form is used for later reporting.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- * @param pCrashReport A created crash report.
- */
- void DebugDumpToCrashReport(const std::string& pDebugDumpDir,
- map_crash_report_t& pCrashReport);
- /**
- * A method, which checks is particular debugdump directory is saved
- * in database. This check is done together with an UID of an user.
- * @param pUID an UID of an user.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- * @return It returns true if debugdump dir is already saved, otherwise
- * it returns false.
- */
- bool IsDebugDumpSaved(const std::string& pUID,
- const std::string& pDebugDumpDir);
- /**
- * A method, which gets a package name from executable name and saves
- * package description to particular debugdump directory of a crash.
- * @param pExecutable A name of crashed application.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecutable,
- const std::string& pDebugDumpDir);
- /**
- * A method, which save a debugdump into database. If a saving is
- * successful, then a crash info is filled. Otherwise the crash info is
- * not changed.
- * @param pUUID A local UUID of a crash.
- * @param pUID An UID of an user.
- * @param pTime Time when a crash occurs.
- * @param pDebugDumpPath A debugdump path.
- * @param pCrashInfo A filled crash info.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t SaveDebugDumpToDatabase(const std::string& pUUID,
- const std::string& pUID,
- const std::string& pTime,
- const std::string& pDebugDumpDir,
- map_crash_info_t& pCrashInfo);
-
- public:
- /**
- * A constructor.
- * @param pPluginsConfDir A plugins configuration directory.
- * @param pPluginsLibDir A plugins library directory.
- */
- CMiddleWare(const std::string& pPluginsConfDir,
- const std::string& pPluginsLibDir);
- /**
- * A destructor.
- */
- ~CMiddleWare();
- /**
- * A method, which registers particular plugin.
- * @param pName A plugin name.
- */
- void RegisterPlugin(const std::string& pName);
- /**
- * A method, which unregister particular plugin.
- * @param pName A plugin name.
- */
- void UnRegisterPlugin(const std::string& pName);
- /**
- * A method, which sets up a plugin.
- * @param pName A plugin name.
- * @param pSettings A plugin's settings.
- */
- void SetPluginSettings(const std::string& pName,
- const map_plugin_settings_t& pSettings);
- /**
- * A method, which returns plugin's settings.
- * @param pName A plugin name.
- * @return Plugin's settings
- */
- map_plugin_settings_t GetPluginSettings(const std::string& pName);
- /**
- * A method, which gets all plugins info (event those plugins which are
- * disabled). It can be send via DBus to GUI and displayed to an user.
- * Then a user can fill all needed informations like URLs etc.
- * @return A vector of maps <key, vaule>
- */
- vector_map_string_string_t GetPluginsInfo();
- /**
- * A method, which takes care of getting all additional data needed
- * for computing UUIDs and creating a report for particular analyzer
- * plugin. This report could be send somewhere afterwards. If a creation
- * is successful, then a crash report is filled.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pDebugDumpPath A debugdump dir containing all necessary data.
- * @param pCrashReport A filled crash report.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t CreateCrashReport(const std::string& pUUID,
- const std::string& pUID,
- map_crash_report_t& pCrashReport);
- /**
- * A method, which activate particular action plugin.
- * @param pActionDir A directory, which is passed as working to a action plugin.
- * @param pPluginName An action plugin name.
- * @param pPluginArgs Action plugin's arguments.
- */
- void RunAction(const std::string& pActionDir,
- const std::string& pPluginName,
- const std::string& pPluginArgs);
- /**
- * A method, which activate all action and reporter plugins when any
- * crash occurs.
- * @param pDebugDumpDir A debugdump dir containing all necessary data.
- */
- void RunActionsAndReporters(const std::string& pDebugDumpDir);
- /**
- * A method, which reports a crash report to particular receiver.
- * @param pCrashReport A crash report.
- */
- void Report(const map_crash_report_t& pCrashReport);
- /**
- * A method, which reports a crash report to particular receiver. It
- * takes a path where settings of reporter are stored (e.g. $HOME/.abrt,
- * ...).
- * @param pCrashReport A crash report.
- * @param pSettingsPath A path to setting files.
- */
- void Report(const map_crash_report_t& pCrashReport,
- const std::string& pSettingsPath);
- /**
- * A method, which deletes particular debugdump directory.
- * @param pDebugDumpDir A debugdump directory.
- */
- void DeleteDebugDumpDir(const std::string& pDebugDumpDir);
- /**
- * A method, which delete a row from database. If a deleting is
- * successfull, it returns a debugdump directort, which is not
- * deleted. Otherwise, it returns empty string.
- * @param pUUID A local UUID of a crash.
- * @param pUID An UID of an user.
- * @return A debugdump directory.
- */
- std::string DeleteCrashInfo(const std::string& pUUID,
- const std::string& pUID);
- /**
- * A method, whis saves debugdump into database.
- * @param pDebugDumpDir A debugdump directory.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t SaveDebugDump(const std::string& pDebugDumpDir);
- /**
- * A method, whis saves debugdump into database. If saving is sucessful
- * it fills crash info.
- * @param pDebugDumpDir A debugdump directory.
- * @param pCrashInfo A crash info.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t SaveDebugDump(const std::string& pDebugDumpDir,
- map_crash_info_t& pCrashInfo);
- /**
- * A method, which gets one crash info. If a getting is successful,
- * then a crash info is filled.
- * @param pUUID A local UUID of a crash.
- * @param pUID An UID of an user.
- * @param pCrashInfo A crash info.
- * @return It return results of operation. See mw_result_t.
- */
- mw_result_t GetCrashInfo(const std::string& pUUID,
- const std::string& pUID,
- map_crash_info_t& pCrashInfo);
- /**
- * A method, which gets all local UUIDs and UIDs of crashes. These crashes
- * occurred when a particular user was logged in.
- * @param pUID an UID of an user.
- * @return A vector of pairs (local UUID, UID).
- */
- vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID);
- /**
- * A method, which set a GPG finger print check.
- * @param pCheck Is it enabled?
- */
- void SetOpenGPGCheck(bool pCheck);
- /**
- * A method, which sets a name of database.
- * @param pDatabase A database name.
- */
- void SetDatabase(const std::string& pDatabase);
- /**
- * A method, which adds one path to a GPG public key into MW's set.
- * @param pKey A path to a GPG public key.
- */
- void AddOpenGPGPublicKey(const std::string& pKey);
- /**
- * A method, which adds one blacklisted package.
- */
- void AddBlackListedPackage(const std::string& pPackage);
- /**
- * A method, which adds one association among alanyzer plugin and its
- * action and reporter plugins.
- * @param pAnalyzer A name of an analyzer plugin.
- * @param pActionOrReporter A name of an action or reporter plugin.
- * @param pArgs An arguments for action or reporter plugin.
- */
- void AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
- const std::string& pActionOrReporter,
- const std::string& pArgs);
- /**
- * A method, which adds action and reporter plugins, which are activated
- * when any crash occurs.
- * @param pActionOrReporter A name of an action or reporter plugin.
- * @param pArgs An arguments for action or reporter plugin.
- */
- void AddActionOrReporter(const std::string& pActionOrReporter,
- const std::string& pArgs);
-};
-
-#endif /*MIDDLEWARE_H_*/
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp
deleted file mode 100644
index 81207f94..00000000
--- a/lib/MiddleWare/PluginManager.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- PluginManager.cpp
-
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@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 <iostream>
-#include "PluginManager.h"
-#include "ABRTException.h"
-#include "CommLayerInner.h"
-#include <dirent.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-/**
- * Text reprezentation of plugin types.
- */
-static const char* const plugin_type_str_t[] = { "Analyzer", "Action", "Reporter", "Database" };
-
-
-CPluginManager::CPluginManager(
- const std::string& pPluginsConfDir,
- const std::string& pPluginsLibDir)
-:
- m_sPluginsConfDir(pPluginsConfDir),
- m_sPluginsLibDir(pPluginsLibDir)
-{}
-
-CPluginManager::~CPluginManager()
-{}
-
-void CPluginManager::LoadPlugins()
-{
- DIR *dir = opendir(m_sPluginsLibDir.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()
-{
- map_abrt_plugins_t::iterator it_p;
- while ((it_p = m_mapABRTPlugins.begin()) != m_mapABRTPlugins.end())
- {
- std::string pluginName = it_p->first;
- UnLoadPlugin(pluginName);
- }
-}
-
-void CPluginManager::LoadPlugin(const std::string& pName)
-{
- if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end())
- {
- CABRTPlugin* abrtPlugin = NULL;
- try
- {
- std::string libPath = m_sPluginsLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION;
- abrtPlugin = new CABRTPlugin(libPath);
- if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER ||
- (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE))
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::LoadPlugin(): non-compatible plugin");
- }
- comm_layer_inner_debug("Plugin " + pName + " (" + abrtPlugin->GetVersion() + ") succesfully loaded.");
- m_mapABRTPlugins[pName] = abrtPlugin;
- }
- catch (CABRTException& e)
- {
- if (abrtPlugin != NULL)
- {
- delete abrtPlugin;
- }
- comm_layer_inner_warning("CPluginManager::LoadPlugin(): " + e.what());
- comm_layer_inner_warning("Failed to load plugin " + pName);
- }
- }
-}
-
-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);
- comm_layer_inner_debug("Plugin " + pName + " sucessfully unloaded.");
- }
-}
-
-
-void CPluginManager::RegisterPlugin(const std::string& pName)
-{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
- {
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- std::string path = m_sPluginsConfDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION;
- CPlugin* plugin = m_mapABRTPlugins[pName]->PluginNew();
- try
- {
- plugin->Init();
- plugin->LoadSettings(path);
- }
- catch (std::string sError)
- {
- comm_layer_inner_warning("Can not initialize plugin " + pName + "("
- + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()])
- + ")");
- UnLoadPlugin(pName);
- return;
- }
- m_mapPlugins[pName] = plugin;
- comm_layer_inner_debug("Registered plugin " + pName + "("
- + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()])
- + ")");
- }
- }
-}
-
-void CPluginManager::UnRegisterPlugin(const std::string& pName)
-{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
- {
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
- {
- m_mapPlugins[pName]->DeInit();
- delete m_mapPlugins[pName];
- m_mapPlugins.erase(pName);
- comm_layer_inner_debug("UnRegistred plugin " + pName + "("
- + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()])
- + ")");
- }
- }
-}
-
-CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName)
-{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():"
- "Analyzer plugin: '"+pName+"' is not registered.");
- }
- if (m_mapABRTPlugins[pName]->GetType() != ANALYZER)
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():"
- "Plugin: '"+pName+"' is not analyzer plugin.");
- }
- return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]);
-}
-
-CReporter* CPluginManager::GetReporter(const std::string& pName)
-{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():"
- "Reporter plugin: '"+pName+"' is not registered.");
- }
- if (m_mapABRTPlugins[pName]->GetType() != REPORTER)
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():"
- "Plugin: '"+pName+"' is not reporter plugin.");
- }
- return dynamic_cast<CReporter*>(m_mapPlugins[pName]);
-}
-
-CAction* CPluginManager::GetAction(const std::string& pName)
-{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():"
- "Action plugin: '"+pName+"' is not registered.");
- }
- if (m_mapABRTPlugins[pName]->GetType() != ACTION)
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():"
- "Plugin: '"+pName+"' is not action plugin.");
- }
- return dynamic_cast<CAction*>(m_mapPlugins[pName]);
-}
-
-CDatabase* CPluginManager::GetDatabase(const std::string& pName)
-{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():"
- "Database plugin: '"+pName+"' is not registered.");
- }
- if (m_mapABRTPlugins[pName]->GetType() != DATABASE)
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():"
- "Plugin: '"+pName+"' is not database plugin.");
- }
- return dynamic_cast<CDatabase*>(m_mapPlugins[pName]);
-}
-
-plugin_type_t CPluginManager::GetPluginType(const std::string& pName)
-{
- if (m_mapPlugins.find(pName) == m_mapPlugins.end())
- {
- throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetPluginType():"
- "Plugin: '"+pName+"' is not registered.");
- }
- return m_mapABRTPlugins[pName]->GetType();
-}
-
-vector_map_string_string_t CPluginManager::GetPluginsInfo()
-{
- vector_map_string_string_t ret;
- map_abrt_plugins_t::iterator it_abrt_plugin;
- for (it_abrt_plugin = m_mapABRTPlugins.begin(); it_abrt_plugin != m_mapABRTPlugins.end(); it_abrt_plugin++)
- {
- map_string_string_t plugin_info;
-
- plugin_info["Enabled"] = (m_mapPlugins.find(it_abrt_plugin->second->GetName()) != m_mapPlugins.end()) ?
- "yes" : "no";
- plugin_info["Type"] = plugin_type_str_t[it_abrt_plugin->second->GetType()];
- plugin_info["Name"] = it_abrt_plugin->second->GetName();
- plugin_info["Version"] = it_abrt_plugin->second->GetVersion();
- plugin_info["Description"] = it_abrt_plugin->second->GetDescription();
- plugin_info["Email"] = it_abrt_plugin->second->GetEmail();
- plugin_info["WWW"] = it_abrt_plugin->second->GetWWW();
- plugin_info["GTKBuilder"] = it_abrt_plugin->second->GetGTKBuilder();
- ret.push_back(plugin_info);
-
- }
- return ret;
-}
-
-void CPluginManager::SetPluginSettings(const std::string& pName,
- const map_plugin_settings_t& pSettings)
-{
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
- {
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
- {
- m_mapPlugins[pName]->SetSettings(pSettings);
- }
- }
-}
-
-map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName)
-{
- map_plugin_settings_t ret;
- if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end())
- {
- if (m_mapPlugins.find(pName) != m_mapPlugins.end())
- {
- ret = m_mapPlugins[pName]->GetSettings();
- }
- }
- return ret;
-}
diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h
deleted file mode 100644
index 0be90d41..00000000
--- a/lib/MiddleWare/PluginManager.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- PluginManager.h - header file for plugin manager. it takes care about
- (un)loading plugins
-
- Copyright (C) 2009 Zdenek Prikryl (zprikryl@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.
- */
-
-#ifndef PLUGINMANAGER_H_
-#define PLUGINMANAGER_H_
-
-#include <map>
-#include <string>
-#include "ABRTPlugin.h"
-#include "Plugin.h"
-#include "Analyzer.h"
-#include "Reporter.h"
-#include "Database.h"
-#include "Action.h"
-#include "MiddleWareTypes.h"
-
-/**
- * A class. It takes care of loading, registering and manipulating with
- * plugins. When a plugin is loaded, its library is opened, but no plugin
- * instance is created. It is possible after plugin registration.
- */
-class CPluginManager
-{
- private:
- typedef std::map<std::string, CABRTPlugin*> map_abrt_plugins_t;
- typedef std::map<std::string, CPlugin*> map_plugins_t;
-
- /**
- * Loaded plugins. A key is a plugin name.
- */
- map_abrt_plugins_t m_mapABRTPlugins;
- /**
- * Registered plugins. A key is a plugin name.
- */
- map_plugins_t m_mapPlugins;
- /**
- * Plugins configuration directory (e.g. /etc/abrt/plugins, ...).
- */
- std::string m_sPluginsConfDir;
- /**
- * Plugins library directory (e.g. /usr/lib/abrt/plugins, ...).
- */
- std::string m_sPluginsLibDir;
-
- public:
- /**
- * A constructor.
- * @param pPluginsConfDir A plugins configuration directory.
- * @param pPluginsLibDir A plugins library directory.
- */
- CPluginManager(const std::string& pPluginsConfDir,
- const std::string& pPluginsLibDir);
- /**
- * A destructor.
- */
- ~CPluginManager();
- /**
- * A method, which loads all plugins in plugins library direcotry.
- */
- void LoadPlugins();
- /**
- * A method, which unregister and unload all loaded plugins.
- */
- void UnLoadPlugins();
- /**
- * A method, which loads particular plugin.
- * @param pName A plugin name.
- */
- void LoadPlugin(const std::string& pName);
- /**
- * A method, which unloads particular plugin.
- * @param pName A plugin name.
- */
- void UnLoadPlugin(const std::string& pName);
- /**
- * A method, which registers particular plugin.
- * @param pName A plugin name.
- */
- void RegisterPlugin(const std::string& pName);
- /**
- * A method, which unregister particular plugin.
- * @param pName A plugin name.
- */
- void UnRegisterPlugin(const std::string& pName);
- /**
- * A method, which returns instance of particular analyzer plugin.
- * @param pName A plugin name.
- * @return An analyzer plugin.
- */
- CAnalyzer* GetAnalyzer(const std::string& pName);
- /**
- * A method, which returns instance of particular reporter plugin.
- * @param pName A plugin name.
- * @return A reporter plugin.
- */
- CReporter* GetReporter(const std::string& pName);
- /**
- * A method, which returns instance of particular action plugin.
- * @param pName A plugin name.
- * @return An action plugin.
- */
- CAction* GetAction(const std::string& pName);
- /**
- * A method, which returns instance of particular database plugin.
- * @param pName A plugin name.
- * @return A database plugin.
- */
- CDatabase* GetDatabase(const std::string& pName);
- /**
- * A method, which returns type of particular plugin.
- * @param pName A plugin name.
- * @return A plugin type.
- */
- plugin_type_t GetPluginType(const std::string& pName);
- /**
- * A method, which gets all plugins info (event those plugins which are
- * disabled). It can be send via DBus to GUI and displayed to an user.
- * Then a user can fill all needed informations like URLs etc.
- * @return A vector of maps <key, vaule>
- */
- vector_map_string_string_t GetPluginsInfo();
- /**
- * A method, which sets up a plugin.
- * @param pName A plugin name.
- * @param pSettings A plugin's settings.
- */
- void SetPluginSettings(const std::string& pName,
- const map_plugin_settings_t& pSettings);
- /**
- * A method, which returns plugin's settings.
- * @param pName A plugin name.
- * @return Plugin's settings
- */
- map_plugin_settings_t GetPluginSettings(const std::string& pName);
-};
-
-#endif /*PLUGINMANAGER_H_*/
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 026e15ae..a47ca387 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -527,19 +527,20 @@ void CAnalyzerCCpp::Init()
}
if (m_sOldCorePattern[0] == '|')
{
- if (m_sOldCorePattern == CORE_PATTERN)
- {
- log("warning: %s already contains %s, "
- "did abrt daemon crash recently?",
- CORE_PATTERN_IFACE, CORE_PATTERN);
- /* There is no point in "restoring" CORE_PATTERN_IFACE
- * to CORE_PATTERN on exit. Will restore to a default value:
- */
- m_sOldCorePattern = "core";
- }
- log("warning: %s was already set to run a crash analyser (%s), "
- "abrt may interfere with it",
- CORE_PATTERN_IFACE, CORE_PATTERN);
+ if (m_sOldCorePattern == CORE_PATTERN)
+ {
+ log("warning: %s already contains %s, "
+ "did abrt daemon crash recently?",
+ CORE_PATTERN_IFACE, CORE_PATTERN);
+ /* There is no point in "restoring" CORE_PATTERN_IFACE
+ * to CORE_PATTERN on exit. Will restore to a default value:
+ */
+ m_sOldCorePattern = "core";
+ } else {
+ log("warning: %s was already set to run a crash analyser (%s), "
+ "abrt may interfere with it",
+ CORE_PATTERN_IFACE, CORE_PATTERN);
+ }
}
std::ofstream fOutCorePattern;
diff --git a/lib/Plugins/FileTransfer.conf b/lib/Plugins/FileTransfer.conf
index cf675e45..75e5671e 100644
--- a/lib/Plugins/FileTransfer.conf
+++ b/lib/Plugins/FileTransfer.conf
@@ -1,6 +1,6 @@
# Configuration of the file transfer reporter plugin
# it takes one parameter:
-# store - just save information about crash
+# store - just save information about crash
# upload - upload new crash or saved crashes to the specified url
# URL to upload the files to
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp
index 00d5803b..f696a994 100644
--- a/lib/Plugins/KerneloopsScanner.cpp
+++ b/lib/Plugins/KerneloopsScanner.cpp
@@ -62,7 +62,7 @@ void CKerneloopsScanner::SaveOopsToDebugDump()
try
{
- debugDump.Create(path, "0");
+ debugDump.Create(path, 0);
debugDump.SaveText(FILENAME_ANALYZER, "Kerneloops");
debugDump.SaveText(FILENAME_EXECUTABLE, "kernel");
debugDump.SaveText(FILENAME_KERNEL, oops.m_sVersion);
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
index 7c1ddbb1..a0616888 100644
--- a/lib/Plugins/Makefile.am
+++ b/lib/Plugins/Makefile.am
@@ -31,40 +31,40 @@ install-data-hook:
$(DESTDIR)$(sysconfdir)/abrt/plugins/Logger.conf
# CCpp
-libCCpp_la_SOURCES = CCpp.cpp CCpp.h
+libCCpp_la_SOURCES = CCpp.cpp CCpp.h
libCCpp_la_LDFLAGS = -avoid-version
libCCpp_la_LIBADD = $(NSS_LIBS)
libCCpp_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\" -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(NSS_CFLAGS)
# Kerneloops
-libKerneloops_la_SOURCES = Kerneloops.cpp Kerneloops.h
+libKerneloops_la_SOURCES = Kerneloops.cpp Kerneloops.h
libKerneloops_la_LDFLAGS = -avoid-version
libKerneloops_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils
# KerneloopsReporter
-libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h
+libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h
libKerneloopsReporter_la_LDFLAGS = -avoid-version
libKerneloopsReporter_la_LIBADD = $(CURL_LIBS)
libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare $(CURL_CFLAGS) -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
# KerneloopsScanner
-libKerneloopsScanner_la_SOURCES = KerneloopsScanner.cpp KerneloopsScanner.h KerneloopsSysLog.cpp KerneloopsSysLog.h
+libKerneloopsScanner_la_SOURCES = KerneloopsScanner.cpp KerneloopsScanner.h KerneloopsSysLog.cpp KerneloopsSysLog.h
libKerneloopsScanner_la_LDFLAGS = -avoid-version
libKerneloopsScanner_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\"
# Mailx
-libMailx_la_SOURCES = Mailx.cpp Mailx.h
+libMailx_la_SOURCES = Mailx.cpp Mailx.h
libMailx_la_LDFLAGS = -avoid-version
libMailx_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -I$(srcdir)/../CommLayer -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
# SQLite3
-libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h
+libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h
libSQLite3_la_LDFLAGS = -avoid-version
libSQLite3_la_LIBADD = $(SQLITE3_LIBS)
libSQLite3_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(SQLITE3_CFLAGS) -DLOCALSTATEDIR='"$(localstatedir)"'
# Logger
-libLogger_la_SOURCES = Logger.cpp Logger.h
+libLogger_la_SOURCES = Logger.cpp Logger.h
libLogger_la_LDFLAGS = -avoid-version
libLogger_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -I$(srcdir)/../CommLayer -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
@@ -77,7 +77,7 @@ libSOSreport_la_SOURCES = SOSreport.cpp SOSreport.h
libSOSreport_la_LDFLAGS = -avoid-version
# Bugzilla
-libBugzilla_la_SOURCES = Bugzilla.h Bugzilla.cpp
+libBugzilla_la_SOURCES = Bugzilla.h Bugzilla.cpp
libBugzilla_la_LIBADD = $(XMLRPC_CPP_LIBS) $(XMLRPC_CLIENT_CPP_LIBS) $(NSS_LIBS)
libBugzilla_la_LDFLAGS = -avoid-version
libBugzilla_la_CPPFLAGS = $(XMLRPC_CPP_CFLAGS) $(XMLRPC_CLIENT_CPP_CFLAGS) $(NSS_CFLAGS) -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\"
@@ -89,7 +89,7 @@ libPython_la_LDFLAGS = -avoid-version
libPython_la_CPPFLAGS = $(NSS_CFLAGS) -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils
# FileTrasfer
-libFileTransfer_la_SOURCES = FileTransfer.cpp FileTransfer.h
+libFileTransfer_la_SOURCES = FileTransfer.cpp FileTransfer.h
libFileTransfer_la_LDFLAGS = -avoid-version
libFileTransfer_la_LIBADD = $(CURL_LIBS)
libFileTransfer_la_CPPFLAGS = -I$(srcdir)/../CommLayer -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(CURL_CFLAGS) -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\"
diff --git a/lib/Plugins/abrt-Bugzilla.7 b/lib/Plugins/abrt-Bugzilla.7
index c3c0e902..99bb60d1 100644
--- a/lib/Plugins/abrt-Bugzilla.7
+++ b/lib/Plugins/abrt-Bugzilla.7
@@ -5,15 +5,15 @@ Bugzilla plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIBugzilla\fP plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIBugzilla\fP plugin
for \fIabrt\fP.
.P
-This plugin is used to report the crash to a Bugzilla instance. The
-plugin will determine the package name and distribution version. The
+This plugin is used to report the crash to a Bugzilla instance. The
+plugin will determine the package name and distribution version. The
crash data is attached to the bug report.
.SH INVOCATION
-The plugin is invoked in the \fIabrt.conf\fP configuration file.
+The plugin is invoked in the \fIabrt.conf\fP configuration file.
No parameters are necessary.
.SH CONFIGURATION
The \fIBugzilla.conf\fP configuration file contains several
@@ -39,5 +39,5 @@ ActionsAndReporters = Bugzilla
.IR abrt.conf (5),
.IR abrt-plugins (7)
.SH AUTHOR
-Written by Zdenek Prikryl <zprikryl@redhat.com>.
+Written by Zdenek Prikryl <zprikryl@redhat.com>.
Manual page written by Daniel Novotny <dnovotny@redhat.com>.
diff --git a/lib/Plugins/abrt-FileTransfer.7 b/lib/Plugins/abrt-FileTransfer.7
index b126c2c9..a04dd421 100644
--- a/lib/Plugins/abrt-FileTransfer.7
+++ b/lib/Plugins/abrt-FileTransfer.7
@@ -5,18 +5,18 @@ FileTransfer plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIFileTransfer\fP plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIFileTransfer\fP plugin
for \fIabrt\fP.
.P
This plugin is used to transfer the crash report to another
machine using a file transfer protocol. The protocols supported
-are FTP, FTPS, HTTP, HTTPS, SCP, SFTP, and TFTP.
+are FTP, FTPS, HTTP, HTTPS, SCP, SFTP, and TFTP.
.SH INVOCATION
.P
The plugin is invoked in the \fIabrt.conf\fP file, usually in the
\fIActionsAndReporters\fP option and/or the \fI[cron]\fP section.
-There are two modes of invocation:
+There are two modes of invocation:
.P
* If you use the parameter
\fI"store"\fP, the plugin stores a record of the occurrence of
@@ -27,12 +27,12 @@ plugin will iterate through the internal list and will send
every recorded crash to the server specified in the \fIFileTransfer.conf\fP
configuration file. After that, the internal list is cleared.
.P
-On a production machine, you probably do not want the daemon to send crash
+On a production machine, you probably do not want the daemon to send crash
data at times that the machine is busy working. This second mode allows you
-to send crash reports at a quieter time (at night, perhaps) that you
+to send crash reports at a quieter time (at night, perhaps) that you
schedule in the \fI[cron]\fP section of \fIabrt.conf\fP.
.SH CONFIGURATION
-The \fIFileTransfer.conf\fP configuration file contains
+The \fIFileTransfer.conf\fP configuration file contains
several entries in the format "Option = Value". The options are:
.SS URL
The URL of the server, where the crash should
@@ -41,7 +41,7 @@ the user name and the password, for example:
.br
URL = ftp://user:passwd@server.com/path
.SS ArchiveType
-The type of the archive in which to pack the crash data.
+The type of the archive in which to pack the crash data.
Currently, \fI.tar.gz\fP, \fI.tar.bz2\fP and \fI.zip\fP are supported.
The plugin currently relies on external file archiving
commandline utilities, which will create the archive.
diff --git a/lib/Plugins/abrt-KerneloopsReporter.7 b/lib/Plugins/abrt-KerneloopsReporter.7
index e0d32c35..98bd3874 100644
--- a/lib/Plugins/abrt-KerneloopsReporter.7
+++ b/lib/Plugins/abrt-KerneloopsReporter.7
@@ -5,13 +5,13 @@ KerneloopsReporter plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIKerneloopsReporter\fP
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIKerneloopsReporter\fP
plugin for \fIabrt\fP.
.P
This plugin is used to report the crash to the Kerneloops tracker.
.SH INVOCATION
-The plugin is invoked in the \fIabrt.conf\fP configuration file.
+The plugin is invoked in the \fIabrt.conf\fP configuration file.
No parameters are necessary.
.SH CONFIGURATION
The \fIKerneloopsReporter.conf\fP configuration file contains one entry:
diff --git a/lib/Plugins/abrt-KerneloopsScanner.7 b/lib/Plugins/abrt-KerneloopsScanner.7
index d9642a97..ff094847 100644
--- a/lib/Plugins/abrt-KerneloopsScanner.7
+++ b/lib/Plugins/abrt-KerneloopsScanner.7
@@ -5,8 +5,8 @@ KerneloopsScanner plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIKerneloopsScanner\fP
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIKerneloopsScanner\fP
plugin for \fIabrt\fP.
.P
This plugin reads the system log file (default /var/log/messages)
@@ -17,12 +17,12 @@ To distinguish between new crashes and crashes
that were already reported, the plugin makes its own entry
in the log file, which acts as a separator.
.SH INVOCATION
-The plugin is invoked in the \fIabrt.conf\fP configuration file.
+The plugin is invoked in the \fIabrt.conf\fP configuration file.
No parameters are necessary.
.SH CONFIGURATION
The \fIKerneloopsScanner.conf\fP configuration file contains one entry:
.SS SysLogFile
-The file to scan. The default is
+The file to scan. The default is
.br
SysLogFile = /var/log/messages
.SH EXAMPLES
diff --git a/lib/Plugins/abrt-Logger.7 b/lib/Plugins/abrt-Logger.7
index 0f814d24..8ae679f8 100644
--- a/lib/Plugins/abrt-Logger.7
+++ b/lib/Plugins/abrt-Logger.7
@@ -5,8 +5,8 @@ Logger plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fILogger\fP plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fILogger\fP plugin
for \fIabrt\fP.
.P
This plugin is used to log the crash to a file.
@@ -16,7 +16,7 @@ content. It also contains "duplicity check": the ID
of the crash, which is used to tell whether the same
crash has happened previously.
.SH INVOCATION
-The plugin is invoked in the \fIabrt.conf\fP configuration file.
+The plugin is invoked in the \fIabrt.conf\fP configuration file.
No parameters are necessary.
.SH CONFIGURATION
The \fILogger.conf\fP configuration file contains
diff --git a/lib/Plugins/abrt-Mailx.7 b/lib/Plugins/abrt-Mailx.7
index 10d5e4b8..90a8bbce 100644
--- a/lib/Plugins/abrt-Mailx.7
+++ b/lib/Plugins/abrt-Mailx.7
@@ -5,8 +5,8 @@ Mailx plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIMailx\fP plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIMailx\fP plugin
for \fIabrt\fP.
.P
This plugin is used to mail the data about the crash
@@ -42,7 +42,7 @@ These are snippets from the \fIabrt.conf\fP configuration file.
.br
ActionsAndReporters = Mailx("[abrt] a crash occurs")
.P
-2) When a program in a specific package (in this case "httpd") crashes,
+2) When a program in a specific package (in this case "httpd") crashes,
send a mail about it.
.PP
[AnalyzerActionsAndReporters]
diff --git a/lib/Plugins/abrt-RunApp.7 b/lib/Plugins/abrt-RunApp.7
index 6d75b12c..56a8d2b0 100644
--- a/lib/Plugins/abrt-RunApp.7
+++ b/lib/Plugins/abrt-RunApp.7
@@ -5,13 +5,13 @@ RunApp plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fIRunApp\fP plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fIRunApp\fP plugin
for \fIabrt\fP.
.P
This plugin is used to run a specified application when the crash occurs.
.SH INVOCATION
-The plugin is invoked in the \fIabrt.conf\fP configuration file.
+The plugin is invoked in the \fIabrt.conf\fP configuration file.
The first parameter is the command to run. The second, optional
parameter specifies an output file, to which the standard
output of the program is saved.
diff --git a/lib/Plugins/abrt-SQLite3.7 b/lib/Plugins/abrt-SQLite3.7
index 87df539f..c2b39d86 100644
--- a/lib/Plugins/abrt-SQLite3.7
+++ b/lib/Plugins/abrt-SQLite3.7
@@ -5,8 +5,8 @@ SQLite3 database plugin for abrt(8)
.P
.I abrt
is a daemon that watches for application crashes. When a crash occurs,
-it collects the crash data and takes action according to
-its configuration. This manual page describes the \fISQLite3\fP database plugin
+it collects the crash data and takes action according to
+its configuration. This manual page describes the \fISQLite3\fP database plugin
for \fIabrt\fP.
.P
This is a database plugin: \fIabrt\fP needs a database in which to store
diff --git a/lib/Plugins/abrt-plugins.7 b/lib/Plugins/abrt-plugins.7
index a7c185cc..3a99dcbb 100644
--- a/lib/Plugins/abrt-plugins.7
+++ b/lib/Plugins/abrt-plugins.7
@@ -9,10 +9,10 @@ it collects the crash data (core file, application's command line etc.)
and takes action according to the type of application that
crashed and according to the configuration specified in the
.I abrt.conf
-configuration file.
+configuration file.
.P
Plugins allow abrt to perform various actions: for example,
-to report the crash to Bugzilla, to mail the report, to transfer
+to report the crash to Bugzilla, to mail the report, to transfer
the report via FTP or SCP, or to run a program that you specify.
.P
This manual page provides a list of all the manual pages for
diff --git a/lib/Python/PyDebugDump.cpp b/lib/Python/PyDebugDump.cpp
index b45b84a3..0f6de47b 100644
--- a/lib/Python/PyDebugDump.cpp
+++ b/lib/Python/PyDebugDump.cpp
@@ -73,7 +73,7 @@ static PyMethodDef ABRTUtils_functions[] = {
static int
_wrap_PyCDebugDump__tp_init(PyCDebugDump *self, PyObject *args, PyObject *kwargs)
{
- const char *keywords[] = {NULL};
+ static const char *const keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
return -1;
@@ -100,10 +100,10 @@ _wrap_PyCDebugDump_Create(PyCDebugDump *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
char *pFilename2;
- char *pUID2;
- const char *keywords[] = {"pFilename", "pUID", NULL};
+ int pUID2;
+ static const char *const keywords[] = {"pFilename", "pUID", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ss", (char **) keywords, &pFilename2, &pUID2)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "si", (char **) keywords, &pFilename2, &pUID2)) {
return NULL;
}
self->obj->Create(pFilename2, pUID2);
@@ -119,7 +119,7 @@ _wrap_PyCDebugDump_SaveText(PyCDebugDump *self, PyObject *args, PyObject *kwargs
PyObject *py_retval;
char *pName2;
char *pData2;
- const char *keywords[] = {"pName", "pData", NULL};
+ static const char *const keywords[] = {"pName", "pData", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ss", (char **) keywords, &pName2, &pData2)) {
return NULL;
diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp
new file mode 100644
index 00000000..dccd4b04
--- /dev/null
+++ b/lib/Utils/CrashTypesSocket.cpp
@@ -0,0 +1,185 @@
+/*
+ CrashTypesSocket.cpp - functions for socket communication
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@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 "abrtlib.h"
+#include "CrashTypesSocket.h"
+#include <sstream>
+
+/**
+ * A request GET_CRASH_INFOS has the following form:
+ * message -> MESSAGE_GET_CRASH_INFOS
+ *
+ * Example:
+ *
+ * (GET_CRASH_INFOS)
+ * \23
+ *
+ *
+ * A request DELETE_DEBUG_DUMP and CREATE_REPORT has following form:
+ * message -> MESSAGE_TYPE data END_MARKER
+ * MESSAGE_TYPE -> MESSAGE_CREATE_REPORT | MESSAGE_DELETE_DEBUG_DUMP
+ * data -> UUID
+ *
+ * Example:
+ * (DELETE_DEBUG_DUMP)
+ * 1135a3f35bccb543
+ * \23
+ *
+ *
+ * A reply to the GET_CRASH_INFOS, CREATE_REPORT and a request REPORT
+ * has the following form:
+ *
+ * message -> MESSAGE_TYPE data END_MARKER
+ * MESSAGE_TYPE -> MESSAGE_GET_CRASH_INFOS | MESSAGE_REPORT | MESSAGE_CREATE_REPORT
+ * data -> (count of items) item
+ * item -> (length of member)member(length of member)memger...
+ *
+ * Example:
+ *
+ * (REPORT)
+ * (2)
+ * (4)aaaa(1)t(1)y(5)hello
+ * (3)xxx(1)s(1)n(5)world
+ * \23
+ *
+ * The replies has same header as the requests.
+ */
+
+#define MESSAGE_DELETE_DEBUG_DUMP "(DELETE_DEBUG_DUMP)"
+#define MESSAGE_GET_CRASH_INFOS "(GET_CRASH_INFOS)"
+#define MESSAGE_REPORT "(REPORT)"
+#define MESSAGE_CREATE_REPORT "(CREATE_REPORT)"
+#define MESSAGE_END_MARKER 23
+
+std::string crash_data_to_string(const map_crash_data_t& pCrashData)
+{
+ std::stringstream sCD;
+ map_crash_data_t::const_iterator it_cd;
+ sCD << "(" << pCrashData.size() << ")";
+ for(it_cd = pCrashData.begin(); it_cd != pCrashData.end(); it_cd++)
+ {
+ sCD << "(" << it_cd->first.length() << ")";
+ sCD << it_cd->first;
+ sCD << "(" << it_cd->second[CD_TYPE].length() << ")";
+ sCD << it_cd->second[CD_TYPE];
+ sCD << "(" << it_cd->second[CD_EDITABLE].length() << ")";
+ sCD << it_cd->second[CD_EDITABLE];
+ sCD << "(" << it_cd->second[CD_CONTENT].length() << ")";
+ sCD << it_cd->second[CD_CONTENT];
+ }
+ return sCD.str();
+}
+
+std::string crash_infos_to_string(const vector_crash_infos_t& pCrashInfos)
+{
+ std::stringstream sCI;
+ unsigned int ii;
+ for (ii = 0; ii < pCrashInfos.size(); ii++)
+ {
+ sCI << crash_data_to_string(pCrashInfos[ii]);
+ }
+ return sCI.str();
+}
+
+int get_number_from_string(const std::string& pMessage, int& len)
+{
+ std::string sNumber = "";
+
+ int ii = 1;
+ while (pMessage[ii] != ')')
+ {
+ sNumber += pMessage[ii];
+ ii++;
+ if (static_cast<std::string::size_type>(ii) >= pMessage.length())
+ {
+ len = ii;
+ return -1;
+ }
+ }
+ len = ii + 1;
+ return atoi(sNumber.c_str());
+}
+
+//TODO: remove constant 4 and place it in a message
+map_crash_data_t string_to_crash_data(const std::string& pMessage, int& len)
+{
+ map_crash_data_t ci;
+ std::string message = pMessage;
+ int nSize;
+ std::string sField;
+ int nField;
+ int nCount;
+ std::string name;
+ int ii;
+
+ nCount = get_number_from_string(message, ii);
+ if (ii == -1)
+ {
+ len = ii;
+ return ci;
+ }
+ message.erase(0, ii);
+ len = ii;
+ nField = 0;
+ while (nField < nCount * 4)
+ {
+ nSize = get_number_from_string(message, ii);
+ if (ii == -1)
+ {
+ len += ii;
+ ci.clear();
+ return ci;
+ }
+ sField = message.substr(ii, nSize);
+ message.erase(0, ii + nSize);
+ len += ii + nSize;
+ switch(nField % 4)
+ {
+ case 0:
+ name = sField;
+ break;
+ default:
+ ci[name].push_back(sField);
+ break;
+ }
+ nField++;
+ }
+ return ci;
+}
+
+vector_crash_infos_t string_to_crash_infos(const std::string& pMessage)
+{
+ vector_crash_infos_t vci;
+ std::string message = pMessage;
+ int len;
+
+ while (message != "")
+ {
+ map_crash_info_t crash_info = string_to_crash_data(message, len);
+ if (crash_info.size() == 0)
+ {
+ return vci;
+ }
+ vci.push_back(crash_info);
+ message.erase(0, len);
+ }
+ return vci;
+}
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 3297579b..f63a8c6b 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -19,25 +19,15 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "abrtlib.h"
#include "DebugDump.h"
#include "ABRTException.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <cerrno>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
#include <sys/utsname.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <time.h>
-#include <unistd.h>
#include <magic.h>
-#include <string.h>
-#include <pwd.h>
-#include <stdlib.h>
#include "CommLayerInner.h"
// BUG? in C/C++, compiler may assume that function address is never NULL
@@ -193,7 +183,7 @@ void CDebugDump::UnLock()
}
}
-void CDebugDump::Create(const std::string& pDir, const std::string& pUID)
+void CDebugDump::Create(const std::string& pDir, uid_t uid)
{
if (m_bOpened)
{
@@ -221,16 +211,16 @@ void CDebugDump::Create(const std::string& pDir, const std::string& pUID)
m_bOpened = false;
throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create(): Cannot change permissions, dir: " + pDir);
}
- uid_t uid = atoi(pUID.c_str());
struct passwd* pw = getpwuid(uid);
- if (chown(m_sDebugDumpDir.c_str(), uid, pw ? pw->pw_gid : uid) == -1)
+ gid_t gid = pw ? pw->pw_gid : uid;
+ if (chown(m_sDebugDumpDir.c_str(), uid, gid) == -1)
{
- UnLock();
- m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create(): Cannot change ownership, dir: " + pDir);
+ /* if /var/cache/abrt is writable by all, _aborting_ here is not useful */
+ /* let's just warn */
+ perror_msg("can't change '%s' ownership to %u:%u", m_sDebugDumpDir.c_str(), (int)uid, (int)gid);
}
- SaveText(FILENAME_UID, pUID);
+ SaveText(FILENAME_UID, ssprintf("%u", (int)uid));
SaveKernelArchitectureRelease();
SaveTime();
}
@@ -239,7 +229,7 @@ static void DeleteFileDir(const std::string& pDir)
{
DIR *dir = opendir(pDir.c_str());
if (!dir)
- return;
+ return;
struct dirent *dent;
while ((dent = readdir(dir)) != NULL)
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index 65cc7609..1bd8cc7b 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -57,7 +57,7 @@ class CDebugDump
public:
CDebugDump();
void Open(const std::string& pDir);
- void Create(const std::string& pDir, const std::string& pUID);
+ void Create(const std::string& pDir, uid_t pUID);
void Delete();
void Close();
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 60431a59..aa6ddc9d 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -1,9 +1,11 @@
lib_LTLIBRARIES = libABRTUtils.la
libABRTUtils_la_SOURCES = \
DebugDump.cpp DebugDump.h \
+ CrashTypesSocket.cpp \
xfuncs.cpp \
read_write.cpp \
- logging.cpp
+ logging.cpp \
+ copyfd.cpp
libABRTUtils_la_LDFLAGS = -version-info 0:1:0
libABRTUtils_la_LIBADD = -lmagic
diff --git a/lib/Utils/copyfd.cpp b/lib/Utils/copyfd.cpp
new file mode 100644
index 00000000..cda52b03
--- /dev/null
+++ b/lib/Utils/copyfd.cpp
@@ -0,0 +1,107 @@
+/*
+ * Utility routines.
+ *
+ * Licensed under GPLv2, see file COPYING in this tarball for details.
+ */
+#include "abrtlib.h"
+
+#define CONFIG_FEATURE_COPYBUF_KB 4
+
+static const char msg_write_error[] = "write error";
+static const char msg_read_error[] = "read error";
+
+static off_t full_fd_action(int src_fd, int dst_fd, off_t size)
+{
+ int status = -1;
+ off_t total = 0;
+#if CONFIG_FEATURE_COPYBUF_KB <= 4
+ char buffer[CONFIG_FEATURE_COPYBUF_KB * 1024];
+ enum { buffer_size = sizeof(buffer) };
+#else
+ char *buffer;
+ int buffer_size;
+
+ /* We want page-aligned buffer, just in case kernel is clever
+ * and can do page-aligned io more efficiently */
+ buffer = mmap(NULL, CONFIG_FEATURE_COPYBUF_KB * 1024,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON,
+ /* ignored: */ -1, 0);
+ buffer_size = CONFIG_FEATURE_COPYBUF_KB * 1024;
+ if (buffer == MAP_FAILED) {
+ buffer = alloca(4 * 1024);
+ buffer_size = 4 * 1024;
+ }
+#endif
+
+ if (src_fd < 0)
+ goto out;
+
+ if (!size) {
+ size = buffer_size;
+ status = 1; /* copy until eof */
+ }
+
+ while (1) {
+ ssize_t rd;
+
+ rd = safe_read(src_fd, buffer, size > buffer_size ? buffer_size : size);
+
+ if (!rd) { /* eof - all done */
+ status = 0;
+ break;
+ }
+ if (rd < 0) {
+ perror_msg(msg_read_error);
+ break;
+ }
+ /* dst_fd == -1 is a fake, else... */
+ if (dst_fd >= 0) {
+ ssize_t wr = full_write(dst_fd, buffer, rd);
+ if (wr < rd) {
+ perror_msg(msg_write_error);
+ break;
+ }
+ }
+ total += rd;
+ if (status < 0) { /* if we aren't copying till EOF... */
+ size -= rd;
+ if (!size) {
+ /* 'size' bytes copied - all done */
+ status = 0;
+ break;
+ }
+ }
+ }
+ out:
+
+#if CONFIG_FEATURE_COPYBUF_KB > 4
+ if (buffer_size != 4 * 1024)
+ munmap(buffer, buffer_size);
+#endif
+ return status ? -1 : total;
+}
+
+off_t copyfd_size(int fd1, int fd2, off_t size)
+{
+ if (size) {
+ return full_fd_action(fd1, fd2, size);
+ }
+ return 0;
+}
+
+void copyfd_exact_size(int fd1, int fd2, off_t size)
+{
+ off_t sz = copyfd_size(fd1, fd2, size);
+ if (sz == size)
+ return;
+ if (sz != -1)
+ error_msg_and_die("short read");
+ /* if sz == -1, copyfd_XX already complained */
+ xfunc_die();
+}
+
+off_t copyfd_eof(int fd1, int fd2)
+{
+ return full_fd_action(fd1, fd2, 0);
+}
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index ad67ec62..078c8045 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -158,6 +158,35 @@ char* xasprintf(const char *format, ...)
return string_ptr;
}
+std::string ssprintf(const char *format, ...)
+{
+ va_list p;
+ int r;
+ char *string_ptr;
+
+#if 1
+ // GNU extension
+ va_start(p, format);
+ r = vasprintf(&string_ptr, format, p);
+ va_end(p);
+#else
+ // Bloat for systems that haven't got the GNU extension.
+ va_start(p, format);
+ r = vsnprintf(NULL, 0, format, p);
+ va_end(p);
+ string_ptr = xmalloc(r+1);
+ va_start(p, format);
+ r = vsnprintf(string_ptr, r+1, format, p);
+ va_end(p);
+#endif
+
+ if (r < 0)
+ error_msg_and_die(msg_memory_exhausted);
+ std::string res = string_ptr;
+ free(string_ptr);
+ return res;
+}
+
void xsetenv(const char *key, const char *value)
{
if (setenv(key, value, 1))
@@ -170,7 +199,6 @@ int xsocket(int domain, int type, int protocol)
int r = socket(domain, type, protocol);
if (r < 0) {
- /* Hijack vaguely related config option */
const char *s = "INET";
if (domain == AF_PACKET) s = "PACKET";
if (domain == AF_NETLINK) s = "NETLINK";