summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-19 15:26:35 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-19 15:26:35 +0200
commit47ac1ffe396607bb1258afeba4d2b644321c58ed (patch)
tree2f6712da5bc134cbb09d8dbd8a521da2c9f6a4bb /src/daemon
parenta0b5d258119666c8145a935710c7c147db34e7b6 (diff)
downloadabrt-47ac1ffe396607bb1258afeba4d2b644321c58ed.zip
abrt-47ac1ffe396607bb1258afeba4d2b644321c58ed.tar.gz
abrt-47ac1ffe396607bb1258afeba4d2b644321c58ed.tar.xz
daemon: remove unused dbus calls and their support code
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/CommLayerServerDBus.cpp200
-rw-r--r--src/daemon/CommLayerServerDBus.h1
-rw-r--r--src/daemon/Daemon.cpp16
-rw-r--r--src/daemon/Makefile.am1
-rw-r--r--src/daemon/MiddleWare.cpp483
-rw-r--r--src/daemon/MiddleWare.h28
-rw-r--r--src/daemon/Settings.cpp22
-rw-r--r--src/daemon/Settings.h4
-rw-r--r--src/daemon/comm_layer_inner.cpp41
9 files changed, 7 insertions, 789 deletions
diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp
index 9fd48b8..3e0a6a7 100644
--- a/src/daemon/CommLayerServerDBus.cpp
+++ b/src/daemon/CommLayerServerDBus.cpp
@@ -24,9 +24,6 @@
#include "Settings.h"
#include "CommLayerServerDBus.h"
-// 16kB message limit
-#define LIMIT_MESSAGE 16384
-
/*
* DBus signal emitters
*/
@@ -93,13 +90,6 @@ void send_dbus_sig_QuotaExceeded(const char* str)
send_flush_and_unref(msg);
}
-void send_dbus_sig_JobDone(const char* peer)
-{
- DBusMessage* msg = new_signal_msg("JobDone", peer);
- VERB2 log("Sending signal JobDone() to peer %s", peer);
- send_flush_and_unref(msg);
-}
-
void send_dbus_sig_Update(const char* pMessage, const char* peer)
{
DBusMessage* msg = new_signal_msg("Update", peer);
@@ -140,147 +130,6 @@ static long get_remote_uid(DBusMessage* call, const char** ppSender = NULL)
return uid;
}
-static int handle_GetCrashInfos(DBusMessage* call, DBusMessage* reply)
-{
- long unix_uid = get_remote_uid(call);
- vector_of_crash_data_t *argout1 = GetCrashInfos(unix_uid);
-
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
- store_vector_of_crash_data(&out_iter, argout1);
- free_vector_of_crash_data(argout1);
-
- send_flush_and_unref(reply);
- return 0;
-}
-
-static int handle_StartJob(DBusMessage* call, DBusMessage* reply)
-{
- int r;
- DBusMessageIter in_iter;
- dbus_message_iter_init(call, &in_iter);
- const char* crash_id;
- r = load_val(&in_iter, crash_id);
- if (r != ABRT_DBUS_MORE_FIELDS)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
- }
- int32_t force;
- r = load_val(&in_iter, force);
- if (r != ABRT_DBUS_LAST_FIELD)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
- }
-
- const char* sender;
- long unix_uid = get_remote_uid(call, &sender);
- if (CreateReportThread(crash_id, unix_uid, force, sender) != 0)
- return -1; /* can't create thread (err msg is already logged) */
-
- send_flush_and_unref(reply);
- return 0;
-}
-
-static int handle_CreateReport(DBusMessage* call, DBusMessage* reply)
-{
- int r;
- DBusMessageIter in_iter;
- dbus_message_iter_init(call, &in_iter);
- const char* crash_id;
- r = load_val(&in_iter, crash_id);
- if (r != ABRT_DBUS_LAST_FIELD)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
- }
-
- long unix_uid = get_remote_uid(call);
- crash_data_t *report = NULL;
- CreateReport(crash_id, unix_uid, /*force:*/ 0, &report);
-
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
- store_crash_data(&out_iter, report);
-
- send_flush_and_unref(reply);
- return 0;
-}
-
-static int handle_Report(DBusMessage* call, DBusMessage* reply)
-{
- int r;
- long unix_uid;
- report_status_t argout1;
- map_map_string_t user_conf_data;
- vector_string_t events;
- const char* comment = NULL;
- const char* errmsg = NULL;
- DBusMessageIter in_iter;
-
- dbus_message_iter_init(call, &in_iter);
-
- crash_data_t *crash_data = NULL;
- r = load_crash_data(&in_iter, &crash_data);
- if (r != ABRT_DBUS_MORE_FIELDS)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- r = -1;
- goto ret;
- }
-//TODO? get_crash_item_content_or_die_or_empty?
- comment = get_crash_item_content_or_NULL(crash_data, FILENAME_COMMENT) ? : "";
- if (strlen(comment) > LIMIT_MESSAGE)
- {
- errmsg = _("Comment is too long");
- }
- if (errmsg)
- {
- dbus_message_unref(reply);
- reply = dbus_message_new_error(call, DBUS_ERROR_FAILED, errmsg);
- if (!reply)
- die_out_of_memory();
- send_flush_and_unref(reply);
- r = 0;
- goto ret;
- }
-
- /* Second parameter: list of events to run */
- r = load_val(&in_iter, events);
- if (r == ABRT_DBUS_ERROR)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- r = -1;
- goto ret;
- }
-
- /* Third parameter (optional): configuration data for plugins */
- if (r == ABRT_DBUS_MORE_FIELDS)
- {
- r = load_val(&in_iter, user_conf_data);
- if (r != ABRT_DBUS_LAST_FIELD)
- {
- error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- r = -1;
- goto ret;
- }
- }
-
- unix_uid = get_remote_uid(call);
- argout1 = Report(crash_data, events, user_conf_data, unix_uid);
-
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, argout1);
-
- send_flush_and_unref(reply);
- r = 0;
- ret:
- free_crash_data(crash_data);
- return r;
-}
-
static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply)
{
int r;
@@ -305,39 +154,6 @@ static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply)
return 0;
}
-static int handle_GetSettings(DBusMessage* call, DBusMessage* reply)
-{
- map_abrt_settings_t result = GetSettings();
-
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, result);
-
- send_flush_and_unref(reply);
- return 0;
-}
-
-//static int handle_SetSettings(DBusMessage* call, DBusMessage* reply)
-//{
-// int r;
-// DBusMessageIter in_iter;
-// dbus_message_iter_init(call, &in_iter);
-// map_abrt_settings_t param1;
-// r = load_val(&in_iter, param1);
-// if (r != ABRT_DBUS_LAST_FIELD)
-// {
-// error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
-// return -1;
-// }
-//
-// const char * sender = dbus_message_get_sender(call);
-// SetSettings(param1, sender);
-//
-// send_flush_and_unref(reply);
-// return 0;
-//}
-
-
/*
* Glib integration machinery
*/
@@ -352,22 +168,8 @@ static DBusHandlerResult message_received(DBusConnection* conn, DBusMessage* msg
DBusMessage* reply = dbus_message_new_method_return(msg);
int r = -1;
- if (strcmp(member, "GetCrashInfos") == 0)
- r = handle_GetCrashInfos(msg, reply);
- else if (strcmp(member, "StartJob") == 0)
- r = handle_StartJob(msg, reply);
- else if (strcmp(member, "Report") == 0)
- r = handle_Report(msg, reply);
- else if (strcmp(member, "DeleteDebugDump") == 0)
+ if (strcmp(member, "DeleteDebugDump") == 0)
r = handle_DeleteDebugDump(msg, reply);
- else if (strcmp(member, "CreateReport") == 0)
- r = handle_CreateReport(msg, reply);
- else if (strcmp(member, "GetSettings") == 0)
- r = handle_GetSettings(msg, reply);
-// looks unused to me.
-// Ok to grep for SetSettings and delete after 2011-04-01.
-// else if (strcmp(member, "SetSettings") == 0)
-// r = handle_SetSettings(msg, reply);
// NB: C++ binding also handles "Introspect" method, which returns a string.
// It was sending "dummy" introspection answer whick looks like this:
diff --git a/src/daemon/CommLayerServerDBus.h b/src/daemon/CommLayerServerDBus.h
index eab7d71..b0dafd2 100644
--- a/src/daemon/CommLayerServerDBus.h
+++ b/src/daemon/CommLayerServerDBus.h
@@ -30,7 +30,6 @@ void send_dbus_sig_Crash(const char *package_name,
const char *dir,
const char *uid_str
);
-void send_dbus_sig_JobDone(const char* peer);
void send_dbus_sig_QuotaExceeded(const char* str);
void send_dbus_sig_Update(const char* pMessage, const char* peer);
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index b1aaf8c..b6735da 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -21,7 +21,6 @@
#endif
#include <sys/un.h>
#include <syslog.h>
-#include <pthread.h>
#include <string>
#include <sys/inotify.h>
#include <sys/ioctl.h> /* ioctl(FIONREAD) */
@@ -52,28 +51,13 @@ using namespace std;
* - signal: we got SIGTERM or SIGINT
*
* DBus methods we have:
- * - GetCrashInfos(): returns a vector_of_crash_data
- * of crashes for given uid
- * v[N]["executable"/"uid"/"kernel"/"backtrace"][N] = "contents"
- * - StartJob(crash_id,force): starts creating a report for /var/spool/abrt/DIR with this UID:UUID.
- * Returns job id (uint64).
- * After thread returns, when report creation thread has finished,
- * JobDone() dbus signal is emitted.
- * - CreateReport(crash_id): returns crash data (hash table of struct crash_item)
- * - Report(crash_data[, map_map_string_t]):
- * "Please report this crash": calls Report() of all registered reporter plugins.
- * Returns report_status_t (map_vector_string_t) - the status of each call.
- * 2nd parameter is the contents of user's abrt.conf.
* - DeleteDebugDump(crash_id): delete it from DB and delete corresponding /var/spool/abrt/DIR
* - RegisterPlugin(PluginName): returns void
* - UnRegisterPlugin(PluginName): returns void
- * - GetSettings(): returns map_abrt_settings_t (map_map_string_t)
* - SetSettings(map_abrt_settings_t): returns void
*
* DBus signals we emit:
* - Crash(progname, crash_id, dir, uid) - a new crash occurred (new /var/spool/abrt/DIR is found)
- * - JobDone(client_dbus_ID) - see StartJob above.
- * Sent as unicast to the client which did StartJob.
* - Warning(msg)
* - Update(msg)
* Both are sent as unicast to last client set by set_client_name(name).
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index d554920..df5198b 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -31,7 +31,6 @@ abrtd_CPPFLAGS = \
-D_GNU_SOURCE \
-Wall -Wwrite-strings
abrtd_LDADD = \
- $(DL_LIBS) \
$(DBUS_LIBS) \
../lib/libreport.la \
../lib/libabrt_dbus.la
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index 5ae7708..d0ee40d 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -35,145 +35,6 @@ using namespace std;
*/
static crash_data_t *FillCrashInfo(const char *dump_dir_name);
-/**
- * Transforms a debugdump directory to inner crash
- * report form. This form is used for later reporting.
- * @param dump_dir_name A debugdump dir containing all necessary data.
- * @param pCrashData A created crash report.
- */
-static crash_data_t *DebugDumpToCrashReport(const char *dump_dir_name)
-{
- VERB3 log(" DebugDumpToCrashReport('%s')", dump_dir_name);
-
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- return NULL;
-
- static const char *const must_have_files[] = {
- FILENAME_ARCHITECTURE,
- FILENAME_KERNEL ,
- FILENAME_PACKAGE ,
- FILENAME_COMPONENT ,
- FILENAME_OS_RELEASE ,
- FILENAME_EXECUTABLE ,
- NULL
- };
- const char *const *v = must_have_files;
- while (*v)
- {
- if (!dd_exist(dd, *v))
- {
- /* Old dump dir format compat. Remove in abrt-2.1 */
- if (strcmp(*v, FILENAME_OS_RELEASE) == 0)
- if (dd_exist(dd, "release"))
- goto ok;
-
- dd_close(dd);
- log("Important file '%s/%s' is missing", dump_dir_name, *v);
- return NULL;
- }
- ok:
- v++;
- }
-
- crash_data_t *crash_data = create_crash_data_from_dump_dir(dd);
- char *events = list_possible_events(dd, NULL, "");
- dd_close(dd);
-
- add_to_crash_data_ext(crash_data, CD_EVENTS, events,
- CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
- free(events);
-
- add_to_crash_data_ext(crash_data, CD_DUMPDIR, dump_dir_name,
- CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
-
- return crash_data;
-}
-
-static char *do_log_and_update_client(char *log_line, void *param)
-{
- VERB1 log("%s", log_line);
- update_client("%s", log_line);
- return log_line;
-}
-
-/**
- * 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 pCrashData A filled crash report.
- * @return It return results of operation. See mw_result_t.
- */
-/*
- * Called in two cases:
- * (1) by StartJob dbus call -> CreateReportThread(), in the thread
- * (2) by CreateReport dbus call
- */
-static mw_result_t CreateCrashReport(const char *dump_dir_name,
- long caller_uid,
- int force,
- crash_data_t **crash_data)
-{
- VERB2 log("CreateCrashReport('%s',%ld)", dump_dir_name, caller_uid);
-
- *crash_data = NULL;
-
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- return MW_NOENT_ERROR;
-
- struct run_event_state *run_state;
- int res;
- mw_result_t r = MW_OK;
-
- if (caller_uid != 0) /* not called by root */
- {
- char caller_uid_str[sizeof(long) * 3 + 2];
- sprintf(caller_uid_str, "%ld", caller_uid);
-
- char *uid = dd_load_text_ext(dd, FILENAME_UID, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
- bool uid_matches = (uid == NULL || strcmp(uid, caller_uid_str) == 0);
- free(uid);
- if (!uid_matches)
- {
- dd_close(dd);
- error_msg("Dump directory '%s' can't be accessed by user with uid %ld",
- dump_dir_name, caller_uid);
- r = MW_PERM_ERROR;
- goto ret;
- }
- }
- dd_close(dd);
-
- run_state = new_run_event_state();
- run_state->logging_callback = do_log_and_update_client;
- res = run_event_on_dir_name(run_state, dump_dir_name, force ? "reanalyze" : "analyze");
- free_run_event_state(run_state);
- if (res != 0)
- {
- r = MW_PLUGIN_ERROR;
- goto ret;
- }
-
- /* Do a create_crash_data_from_dump_dir from (possibly updated)
- * crash dump dir
- */
- *crash_data = DebugDumpToCrashReport(dump_dir_name);
- if (!*crash_data)
- {
- error_msg("Error loading crash data");
- r = MW_ERROR;
- }
-
- ret:
- if (*crash_data == NULL)
- *crash_data = new_crash_data();
- VERB3 log("CreateCrashReport() returns %d", r);
- return r;
-}
struct logging_state {
char *last_line;
@@ -190,195 +51,6 @@ static char *do_log_and_save_line(char *log_line, void *param)
return NULL;
}
-// Do not trust client_report here!
-// dbus handler passes it from user without checking
-report_status_t Report(crash_data_t *client_report,
- const vector_string_t& events,
- const map_map_string_t& settings,
- long caller_uid)
-{
- report_status_t ret;
- const char *dump_dir_name = get_crash_item_content_or_NULL(client_report, CD_DUMPDIR);
- if (!dump_dir_name)
- {
- update_client("Reporting error: %s", "DUMPDIR is missing in client's report data");
- ret[""].push_back("0"); // REPORT_STATUS_IDX_FLAG
- ret[""].push_back("DUMPDIR is missing in client's report data"); // REPORT_STATUS_IDX_MSG
- return ret;
- }
-
- // Retrieve corresponding stored record
- crash_data_t *stored_report = FillCrashInfo(dump_dir_name);
- if (!stored_report)
- {
- return report_status_t();
- }
-
- // Is it allowed for this user to report?
- if (caller_uid != 0) // not called by root
- {
- char caller_uid_str[sizeof(long)*3 + 2];
- sprintf(caller_uid_str, "%ld", caller_uid);
- const char *uid = get_crash_item_content_or_NULL(stored_report, FILENAME_UID);
- if (uid && strcmp(caller_uid_str, uid) != 0)
- {
- free_crash_data(stored_report);
- char *errmsg = xasprintf("user with uid %ld can't report crash %s", caller_uid, dump_dir_name);
- update_client("Reporting error: %s", errmsg);
- ret[""].push_back("0"); // REPORT_STATUS_IDX_FLAG
- ret[""].push_back(errmsg); // REPORT_STATUS_IDX_MSG
- free(errmsg);
- return ret;
- }
- }
-
- // Save comment, backtrace
-//TODO: we should iterate through stored_report and modify all
-//modifiable fields which have new data in client_report
- const char *comment = get_crash_item_content_or_NULL(client_report, FILENAME_COMMENT);
- const char *backtrace = get_crash_item_content_or_NULL(client_report, FILENAME_BACKTRACE);
- if (comment || backtrace)
- {
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (dd)
- {
- if (comment)
- {
- dd_save_text(dd, FILENAME_COMMENT, comment);
- add_to_crash_data_ext(stored_report, FILENAME_COMMENT, comment, CD_FLAG_TXT + CD_FLAG_ISEDITABLE);
- }
- if (backtrace)
- {
- dd_save_text(dd, FILENAME_BACKTRACE, backtrace);
- add_to_crash_data_ext(stored_report, FILENAME_BACKTRACE, backtrace, CD_FLAG_TXT + CD_FLAG_ISEDITABLE);
- }
- dd_close(dd);
- }
- }
-
- /* Remove BIN filenames from stored_report if they are not present in client's data */
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, stored_report);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- if (value->flags & CD_FLAG_BIN)
- {
- if (get_crash_item_content_or_NULL(client_report, name) == NULL)
- {
- /* client does not have it -> does not want it passed to events */
- VERB3 log("Won't report BIN file %s:'%s'", name, value->content);
- g_hash_table_iter_remove(&iter);
- continue;
- }
- }
- }
-
- VERB3 {
- log_crash_data(client_report, " client_report");
- log_crash_data(stored_report, " stored_report");
- }
- free_crash_data(stored_report);
-#define stored_report stored_report_must_not_be_used_below
-#define client_report client_report_must_not_be_used_below
-
- // Export overridden settings as environment variables
- GList *env_list = NULL;
- map_map_string_t::const_iterator reporter_settings = settings.begin();
- while (reporter_settings != settings.end())
- {
- map_string_t::const_iterator var = reporter_settings->second.begin();
- while (var != reporter_settings->second.end())
- {
- char *s = xasprintf("%s_%s=%s", reporter_settings->first.c_str(), var->first.c_str(), var->second.c_str());
- VERB3 log("Exporting '%s'", s);
- putenv(s);
- env_list = g_list_append(env_list, s);
- var++;
- }
- reporter_settings++;
- }
-
- // Run events
- bool at_least_one_reporter_succeeded = false;
- std::string message;
- struct logging_state l_state;
- struct run_event_state *run_state = new_run_event_state();
- run_state->logging_callback = do_log_and_save_line;
- run_state->logging_param = &l_state;
- for (unsigned i = 0; i < events.size(); i++)
- {
- std::string event = events[i];
-
- l_state.last_line = NULL;
- int r = run_event_on_dir_name(run_state, dump_dir_name, event.c_str());
- if (r == 0 && run_state->children_count == 0)
- {
- l_state.last_line = xasprintf("Error: no processing is specified for event '%s'", event.c_str());
- r = -1;
- }
- if (r == 0)
- {
- at_least_one_reporter_succeeded = true;
- ret[event].push_back("1"); // REPORT_STATUS_IDX_FLAG
- ret[event].push_back(l_state.last_line ? : "Reporting succeeded"); // REPORT_STATUS_IDX_MSG
- if (message != "")
- message += ";";
- message += (l_state.last_line ? : "Reporting succeeded");
- }
- else
- {
- ret[event].push_back("0"); // REPORT_STATUS_IDX_FLAG
- ret[event].push_back(l_state.last_line ? : "Error in reporting"); // REPORT_STATUS_IDX_MSG
- update_client("Reporting via '%s' was not successful%s%s",
- event.c_str(),
- l_state.last_line ? ": " : "",
- l_state.last_line ? l_state.last_line : ""
- );
- }
- free(l_state.last_line);
- }
- free_run_event_state(run_state);
-
- // Unexport overridden settings
- for (GList *li = env_list; li; li = g_list_next(li))
- {
- char *s = (char*)li->data;
- VERB3 log("Unexporting '%s'", s);
- safe_unsetenv(s);
- free(s);
- }
- g_list_free(env_list);
-
- // Save reporting results
- if (at_least_one_reporter_succeeded)
- {
- report_status_t::iterator ret_it = ret.begin();
- while (ret_it != ret.end())
- {
-// const string &event = ret_it->first;
-// const vector_string_t &v = ret_it->second;
-// if (v[REPORT_STATUS_IDX_FLAG] == "1")
-// {
-// TODO: append to a log of reports done
-// database->SetReportedPerReporter(dump_dir_name, event.c_str(), v[REPORT_STATUS_IDX_MSG].c_str());
-// }
- ret_it++;
- }
- /* Was: database->SetReported(dump_dir_name, message.c_str()); */
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (dd)
- {
- add_reported_to(dd, message.c_str());
- dd_close(dd);
- }
- }
-
- return ret;
-#undef stored_report
-#undef client_report
-}
/* We need to share some data between LoadDebugDump and is_crash_a_dup: */
struct cdump_state {
@@ -580,161 +252,6 @@ static crash_data_t *FillCrashInfo(const char *dump_dir_name)
return crash_data;
}
-vector_of_crash_data_t *GetCrashInfos(long caller_uid)
-{
- vector_of_crash_data_t *retval = new_vector_of_crash_data();
- log("Getting crash infos...");
-
- DIR *dir = opendir(DEBUG_DUMPS_DIR);
- if (dir != NULL)
- {
- struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
- {
- if (dot_or_dotdot(dent->d_name))
- continue; /* skip "." and ".." */
-
- char *dump_dir_name = concat_path_file(DEBUG_DUMPS_DIR, dent->d_name);
-
- struct stat statbuf;
- if (stat(dump_dir_name, &statbuf) != 0
- || !S_ISDIR(statbuf.st_mode)
- ) {
- goto next; /* not a dir, skip */
- }
-
- /* Skip directories which are not for this uid */
- if (caller_uid != 0) /* not called by root? */
- {
- char *uid;
- char caller_uid_str[sizeof(long) * 3 + 2];
-
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- goto next;
-
- sprintf(caller_uid_str, "%ld", caller_uid);
- uid = dd_load_text(dd, FILENAME_UID);
- bool uid_matches = (uid == NULL || strcmp(uid, caller_uid_str) == 0);
- free(uid);
- dd_close(dd);
- if (!uid_matches)
- {
- goto next;
- }
- }
-
- {
- crash_data_t *crash_data = FillCrashInfo(dump_dir_name);
- if (!crash_data)
- {
- error_msg("Dump directory %s doesn't exist or misses crucial files, deleting", dump_dir_name);
- delete_dump_dir(dump_dir_name);
- }
- else
- {
- g_ptr_array_add(retval, crash_data);
- }
- }
- next:
- free(dump_dir_name);
- }
- closedir(dir);
- }
-
- return retval;
-}
-
-/*
- * Called in two cases:
- * (1) by StartJob dbus call -> CreateReportThread(), in the thread
- * (2) by CreateReport dbus call
- * In the second case, it finishes quickly, because previous
- * StartJob dbus call already did all the processing, and we just retrieve
- * the result from dump directory, which is fast.
- */
-void CreateReport(const char* crash_id, long caller_uid, int force, crash_data_t **crash_data)
-{
- /* FIXME: starting from here, any shared data must be protected with a mutex. */
- mw_result_t res = CreateCrashReport(crash_id, caller_uid, force, crash_data);
- switch (res)
- {
- case MW_OK:
- VERB2 log_crash_data(*crash_data, "crashReport");
- break;
- case MW_NOENT_ERROR:
- error_msg("Can't find crash with id '%s'", crash_id);
- break;
- case MW_PERM_ERROR:
- error_msg("Can't find crash with id '%s'", crash_id);
- break;
- case MW_PLUGIN_ERROR:
- error_msg("Particular analyzer plugin isn't loaded or there is an error within plugin(s)");
- break;
- default:
- error_msg("Corrupted crash with id %s, deleting", crash_id);
- DeleteDebugDump(crash_id, /*caller_uid:*/ 0);
- break;
- }
-}
-
-typedef struct thread_data_t {
- pthread_t thread_id;
- long caller_uid;
- int force;
- char* crash_id;
- char* peer;
-} thread_data_t;
-static void* create_report(void* arg)
-{
- thread_data_t *thread_data = (thread_data_t *) arg;
-
- /* Client name is per-thread, need to set it */
- set_client_name(thread_data->peer);
-
- log("Creating report...");
- crash_data_t *crash_data = NULL;
- CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, &crash_data);
- send_dbus_sig_JobDone(thread_data->peer);
- set_client_name(NULL);
-
- /* free strduped strings */
- free(thread_data->crash_id);
- free(thread_data->peer);
- free(thread_data);
-
- /* Bogus value. pthreads require us to return void* */
- return NULL;
-}
-int CreateReportThread(const char* crash_id, long caller_uid, int force, const char* pSender)
-{
- thread_data_t *thread_data = (thread_data_t *)xzalloc(sizeof(thread_data_t));
- thread_data->crash_id = xstrdup(crash_id);
- thread_data->caller_uid = caller_uid;
- thread_data->force = force;
- thread_data->peer = xstrdup(pSender);
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- int r = pthread_create(&thread_data->thread_id, &attr, create_report, thread_data);
- pthread_attr_destroy(&attr);
- if (r != 0)
- {
- free(thread_data->crash_id);
- free(thread_data->peer);
- free(thread_data);
- /* The only reason this may happen is system-wide resource starvation,
- * or ulimit is exceeded (someone floods us with CreateReport() dbus calls?)
- */
- error_msg("Can't create thread");
- return r;
- }
- VERB3 log("Thread %llx created", (unsigned long long)thread_data->thread_id);
- return r;
-}
-
-
/* Remove dump dir */
int DeleteDebugDump(const char *dump_dir_name, long caller_uid)
{
diff --git a/src/daemon/MiddleWare.h b/src/daemon/MiddleWare.h
index b3f6e60..4505527 100644
--- a/src/daemon/MiddleWare.h
+++ b/src/daemon/MiddleWare.h
@@ -38,31 +38,6 @@ typedef enum {
MW_PLUGIN_ERROR, /**< plugin wasn't found or error within plugin*/
} mw_result_t;
-typedef enum {
- RS_CODE,
- RS_MESSAGE
-} report_status_items_t;
-
-
-/**
- * Reports a crash report to particular receiver. It
- * takes an user uid, tries to find user config file and load it. If it
- * fails, then default config is used. If pUID is emply string, default
- * config is used.
- * ...).
- * @param crash_data
- * A crash report.
- * @param events
- * List of events to run.
- * @param caller_uid
- * An user uid.
- * @return
- * A report status: which events finished successfully, with messages.
- */
-report_status_t Report(crash_data_t *crash_data,
- const vector_string_t& events,
- const map_map_string_t& settings,
- long caller_uid);
/**
* Detects whether it's a duplicate crash dump.
* Fills crash info.
@@ -73,9 +48,6 @@ report_status_t Report(crash_data_t *crash_data,
*/
mw_result_t LoadDebugDump(const char *dump_dir_name, crash_data_t **crash_data);
-vector_of_crash_data_t *GetCrashInfos(long caller_uid);
-int CreateReportThread(const char* dump_dir_name, long caller_uid, int force, const char* pSender);
-void CreateReport(const char* dump_dir_name, long caller_uid, int force, crash_data_t **crash_data);
int DeleteDebugDump(const char *dump_dir_name, long caller_uid);
#endif /*MIDDLEWARE_H_*/
diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp
index b3d1ade..cb77d19 100644
--- a/src/daemon/Settings.cpp
+++ b/src/daemon/Settings.cpp
@@ -295,28 +295,6 @@ int load_settings()
return err;
}
-/* dbus call to retrieve .conf file data from daemon */
-map_abrt_settings_t GetSettings()
-{
- map_abrt_settings_t ABRTSettings;
-
- ABRTSettings[SECTION_COMMON] = s_mapSectionCommon;
-
- return ABRTSettings;
-}
-
-///* dbus call to change some .conf file data */
-//void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender)
-//{
-// map_abrt_settings_t::const_iterator it = pSettings.find(SECTION_COMMON);
-// map_abrt_settings_t::const_iterator end = pSettings.end();
-// if (it != end)
-// {
-// s_mapSectionCommon = it->second;
-// ParseCommon();
-// }
-//}
-
void free_settings()
{
list_free_with_free(g_settings_setOpenGPGPublicKeys);
diff --git a/src/daemon/Settings.h b/src/daemon/Settings.h
index dce6407..3f8af8f 100644
--- a/src/daemon/Settings.h
+++ b/src/daemon/Settings.h
@@ -24,10 +24,6 @@
#ifdef __cplusplus
typedef map_map_string_t map_abrt_settings_t;
-// looks unused to me.
-// Ok to grep for SetSettings and delete after 2011-04-01.
-// void SetSettings(const map_abrt_settings_t& pSettings, const char *dbus_sender);
-map_abrt_settings_t GetSettings();
extern "C" {
#endif
diff --git a/src/daemon/comm_layer_inner.cpp b/src/daemon/comm_layer_inner.cpp
index 9d5ddfc..7cba1c9 100644
--- a/src/daemon/comm_layer_inner.cpp
+++ b/src/daemon/comm_layer_inner.cpp
@@ -16,27 +16,16 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <pthread.h>
-#include <map>
#include "abrtlib.h"
#include "CommLayerServerDBus.h"
#include "comm_layer_inner.h"
-typedef std::map<uint64_t, std::string> map_uint_str_t;
-static map_uint_str_t s_mapClientID;
-static pthread_mutex_t s_map_mutex;
-static bool s_map_mutex_inited;
+static char *client_name = NULL;
/* called via [p]error_msg() */
static void warn_client(const char *msg)
{
- uint64_t key = uint64_t(pthread_self());
-
- pthread_mutex_lock(&s_map_mutex);
- map_uint_str_t::const_iterator ki = s_mapClientID.find(key);
- const char* peer = (ki != s_mapClientID.end() ? ki->second.c_str() : NULL);
- pthread_mutex_unlock(&s_map_mutex);
-
+ const char* peer = client_name;
if (peer)
{
send_dbus_sig_Warning(msg, peer);
@@ -45,36 +34,18 @@ static void warn_client(const char *msg)
void init_daemon_logging(void)
{
- if (!s_map_mutex_inited)
- {
- s_map_mutex_inited = true;
- pthread_mutex_init(&s_map_mutex, NULL);
- g_custom_logger = &warn_client;
- }
+ g_custom_logger = &warn_client;
}
void set_client_name(const char *name)
{
- uint64_t key = uint64_t(pthread_self());
-
- pthread_mutex_lock(&s_map_mutex);
- if (!name) {
- s_mapClientID.erase(key);
- } else {
- s_mapClientID[key] = name;
- }
- pthread_mutex_unlock(&s_map_mutex);
+ free(client_name);
+ client_name = xstrdup(name);
}
void update_client(const char *fmt, ...)
{
- uint64_t key = uint64_t(pthread_self());
-
- pthread_mutex_lock(&s_map_mutex);
- map_uint_str_t::const_iterator ki = s_mapClientID.find(key);
- const char* peer = (ki != s_mapClientID.end() ? ki->second.c_str() : NULL);
- pthread_mutex_unlock(&s_map_mutex);
-
+ const char* peer = client_name;
if (!peer)
return;