summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-23 18:26:33 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-23 18:26:33 +0100
commit3c3d9ab3a7a804d2b0460240a4c96362a14c13ed (patch)
treebd84dd3b21b1e1e50cdcdc7dd250400c3fd45427
parent13997243816d57f77d7a3e36a26dad784e45d5f9 (diff)
downloadabrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.tar.gz
abrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.tar.xz
abrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.zip
remove socket code, it is dead
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--inc/CrashTypesSocket.h87
-rw-r--r--inc/Makefile.am1
-rw-r--r--lib/Utils/CrashTypesSocket.cpp183
-rw-r--r--lib/Utils/Makefile.am1
-rw-r--r--src/CLI/ABRTSocket.cpp155
-rw-r--r--src/CLI/ABRTSocket.h47
-rw-r--r--src/CLI/Makefile.am1
-rw-r--r--src/Daemon/CommLayerServerSocket.cpp269
-rw-r--r--src/Daemon/CommLayerServerSocket.h52
-rw-r--r--src/Daemon/CrashWatcher.h6
-rw-r--r--src/Daemon/Daemon.cpp4
-rw-r--r--src/Daemon/Makefile.am1
12 files changed, 1 insertions, 806 deletions
diff --git a/inc/CrashTypesSocket.h b/inc/CrashTypesSocket.h
deleted file mode 100644
index 85f14567..00000000
--- a/inc/CrashTypesSocket.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- CrashTypesSocket.h - contains inline 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.
-*/
-#ifndef SOCKETCRASHTYPES_H_
-#define SOCKETCRASHTYPES_H_
-
-#include "CrashTypes.h"
-
-/**
- * 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_infos_to_string(const vector_map_crash_data_t& pCrashDatas);
-std::string crash_data_to_string(const map_crash_data_t& pCrashData);
-inline std::string crash_report_to_string(const map_crash_data_t& pCrashData)
-{
- return crash_data_to_string(pCrashData);
-}
-
-vector_map_crash_data_t string_to_crash_infos(const std::string& pMessage);
-map_crash_data_t string_to_crash_data(const std::string& pMessage, int& len);
-inline map_crash_data_t string_to_crash_report(const std::string& pMessage)
-{
- int len;
- return string_to_crash_data(pMessage, len);
-}
-
-#endif
diff --git a/inc/Makefile.am b/inc/Makefile.am
index 7059cf16..2ccc714f 100644
--- a/inc/Makefile.am
+++ b/inc/Makefile.am
@@ -1,2 +1 @@
EXTRA_DIST = ABRTException.h CrashTypes.h abrtlib.h abrt_types.h
-# removed: CrashTypesSocket.h
diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp
deleted file mode 100644
index 710e31e9..00000000
--- a/lib/Utils/CrashTypesSocket.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- 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"
-
-/**
- * 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_map_crash_data_t& pCrashDatas)
-{
- std::stringstream sCI;
- unsigned int ii;
- for (ii = 0; ii < pCrashDatas.size(); ii++)
- {
- sCI << crash_data_to_string(pCrashDatas[ii]);
- }
- return sCI.str();
-}
-
-static 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 xatoi(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_map_crash_data_t string_to_crash_infos(const std::string& pMessage)
-{
- vector_map_crash_data_t vci;
- std::string message = pMessage;
- int len;
-
- while (message != "")
- {
- map_crash_data_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/Makefile.am b/lib/Utils/Makefile.am
index 6847ab0a..976cf318 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -6,7 +6,6 @@ lib_LTLIBRARIES = libABRTUtils.la libABRTdUtils.la
# time.cpp
# xconnect.cpp
-# removed: CrashTypesSocket.cpp
libABRTUtils_la_SOURCES = \
xfuncs.cpp \
encbase64.cpp \
diff --git a/src/CLI/ABRTSocket.cpp b/src/CLI/ABRTSocket.cpp
deleted file mode 100644
index 61618c08..00000000
--- a/src/CLI/ABRTSocket.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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 "ABRTSocket.h"
-#include "ABRTException.h"
-#include "CrashTypesSocket.h"
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <string.h>
-
-CABRTSocket::CABRTSocket() : m_nSocket(-1)
-{}
-
-CABRTSocket::~CABRTSocket()
-{
- /* Paranoia. In C++, destructor will abort() if it was called while unwinding
- * the stack and it throws an exception.
- */
- try
- {
- Disconnect();
- }
- catch (...)
- {
- error_msg_and_die("Internal error");
- }
-}
-
-void CABRTSocket::Send(const std::string& pMessage)
-{
- int ret = 0;
- int len = pMessage.length();
- int offset = 0;
- char* message = new char[len + 3];
- memcpy(message, pMessage.c_str(), len);
- message[len] = MESSAGE_END_MARKER;
- message[len + 1] = '\n';
- message[len + 2] = '\0';
-
- while (ret != strlen(message + offset))
- {
- offset += ret;
- ret = send(m_nSocket, message + offset, strlen(message + offset), 0);
- if (ret == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Send(): Can not send data");
- }
- }
- delete[] message;
-}
-
-void CABRTSocket::Recv(std::string& pMessage)
-{
- std::string message;
- bool receivingMessage = true;
- char buff[1];
- int ret;
-
- pMessage = "";
- while (receivingMessage)
- {
- ret = recv(m_nSocket, buff, 1, 0);
- if (ret == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Recv(): Can not recv data");
- }
- else if (ret == 0)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Recv(): Connection closed by abrt server");
- }
-
- message += buff[0];
-
- if (message.length() > 2 &&
- message[message.length() - 2] == MESSAGE_END_MARKER &&
- message[message.length() - 1] == '\n')
- {
- receivingMessage = false;
- message = message.substr(0, message.length() - 2);
- }
- }
- pMessage = message;
-}
-
-
-void CABRTSocket::Connect(const std::string& pPath)
-{
- int len;
- struct sockaddr_un remote;
- if ((m_nSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Connect(): Can not create socket");
- }
- remote.sun_family = AF_UNIX;
- strcpy(remote.sun_path, pPath.c_str());
- len = strlen(remote.sun_path) + sizeof(remote.sun_family);
- if (connect(m_nSocket, (struct sockaddr *)&remote, len) == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Connect(): Can not connect to remote");
- }
-}
-
-void CABRTSocket::Disconnect()
-{
- if (m_nSocket != -1)
- close(m_nSocket);
-}
-
-vector_map_crash_data_t CABRTSocket::GetCrashInfos()
-{
- std::string message = MESSAGE_GET_CRASH_INFOS;
- Send(message);
- Recv(message);
- message.erase(0, sizeof(MESSAGE_GET_CRASH_INFOS) - 1);
- return string_to_crash_infos(message);
-}
-
-map_crash_data_t CABRTSocket::CreateReport(const std::string &pUUID)
-{
- std::string message = MESSAGE_CREATE_REPORT + pUUID;
- Send(message);
- Recv(message);
- message.erase(0, sizeof(MESSAGE_CREATE_REPORT) - 1);
- return string_to_crash_report(message);
-}
-
-void CABRTSocket::Report(const map_crash_data_t& pReport)
-{
- std::string message = MESSAGE_REPORT + crash_report_to_string(pReport);
- Send(message);
-}
-
-void CABRTSocket::DeleteDebugDump(const std::string& pUUID)
-{
- std::string message = MESSAGE_DELETE_DEBUG_DUMP + pUUID;
- Send(message);
-}
diff --git a/src/CLI/ABRTSocket.h b/src/CLI/ABRTSocket.h
deleted file mode 100644
index f8fb42b8..00000000
--- a/src/CLI/ABRTSocket.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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 ABRTSOCKET_H_
-#define ABRTSOCKET_H_
-
-#include <string>
-
-#include "CrashTypes.h"
-
-class CABRTSocket
-{
- private:
- int m_nSocket;
-
- void Send(const char *pMessage);
- void Recv(std::string& pMessage);
-
- public:
- CABRTSocket();
- ~CABRTSocket();
-
- void Connect(const char *pPath);
- void Disconnect();
-
- vector_map_crash_data_t GetCrashInfos();
- map_crash_data_t CreateReport(const char *pUUID);
- void Report(const map_crash_data_t& pReport);
- int32_t DeleteDebugDump(const char *pUUID);
-};
-
-#endif /* ABRTSOCKET_H_ */
diff --git a/src/CLI/Makefile.am b/src/CLI/Makefile.am
index d12b69b1..361b64f7 100644
--- a/src/CLI/Makefile.am
+++ b/src/CLI/Makefile.am
@@ -1,6 +1,5 @@
bin_PROGRAMS = abrt-cli
-# removed: ABRTSocket.h ABRTSocket.cpp
abrt_cli_SOURCES = \
CLI.cpp \
run-command.h run-command.cpp \
diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp
deleted file mode 100644
index 1e8bf6ee..00000000
--- a/src/Daemon/CommLayerServerSocket.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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 <sys/socket.h>
-#include <sys/un.h>
-#include "abrtlib.h"
-#include "CommLayerInner.h"
-#include "ABRTException.h"
-#include "CrashTypesSocket.h"
-#include "CrashWatcher.h"
-#include "CommLayerServerSocket.h"
-
-void CCommLayerServerSocket::Send(const std::string& pData, GIOChannel *pDestination)
-{
- ssize_t ret = -1;
- gsize len = pData.length();
- int offset = 0;
- GError *err = NULL;
- gchar* message = new gchar[len + 3];
- memcpy(message, pData.c_str(), len);
- message[len] = MESSAGE_END_MARKER;
- message[len + 1] = '\n';
- message[len + 2] = '\0';
-
- len = 0;
- while (len != strlen(message + offset))
- {
- offset += len;
- ret = g_io_channel_write_chars(pDestination, message + offset, strlen(message + offset), &len, &err);
- if (ret == G_IO_STATUS_ERROR)
- {
- error_msg("Error during sending data");
- }
- }
-
- g_io_channel_flush(pDestination, &err);
- delete[] message;
-}
-
-std::string CCommLayerServerSocket::GetSenderUID(int pSenderSocket)
-{
- struct ucred creds;
- socklen_t len = sizeof(creds);
- if (getsockopt(pSenderSocket, SOL_SOCKET, SO_PEERCRED, &creds, &len) == -1)
- {
- throw CABRTException(EXCEP_ERROR, "CCommLayerServerSocket::GetSenderUID(): error getting sender uid");
- }
- return to_string(creds.uid);
-}
-
-gboolean CCommLayerServerSocket::client_socket_cb(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- CCommLayerServerSocket* serverSocket = static_cast<CCommLayerServerSocket*>(data);
- std::string senderUID = serverSocket->GetSenderUID(g_io_channel_unix_get_fd(source));
- gchar buff[1];
- gsize len;
- GIOStatus ret;
- GError *err = NULL;
- bool receivingMessage = true;
- std::string message = "";
-
- if (condition & G_IO_HUP ||
- condition & G_IO_ERR ||
- condition & G_IO_NVAL)
- {
- log("Socket client disconnected");
- g_io_channel_unref(serverSocket->m_mapClientChannels[g_io_channel_unix_get_fd(source)]);
- serverSocket->m_mapClientChannels.erase(g_io_channel_unix_get_fd(source));
- return FALSE;
- }
-
- // TODO: rewrite this
- while (receivingMessage)
- {
- ret = g_io_channel_read_chars(source, buff, 1, &len, &err);
- if (ret == G_IO_STATUS_ERROR)
- {
- error_msg("Error while reading data from client socket: %s", err->message);
- return FALSE;
- }
- message += buff[0];
-
- if (message.length() > 2 &&
- message[message.length() - 2] == MESSAGE_END_MARKER &&
- message[message.length() - 1] == '\n')
- {
- receivingMessage = false;
- message = message.substr(0, message.length() - 2);
- }
- }
-
- serverSocket->ProcessMessage(message, source);
- return TRUE;
-}
-
-gboolean CCommLayerServerSocket::server_socket_cb(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- CCommLayerServerSocket* serverSocket = static_cast<CCommLayerServerSocket*>(data);
- int socket;
- struct sockaddr_un remote;
- socklen_t len = sizeof(remote);
-
- if (condition & G_IO_HUP ||
- condition & G_IO_ERR ||
- condition & G_IO_NVAL)
- {
- error_msg("Server socket error");
- return FALSE;
- }
-
- if ((socket = accept(serverSocket->m_nSocket, (struct sockaddr *)&remote, &len)) == -1)
- {
- error_msg("Server can not accept client");
- return TRUE;
- }
- log("New socket client connected");
- GIOChannel* gSocket = g_io_channel_unix_new(socket);
- if (!g_io_add_watch(gSocket,
- static_cast<GIOCondition>(G_IO_IN |G_IO_PRI| G_IO_ERR | G_IO_HUP | G_IO_NVAL),
- static_cast<GIOFunc>(client_socket_cb),
- data))
- {
- error_msg("Can not init g_io_channel");
- return TRUE;
- }
- serverSocket->m_mapClientChannels[socket] = gSocket;
- return TRUE;
-}
-
-void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChannel *pSource)
-{
- std::string UID = GetSenderUID(g_io_channel_unix_get_fd(pSource));
-
- if (!strncmp(pMessage.c_str(), MESSAGE_GET_CRASH_INFOS, sizeof(MESSAGE_GET_CRASH_INFOS) - 1))
- {
- vector_map_crash_data_t crashInfos = GetCrashInfos(UID);
- std::string message = MESSAGE_GET_CRASH_INFOS + crash_infos_to_string(crashInfos);
- Send(message, pSource);
- }
- else if (!strncmp(pMessage.c_str(), MESSAGE_REPORT, sizeof(MESSAGE_REPORT) - 1))
- {
- std::string message = pMessage.substr(sizeof(MESSAGE_REPORT) - 1);
- map_crash_data_t report = string_to_crash_report(message);
- map_plugin_settings_t plugin_settings;
- //FIXME: another hack to make this compile
-// Report(report, plugin_settings, UID);
- }
- else if (!strncmp(pMessage.c_str(), MESSAGE_CREATE_REPORT, sizeof(MESSAGE_CREATE_REPORT) - 1))
- {
-// std::string UUID = pMessage.substr(sizeof(MESSAGE_CREATE_REPORT) - 1);
-// map_crash_data_t crashReport;
-// CreateReport(UUID, UID, crashReport);
-//use CreateReportThread instead of CreateReport?
-// std::string message = MESSAGE_CREATE_REPORT + crash_report_to_string(crashReport);
-// Send(message, pSource);
- }
- else if (!strncmp(pMessage.c_str(), MESSAGE_DELETE_DEBUG_DUMP, sizeof(MESSAGE_DELETE_DEBUG_DUMP) - 1))
- {
- std::string UUID = pMessage.substr(sizeof(MESSAGE_DELETE_DEBUG_DUMP) - 1);
- DeleteDebugDump(UUID, UID);
- }
- else
- {
- error_msg("Received unknown message type");
- }
-}
-
-CCommLayerServerSocket::CCommLayerServerSocket()
-: CCommLayerServer()
-{
- struct sockaddr_un local;
-
- unlink(SOCKET_FILE);
- m_nSocket = socket(AF_UNIX, SOCK_STREAM, 0);
- if (m_nSocket == -1)
- {
- m_init_error = 1;
- perror_msg("CCommLayerServerSocket: can't create AF_UNIX socket");
- return;
- }
- fcntl(m_nSocket, F_SETFD, FD_CLOEXEC);
-
- memset(&local, 0, sizeof(local));
- local.sun_family = AF_UNIX;
- strcpy(local.sun_path, SOCKET_FILE);
- if (bind(m_nSocket, (struct sockaddr *)&local, sizeof(local)) == -1)
- {
- m_init_error = 1;
- perror_msg("CCommLayerServerSocket: can't bind AF_UNIX socket to '%s'", SOCKET_FILE);
- return;
- }
- if (listen(m_nSocket, 5) == -1)
- {
- m_init_error = 1;
- perror_msg("CCommLayerServerSocket: can't listen on AF_UNIX socket");
- return;
- }
- chmod(SOCKET_FILE, SOCKET_PERMISSION);
-
- m_pGSocket = g_io_channel_unix_new(m_nSocket);
- if (!g_io_add_watch(m_pGSocket,
- static_cast<GIOCondition>(G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
- static_cast<GIOFunc>(server_socket_cb),
- this))
- {
- m_init_error = 1;
- perror_msg("CCommLayerServerSocket: can't hook AF_UNIX socket to glb main loop");
- return;
- }
-}
-
-CCommLayerServerSocket::~CCommLayerServerSocket()
-{
- g_io_channel_unref(m_pGSocket);
- close(m_nSocket);
-}
-
-vector_map_crash_data_t CCommLayerServerSocket::GetCrashInfos(const std::string &pSender)
-{
- vector_map_crash_data_t crashInfos;
- crashInfos = ::GetCrashInfos(pSender);
- return crashInfos;
-}
-
-//reimplement as CreateReportThread(...)?
-//map_crash_data_t CCommLayerServerSocket::CreateReport(const std::string &pUUID, const std::string &pSender)
-//{
-// map_crash_data_t crashReport;
-// crashReport = ::CreateReport(pUUID, pSender);
-// return crashReport;
-//}
-
-report_status_t CCommLayerServerSocket::Report(const map_crash_data_t& pReport, const std::string& pSender)
-{
- report_status_t rs;
- //FIXME: a hack to make this compile, but we don't use sockets anyway
- /* we could probably remove the sockets and rely only on dbus,
- as it will become mandatory even on servers, but this needs some investigation
- and more opinions
- */
- //rs = ::Report(pReport, pSettings, pSender);
- return rs;
-}
-
-bool CCommLayerServerSocket::DeleteDebugDump(const std::string& pUUID, const std::string& pSender)
-{
- ::DeleteDebugDump(pUUID, pSender);
- return true;
-}
-
-void CCommLayerServerSocket::Crash(const std::string& arg1)
-{
- //Send("(CRASH)New Crash Detected: " + arg1);
-}
diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h
deleted file mode 100644
index 40f6f892..00000000
--- a/src/Daemon/CommLayerServerSocket.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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 "CommLayerServer.h"
-#include "DBusCommon.h"
-#include <glib.h>
-
-#define SOCKET_FILE VAR_RUN"/abrt.socket"
-#define SOCKET_PERMISSION 0666
-
-class CCommLayerServerSocket : public CCommLayerServer
-{
- private:
- typedef std::map<int, GIOChannel*> map_clinet_channels_t;
-
- int m_nSocket;
- GIOChannel* m_pGSocket;
- map_clinet_channels_t m_mapClientChannels;
-
- void Send(const std::string& pData, GIOChannel *pDestination);
-
- static gboolean server_socket_cb(GIOChannel *source, GIOCondition condition, gpointer data);
- static gboolean client_socket_cb(GIOChannel *source, GIOCondition condition, gpointer data);
-
- std::string GetSenderUID(int pSenderSocket);
- void ProcessMessage(const std::string& pMessage, GIOChannel *pSource);
-
- public:
- CCommLayerServerSocket();
- virtual ~CCommLayerServerSocket();
-
- virtual vector_map_crash_data_t GetCrashInfos(const char *pSender);
- virtual report_status_t Report(const map_crash_data_t& pReport, const char *pSender);
- virtual void DeleteDebugDump(const char *pUUID, const char *pSender);
-
- virtual void Crash(const char *arg1);
-};
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index 015bd70f..276adea8 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -26,11 +26,7 @@
#include "MiddleWare.h"
#include "Settings.h"
-#ifdef ENABLE_DBUS
- #include "CommLayerServerDBus.h"
-#elif ENABLE_SOCKET
- #include "CommLayerServerSocket.h"
-#endif
+#include "CommLayerServerDBus.h"
#include "CommLayerInner.h"
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 66f1d6e9..143d8b4e 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -849,12 +849,8 @@ int main(int argc, char** argv)
/* Note: this already may process a few dbus messages,
* therefore it should be the last thing to initialize.
*/
-#if 1 //def ENABLE_DBUS
VERB1 log("Initializing dbus");
g_pCommLayer = new CCommLayerServerDBus();
-#elif ENABLE_SOCKET
- g_pCommLayer = new CCommLayerServerSocket();
-#endif
if (g_pCommLayer->m_init_error)
throw 1;
}
diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am
index cb440277..c2347aec 100644
--- a/src/Daemon/Makefile.am
+++ b/src/Daemon/Makefile.am
@@ -2,7 +2,6 @@ bin_SCRIPTS = abrt-debuginfo-install
sbin_PROGRAMS = abrtd
-# disabled: CommLayerServerSocket.h CommLayerServerSocket.cpp
abrtd_SOURCES = \
PluginManager.h PluginManager.cpp \
RPM.h RPM.cpp \