summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/abrt-plugin/abrt-reporter-hello-world.cpp1
-rw-r--r--src/cli/CLI.cpp1
-rw-r--r--src/cli/report.cpp39
-rw-r--r--src/daemon/CommLayerServerDBus.cpp23
-rw-r--r--src/daemon/Daemon.cpp106
-rw-r--r--src/daemon/MiddleWare.cpp189
-rw-r--r--src/daemon/MiddleWare.h2
-rw-r--r--src/daemon/PluginManager.cpp49
-rw-r--r--src/daemon/PluginManager.h4
-rw-r--r--src/hooks/dumpoops.cpp1
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/abrt_exception.h57
-rw-r--r--src/include/abrt_types.h27
-rw-r--r--src/include/abrtlib.h30
-rw-r--r--src/include/plugin.h1
-rw-r--r--src/lib/Makefile.am2
-rw-r--r--src/lib/abrt_dbus.c28
-rw-r--r--src/lib/abrt_dbus.h1
-rw-r--r--src/lib/abrt_types.c (renamed from src/lib/ABRTException.cpp)30
-rw-r--r--src/lib/abrt_xmlrpc.cpp4
-rw-r--r--src/lib/load_plugin_settings.cpp36
-rw-r--r--src/plugins/CCpp.cpp1
-rw-r--r--src/plugins/KerneloopsScanner.cpp1
-rw-r--r--src/plugins/abrt-action-bugzilla.cpp57
-rw-r--r--src/plugins/abrt-action-kerneloops.cpp24
-rw-r--r--src/plugins/abrt-action-mailx.cpp31
-rw-r--r--src/plugins/abrt-action-print.cpp27
-rw-r--r--src/plugins/abrt-action-rhtsupport.cpp33
-rw-r--r--src/plugins/abrt-action-upload.cpp26
29 files changed, 347 insertions, 485 deletions
diff --git a/doc/abrt-plugin/abrt-reporter-hello-world.cpp b/doc/abrt-plugin/abrt-reporter-hello-world.cpp
index 30a55e88..471e5087 100644
--- a/doc/abrt-plugin/abrt-reporter-hello-world.cpp
+++ b/doc/abrt-plugin/abrt-reporter-hello-world.cpp
@@ -18,7 +18,6 @@
*/
#include <abrt/abrtlib.h>
-#include <abrt/abrt_exception.h>
#include "abrt-reporter-hello-world.h"
std::string CHelloWorld::Report(const map_crash_data_t& pCrashData,
diff --git a/src/cli/CLI.cpp b/src/cli/CLI.cpp
index fd8ec4f0..cdce6b8a 100644
--- a/src/cli/CLI.cpp
+++ b/src/cli/CLI.cpp
@@ -19,7 +19,6 @@
# include <locale.h>
#endif
#include <getopt.h>
-#include "abrt_exception.h"
#include "abrtlib.h"
#include "abrt_dbus.h"
#include "dbus_common.h"
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 4c38e852..556e06b4 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -521,26 +521,35 @@ static GHashTable *get_reporter_plugin_settings(const vector_string_t& reporters
if (homedir)
{
GHashTableIter iter;
- gpointer key, value;
-
+ char *key;
+ map_string_t *value;
g_hash_table_iter_init(&iter, settings);
- while (g_hash_table_iter_next(&iter, &key, &value))
+ while (g_hash_table_iter_next(&iter, (void**)&key, (void**)&value))
{
- map_string_t single_plugin_settings;
-
- char *path = xasprintf("%s/.abrt/%s.conf", homedir, (char *)key);
-
- /* Load plugin config in the home dir. Do not skip lines with empty value (but containing a "key="),
- because user may want to override password from /etc/abrt/plugins/*.conf, but he prefers to
- enter it every time he reports. */
- bool success = LoadPluginSettings(path, single_plugin_settings, false);
+ /* Load plugin config in the home dir. Do not skip lines
+ * with empty value (but containing a "key="),
+ * because user may want to override password
+ * from /etc/abrt/plugins/*.conf, but he prefers to
+ * enter it every time he reports. */
+ map_string_h *single_plugin_settings = new_map_string();
+ char *path = xasprintf("%s/.abrt/%s.conf", homedir, key);
+ bool success = load_conf_file(path, single_plugin_settings, /*skip key w/o values:*/ false);
free(path);
if (!success)
+ {
+ free_map_string(single_plugin_settings);
continue;
- // Merge user's plugin settings into already loaded settings.
- map_string_t::const_iterator valit, valitend = single_plugin_settings.end();
- for (valit = single_plugin_settings.begin(); valit != valitend; ++valit)
- (*(map_string_t*)value)[valit->first] = valit->second;
+ }
+
+ /* Merge user's plugin settings into already loaded settings */
+ GHashTableIter iter2;
+ char *key2;
+ char *value2;
+ g_hash_table_iter_init(&iter2, single_plugin_settings);
+ while (g_hash_table_iter_next(&iter2, (void**)&key2, (void**)&value2))
+ (*value)[key2] = xstrdup(value2);
+
+ free_map_string(single_plugin_settings);
}
}
return settings;
diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp
index 14f132b3..b9b7f20b 100644
--- a/src/daemon/CommLayerServerDBus.cpp
+++ b/src/daemon/CommLayerServerDBus.cpp
@@ -19,7 +19,6 @@
#include <dbus/dbus.h>
#include "abrtlib.h"
#include "abrt_dbus.h"
-#include "abrt_exception.h"
#include "comm_layer_inner.h"
#include "dbus_common.h"
#include "MiddleWare.h"
@@ -275,20 +274,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply)
}
unix_uid = get_remote_uid(call);
- try
- {
- argout1 = Report(crash_data, events, user_conf_data, unix_uid);
- }
- catch (CABRTException &e)
- {
- dbus_message_unref(reply);
- reply = dbus_message_new_error(call, DBUS_ERROR_FAILED, e.what());
- if (!reply)
- die_out_of_memory();
- send_flush_and_unref(reply);
- r = 0;
- goto ret;
- }
+ argout1 = Report(crash_data, events, user_conf_data, unix_uid);
DBusMessageIter out_iter;
dbus_message_iter_init_append(reply, &out_iter);
@@ -353,12 +339,13 @@ static int handle_GetPluginSettings(DBusMessage* call, DBusMessage* reply)
//long unix_uid = get_remote_uid(call);
//VERB1 log("got %s('%s') call from uid %ld", "GetPluginSettings", PluginName, unix_uid);
- map_plugin_settings_t plugin_settings;
- GetPluginSettings(PluginName, plugin_settings);
+ map_string_h *plugin_settings = GetPluginSettings(PluginName);
DBusMessageIter out_iter;
dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, plugin_settings);
+ store_map_string(&out_iter, plugin_settings);
+
+ free_map_string(plugin_settings);
send_flush_and_unref(reply);
return 0;
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 62bcdc68..f98d8741 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -27,7 +27,6 @@
#include <sys/ioctl.h> /* ioctl(FIONREAD) */
#include <glib.h>
#include "abrtlib.h"
-#include "abrt_exception.h"
#include "comm_layer_inner.h"
#include "Settings.h"
#include "CommLayerServerDBus.h"
@@ -543,63 +542,49 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
char *fullname = NULL;
crash_data_t *crash_data = NULL;
- try
+ fullname = concat_path_file(DEBUG_DUMPS_DIR, name);
+ mw_result_t res = LoadDebugDump(fullname, &crash_data);
+ switch (res)
{
- fullname = concat_path_file(DEBUG_DUMPS_DIR, name);
- mw_result_t res = LoadDebugDump(fullname, &crash_data);
- switch (res)
- {
- case MW_OK:
- log("New crash %s, processing", fullname);
- /* Fall through */
+ case MW_OK:
+ log("New crash %s, processing", fullname);
+ /* Fall through */
- case MW_OCCURRED: /* dup */
+ case MW_OCCURRED: /* dup */
+ {
+ if (res != MW_OK)
{
- if (res != MW_OK)
- {
- const char *first = get_crash_item_content_or_NULL(crash_data, CD_DUMPDIR);
- log("Deleting crash %s (dup of %s), sending dbus signal",
- strrchr(fullname, '/') + 1,
- strrchr(first, '/') + 1);
- delete_crash_dump_dir(fullname);
- }
-
- const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID);
- const char *inform_all = get_crash_item_content_or_NULL(crash_data, FILENAME_INFORMALL);
-
- if (inform_all && string_to_bool(inform_all))
- uid_str = NULL;
- char *crash_id = xasprintf("%s:%s",
- get_crash_item_content_or_NULL(crash_data, FILENAME_UID),
- get_crash_item_content_or_NULL(crash_data, FILENAME_UUID)
- );
- /* Send dbus signal */
- g_pCommLayer->Crash(get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE),
- crash_id, //TODO: stop passing this param, it is unused
- fullname,
- uid_str
- );
- free(crash_id);
- break;
- }
- case MW_CORRUPTED:
- case MW_GPG_ERROR:
- default:
- log("Corrupted or bad crash %s (res:%d), deleting", fullname, (int)res);
+ const char *first = get_crash_item_content_or_NULL(crash_data, CD_DUMPDIR);
+ log("Deleting crash %s (dup of %s), sending dbus signal",
+ strrchr(fullname, '/') + 1,
+ strrchr(first, '/') + 1);
delete_crash_dump_dir(fullname);
- break;
+ }
+
+ const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID);
+ const char *inform_all = get_crash_item_content_or_NULL(crash_data, FILENAME_INFORMALL);
+
+ if (inform_all && string_to_bool(inform_all))
+ uid_str = NULL;
+ char *crash_id = xasprintf("%s:%s",
+ get_crash_item_content_or_NULL(crash_data, FILENAME_UID),
+ get_crash_item_content_or_NULL(crash_data, FILENAME_UUID)
+ );
+ /* Send dbus signal */
+ g_pCommLayer->Crash(get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE),
+ crash_id, //TODO: stop passing this param, it is unused
+ fullname,
+ uid_str
+ );
+ free(crash_id);
+ break;
}
- }
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
- }
- catch (...)
- {
- free(fullname);
- free(buf);
- free_crash_data(crash_data);
- throw;
+ case MW_CORRUPTED:
+ case MW_GPG_ERROR:
+ default:
+ log("Corrupted or bad crash %s (res:%d), deleting", fullname, (int)res);
+ delete_crash_dump_dir(fullname);
+ break;
}
free(fullname);
free_crash_data(crash_data);
@@ -899,19 +884,8 @@ int main(int argc, char** argv)
s_signal_pipe_write = s_signal_pipe[1];
/* Enter the event loop */
- try
- {
- log("Init complete, entering main loop");
- run_main_loop(pMainloop);
- }
- catch (CABRTException& e)
- {
- error_msg("Error: %s", e.what());
- }
- catch (std::exception& e)
- {
- error_msg("Error: %s", e.what());
- }
+ log("Init complete, entering main loop");
+ run_main_loop(pMainloop);
cleanup:
/* Error or INT/TERM. Clean up, in reverse order.
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index 6abf019e..7135a50a 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -21,7 +21,6 @@
#include "abrtlib.h"
#include "Daemon.h"
#include "Settings.h"
-#include "abrt_exception.h"
#include "comm_layer_inner.h"
#include "CommLayerServer.h"
#include "MiddleWare.h"
@@ -127,6 +126,8 @@ static mw_result_t CreateCrashReport(const char *dump_dir_name,
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 */
@@ -151,37 +152,24 @@ static mw_result_t CreateCrashReport(const char *dump_dir_name,
}
dd_close(dd);
- try
+ run_state = new_run_event_state();
+ run_state->logging_callback = do_log_and_update_client;
+ res = run_event(run_state, dump_dir_name, force ? "reanalyze" : "analyze");
+ free_run_event_state(run_state);
+ if (res != 0 && res != -1) /* -1 is "nothing was done", here it is ok */
{
- struct run_event_state *run_state = new_run_event_state();
- run_state->logging_callback = do_log_and_update_client;
- int res = run_event(run_state, dump_dir_name, force ? "reanalyze" : "analyze");
- free_run_event_state(run_state);
- if (res != 0 && res != -1) /* -1 is "nothing was done", here it is ok */
- {
- r = MW_PLUGIN_ERROR;
- goto ret;
- }
-
- /* Do a load_crash_data_from_crash_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;
- goto ret;
- }
+ r = MW_PLUGIN_ERROR;
+ goto ret;
}
- catch (CABRTException& e)
+
+ /* Do a load_crash_data_from_crash_dump_dir from (possibly updated)
+ * crash dump dir
+ */
+ *crash_data = DebugDumpToCrashReport(dump_dir_name);
+ if (!*crash_data)
{
- r = MW_CORRUPTED;
- error_msg("%s", e.what());
- if (e.type() == EXCEP_PLUGIN)
- {
- r = MW_PLUGIN_ERROR;
- }
+ error_msg("Error loading crash data");
+ r = MW_ERROR;
}
ret:
@@ -199,14 +187,7 @@ void RunAction(const char *pActionDir,
/* GetAction() already complained */
return;
}
- try
- {
- action->Run(pActionDir, pPluginArgs, /*force:*/ 0);
- }
- catch (CABRTException& e)
- {
- error_msg("Execution of '%s' was not successful: %s", pPluginName, e.what());
- }
+ action->Run(pActionDir, pPluginArgs, /*force:*/ 0);
}
struct logging_state {
@@ -231,12 +212,14 @@ report_status_t Report(crash_data_t *client_report,
const map_map_string_t& settings,
long caller_uid)
{
- // Get ID fields
- const char *UID = get_crash_item_content_or_NULL(client_report, FILENAME_UID);
+ report_status_t ret;
const char *dump_dir_name = get_crash_item_content_or_NULL(client_report, CD_DUMPDIR);
- if (!UID || !dump_dir_name)
+ if (!dump_dir_name)
{
- throw CABRTException(EXCEP_ERROR, "Report(): UID or DUMPDIR is missing in client's report data");
+ 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
@@ -248,14 +231,18 @@ report_status_t Report(crash_data_t *client_report,
// Is it allowed for this user to report?
if (caller_uid != 0 // not called by root
- && strcmp(to_string(caller_uid).c_str(), UID) != 0
+ && strcmp(to_string(caller_uid).c_str(), get_crash_item_content_or_die(stored_report, FILENAME_UID)) != 0
) {
const char *inform_all = get_crash_item_content_or_NULL(stored_report, FILENAME_INFORMALL);
if (!inform_all || !string_to_bool(inform_all))
{
free_crash_data(stored_report);
- throw CABRTException(EXCEP_ERROR, "Report(): user with uid %ld can't report crash %s",
- caller_uid, dump_dir_name);
+ 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;
}
}
@@ -335,7 +322,6 @@ report_status_t Report(crash_data_t *client_report,
// Run events
bool at_least_one_reporter_succeeded = false;
- report_status_t ret;
std::string message;
struct logging_state l_state;
struct run_event_state *run_state = new_run_event_state();
@@ -620,68 +606,61 @@ vector_of_crash_data_t *GetCrashInfos(long caller_uid)
DIR *dir = opendir(DEBUG_DUMPS_DIR);
if (dir != NULL)
{
- try
+ struct dirent *dent;
+ while ((dent = readdir(dir)) != NULL)
{
- struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
- {
- if (dot_or_dotdot(dent->d_name))
- continue; /* skip "." and ".." */
+ if (dot_or_dotdot(dent->d_name))
+ continue; /* skip "." and ".." */
- char *dump_dir_name = concat_path_file(DEBUG_DUMPS_DIR, dent->d_name);
+ 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 */
- }
+ 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];
+ /* 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;
+ 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);
- if (strcmp(uid, caller_uid_str) != 0)
+ sprintf(caller_uid_str, "%ld", caller_uid);
+ uid = dd_load_text(dd, FILENAME_UID);
+ if (strcmp(uid, caller_uid_str) != 0)
+ {
+ char *inform_all = dd_load_text_ext(dd, FILENAME_INFORMALL, DD_FAIL_QUIETLY);
+ bool for_all = string_to_bool(inform_all);
+ free(inform_all);
+ if (!for_all)
{
- char *inform_all = dd_load_text_ext(dd, FILENAME_INFORMALL, DD_FAIL_QUIETLY);
- bool for_all = string_to_bool(inform_all);
- free(inform_all);
- if (!for_all)
- {
- dd_close(dd);
- goto next;
- }
+ dd_close(dd);
+ goto next;
}
- dd_close(dd);
}
+ dd_close(dd);
+ }
+ {
+ crash_data_t *crash_data = FillCrashInfo(dump_dir_name);
+ if (!crash_data)
{
- 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_crash_dump_dir(dump_dir_name);
- }
- else
- {
- g_ptr_array_add(retval, crash_data);
- }
+ error_msg("Dump directory %s doesn't exist or misses crucial files, deleting", dump_dir_name);
+ delete_crash_dump_dir(dump_dir_name);
+ }
+ else
+ {
+ g_ptr_array_add(retval, crash_data);
}
- next:
- free(dump_dir_name);
}
- }
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
+ next:
+ free(dump_dir_name);
}
closedir(dir);
}
@@ -736,18 +715,10 @@ static void* create_report(void* arg)
/* Client name is per-thread, need to set it */
set_client_name(thread_data->peer);
- try
- {
- log("Creating report...");
- crash_data_t *crash_data = NULL;
- CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, &crash_data);
- g_pCommLayer->JobDone(thread_data->peer);
- }
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
- }
- catch (...) {}
+ log("Creating report...");
+ crash_data_t *crash_data = NULL;
+ CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, &crash_data);
+ g_pCommLayer->JobDone(thread_data->peer);
set_client_name(NULL);
/* free strduped strings */
@@ -874,10 +845,12 @@ void GetPluginsInfo(map_map_string_t &map_of_plugin_info)
closedir(dir);
}
-void GetPluginSettings(const char *plugin_name, map_plugin_settings_t &plugin_settings)
+map_string_h *GetPluginSettings(const char *plugin_name)
{
char *conf_file = xasprintf(PLUGINS_CONF_DIR"/%s.conf", plugin_name);
- if (LoadPluginSettings(conf_file, plugin_settings, /*skip w/o value:*/ false))
+ map_string_h *settings = new_map_string();
+ if (load_conf_file(conf_file, settings, /*skip w/o value:*/ false))
VERB3 log("Loaded %s.conf", plugin_name);
free(conf_file);
+ return settings;
}
diff --git a/src/daemon/MiddleWare.h b/src/daemon/MiddleWare.h
index 55c84c3b..4826d79d 100644
--- a/src/daemon/MiddleWare.h
+++ b/src/daemon/MiddleWare.h
@@ -91,6 +91,6 @@ void CreateReport(const char* dump_dir_name, long caller_uid, int force, crash_d
int DeleteDebugDump(const char *dump_dir_name, long caller_uid);
void GetPluginsInfo(map_map_string_t &map_of_plugin_info);
-void GetPluginSettings(const char *plugin_name, map_plugin_settings_t &plugin_settings);
+map_string_h *GetPluginSettings(const char *plugin_name);
#endif /*MIDDLEWARE_H_*/
diff --git a/src/daemon/PluginManager.cpp b/src/daemon/PluginManager.cpp
index 665a4625..f8f6b8f8 100644
--- a/src/daemon/PluginManager.cpp
+++ b/src/daemon/PluginManager.cpp
@@ -20,7 +20,6 @@
*/
#include <dlfcn.h>
#include "abrtlib.h"
-#include "abrt_exception.h"
#include "PluginManager.h"
using namespace std;
@@ -132,18 +131,14 @@ CPlugin* CPluginManager::LoadPlugin(const char *pName, bool enabled_only)
/* Kerneloops{,Scanner,Reporter} share the same .conf file */
conf_name = "Kerneloops";
}
- map_plugin_settings_t pluginSettings;
string conf_fullname = ssprintf(PLUGINS_CONF_DIR"/%s."PLUGINS_CONF_EXTENSION, conf_name);
- LoadPluginSettings(conf_fullname.c_str(), pluginSettings);
- m_map_plugin_settings[pName] = pluginSettings;
- /* If settings are empty, most likely .conf file does not exist.
- * Don't mislead the user: */
- VERB3 if (!pluginSettings.empty()) log("Loaded %s.conf", conf_name);
+ map_string_h *pluginSettings = new_map_string();
+ if (load_conf_file(conf_fullname.c_str(), pluginSettings, /*skip key w/o values:*/ true))
+ VERB3 log("Loaded %s.conf", conf_name);
if (enabled_only)
{
- map_plugin_settings_t::iterator it = pluginSettings.find("Enabled");
- if (it == pluginSettings.end() || !string_to_bool(it->second.c_str()))
+ if (!string_to_bool(get_map_string_item_or_empty(pluginSettings, "Enabled")))
{
plugin_info["Enabled"] = "no";
string empty;
@@ -163,6 +158,7 @@ CPlugin* CPluginManager::LoadPlugin(const char *pName, bool enabled_only)
if (!handle)
{
error_msg("Can't load '%s': %s", libPath.c_str(), dlerror());
+ free_map_string(pluginSettings);
return NULL; /* error */
}
CLoadedModule *module = new CLoadedModule(handle, pName);
@@ -175,27 +171,32 @@ CPlugin* CPluginManager::LoadPlugin(const char *pName, bool enabled_only)
module->GetMagicNumber(), PLUGINS_MAGIC_NUMBER,
module->GetType(), MAX_PLUGIN_TYPE);
delete module;
+ free_map_string(pluginSettings);
return NULL; /* error */
}
VERB3 log("Loaded plugin %s v.%s", pName, module->GetVersion());
CPlugin *plugin = NULL;
- try
+ plugin = module->PluginNew();
+ plugin->Init();
+ /* Need to convert pluginSettings from map_string_h container
+ * to map_string_t, since plugin->SetSettings() needs that type.
+ * To be removed when remaining uses of map_string_t
+ * are globally converted to map_string_h.
+ */
{
- plugin = module->PluginNew();
- plugin->Init();
- plugin->SetSettings(pluginSettings);
- }
- catch (CABRTException& e)
- {
- error_msg("Can't initialize plugin %s: %s",
- pName,
- e.what()
- );
- delete plugin;
- delete module;
- return NULL; /* error */
+ map_string_t pluginSettings2;
+ GHashTableIter iter;
+ char *name;
+ char *value;
+ g_hash_table_iter_init(&iter, pluginSettings);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ pluginSettings2[name] = value;
+ }
+ plugin->SetSettings(pluginSettings2);
}
+ free_map_string(pluginSettings);
plugin_info["Enabled"] = "yes";
plugin_info["Type"] = plugin_type_str[module->GetType()];
@@ -252,7 +253,7 @@ plugin_type_t CPluginManager::GetPluginType(const char *pName)
CPlugin *plugin = LoadPlugin(pName);
if (!plugin)
{
- throw CABRTException(EXCEP_PLUGIN, "Plugin '%s' is not registered", pName);
+ return INVALID_PLUGIN_TYPE;
}
map_loaded_module_t::iterator it_module = m_mapLoadedModules.find(pName);
return it_module->second->GetType();
diff --git a/src/daemon/PluginManager.h b/src/daemon/PluginManager.h
index c5036fbf..1108b985 100644
--- a/src/daemon/PluginManager.h
+++ b/src/daemon/PluginManager.h
@@ -48,10 +48,6 @@ class CPluginManager
* Registered plugins. A key is a plugin name.
*/
map_plugin_t m_mapPlugins;
- /**
- * List of all possible plugins (loaded or not), with some attributes.
- */
- map_map_string_t m_map_plugin_settings;
public:
/**
diff --git a/src/hooks/dumpoops.cpp b/src/hooks/dumpoops.cpp
index c67f8cda..6e0d2d59 100644
--- a/src/hooks/dumpoops.cpp
+++ b/src/hooks/dumpoops.cpp
@@ -22,7 +22,6 @@
*/
#include "abrtlib.h"
-#include "abrt_exception.h"
#include "KerneloopsScanner.h"
#include <dlfcn.h>
#include <glib.h>
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index c035aaa9..5b61bd82 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -3,7 +3,6 @@ HEADER_FILES = \
dump_dir.h \
run_event.h \
\
- abrt_exception.h \
abrtlib.h \
abrt_types.h \
comm_layer_inner.h \
diff --git a/src/include/abrt_exception.h b/src/include/abrt_exception.h
deleted file mode 100644
index b826bfa8..00000000
--- a/src/include/abrt_exception.h
+++ /dev/null
@@ -1,57 +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 ABRTEXCEPTION_H_
-#define ABRTEXCEPTION_H_
-
-#include "abrtlib.h"
-
-typedef enum {
- EXCEP_UNKNOW,
- EXCEP_DD_OPEN,
- EXCEP_DD_LOAD,
- EXCEP_DD_SAVE,
- EXCEP_DD_DELETE,
- EXCEP_DL,
- EXCEP_PLUGIN,
- EXCEP_ERROR,
-} abrt_exception_t;
-
-/* std::exception is a class with virtual members.
- * deriving from it makes our ctor/dtor much more heavy,
- * and those are inlined in every throw and catch site!
- */
-class CABRTException /*: public std::exception*/
-{
- private:
- abrt_exception_t m_type;
- char *m_what;
-
- /* Not defined. You can't use it */
- CABRTException& operator= (const CABRTException&);
-
- public:
- ~CABRTException() { free(m_what); }
- CABRTException(abrt_exception_t type, const char* fmt, ...);
- CABRTException(const CABRTException& rhs);
-
- abrt_exception_t type() { return m_type; }
- const char* what() const { return m_what; }
-};
-
-#endif
diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h
index 38804895..3ebd1697 100644
--- a/src/include/abrt_types.h
+++ b/src/include/abrt_types.h
@@ -19,6 +19,33 @@
#ifndef ABRT_TYPES_H_
#define ABRT_TYPES_H_
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We can't typedef it to map_string_t, since other parts of ABRT
+ * (daemon, cli) still use that name for C++ container. For now,
+ * let's call it map_string_h:
+ */
+typedef GHashTable map_string_h;
+
+map_string_h *new_map_string(void);
+void free_map_string(map_string_h *ms);
+const char *get_map_string_item_or_empty(map_string_h *ms, const char *key);
+static inline
+const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key)
+{
+ return (const char*)g_hash_table_lookup(ms, key);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
#ifdef __cplusplus
#include <map>
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
index a4337709..f3a5de4e 100644
--- a/src/include/abrtlib.h
+++ b/src/include/abrtlib.h
@@ -224,6 +224,20 @@ char* make_description_mailx(crash_data_t *crash_data);
void parse_release(const char *pRelease, char **product, char **version);
+/**
+ * Loads settings and stores it in second parameter. On success it
+ * returns true, otherwise returns false.
+ *
+ * @param path A path of config file.
+ * Config file consists of "key=value" lines.
+ * @param settings A read plugin's settings.
+ * @param skipKeysWithoutValue
+ * If true, lines in format "key=" (without value) are skipped.
+ * Otherwise empty value "" is inserted into pSettings.
+ * @return if it success it returns true, otherwise it returns false.
+ */
+bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue);
+
#ifdef __cplusplus
}
#endif
@@ -241,22 +255,6 @@ std::string to_string(T x)
return unsigned_to_string(x);
}
-/**
- * Loads settings and stores it in second parameter. On success it
- * returns true, otherwise returns false.
- *
- * @param path A path of config file.
- * Config file consists of "key=value" lines.
- * @param settings A readed plugin's settings.
- * @param skipKeysWithoutValue
- * If true, lines in format "key=" (without value) are skipped.
- * Otherwise empty value "" is inserted into pSettings.
- * @return if it success it returns true, otherwise it returns false.
- */
-extern bool LoadPluginSettings(const char *pPath,
- map_plugin_settings_t& pSettings,
- bool skipKeysWithoutValue = true);
-
// TODO: npajkovs: full rewrite ssprintf -> xasprintf
static inline std::string ssprintf(const char *format, ...)
{
diff --git a/src/include/plugin.h b/src/include/plugin.h
index 3f652e65..322c212f 100644
--- a/src/include/plugin.h
+++ b/src/include/plugin.h
@@ -76,6 +76,7 @@ typedef enum {
REPORTER, /**< A reporter plugin*/
DATABASE, /**< A database plugin*/
MAX_PLUGIN_TYPE = DATABASE,
+ INVALID_PLUGIN_TYPE
} plugin_type_t;
/**
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 015632fd..8212ebf7 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -40,7 +40,7 @@ libabrt_la_SOURCES = \
run_event.c \
crash_dump.cpp \
create_crash_dump_dir.cpp \
- ABRTException.cpp \
+ abrt_types.c \
hooklib.c hooklib.h \
parse_release.cpp \
parse_options.c parse_options.h
diff --git a/src/lib/abrt_dbus.c b/src/lib/abrt_dbus.c
index 2ba5fa12..69ac1241 100644
--- a/src/lib/abrt_dbus.c
+++ b/src/lib/abrt_dbus.c
@@ -156,6 +156,34 @@ void store_string(DBusMessageIter* iter, const char* val)
free((char*)sanitized);
}
+/* Helper for storing map_string */
+void store_map_string(DBusMessageIter* dbus_iter, map_string_h *val)
+{
+ DBusMessageIter sub_iter;
+ /* map_string is a map. map in dbus is an array of two element structs "({...})":
+ * "s" (string) for key and "s" for value (in this case, also string) */
+ if (!dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY, "{ss}", &sub_iter))
+ die_out_of_memory();
+
+ GHashTableIter iter;
+ char *name;
+ char *value;
+ g_hash_table_iter_init(&iter, val);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ DBusMessageIter sub_sub_iter;
+ if (!dbus_message_iter_open_container(&sub_iter, DBUS_TYPE_DICT_ENTRY, NULL, &sub_sub_iter))
+ die_out_of_memory();
+ store_string(&sub_sub_iter, name);
+ store_string(&sub_sub_iter, value);
+ if (!dbus_message_iter_close_container(&sub_iter, &sub_sub_iter))
+ die_out_of_memory();
+ }
+
+ if (!dbus_message_iter_close_container(dbus_iter, &sub_iter))
+ die_out_of_memory();
+}
+
/* Helpers for storing crash_data */
static void store_crash_item(DBusMessageIter* iter, struct crash_item *val)
diff --git a/src/lib/abrt_dbus.h b/src/lib/abrt_dbus.h
index b971280c..2f32b26f 100644
--- a/src/lib/abrt_dbus.h
+++ b/src/lib/abrt_dbus.h
@@ -85,6 +85,7 @@ void store_uint64(DBusMessageIter* iter, uint64_t val);
void store_string(DBusMessageIter* iter, const char* val);
void store_crash_data(DBusMessageIter* iter, crash_data_t *val);
void store_vector_of_crash_data(DBusMessageIter* iter, vector_of_crash_data_t *val);
+void store_map_string(DBusMessageIter* iter, map_string_h *val);
/*
* Helpers for parsing DBus messages
diff --git a/src/lib/ABRTException.cpp b/src/lib/abrt_types.c
index 0ae5d452..42100075 100644
--- a/src/lib/ABRTException.cpp
+++ b/src/lib/abrt_types.c
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
+ 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
@@ -16,18 +16,22 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "abrt_exception.h"
+#include "abrtlib.h"
-CABRTException::CABRTException(abrt_exception_t type, const char* fmt, ...)
+map_string_h *new_map_string(void)
{
- m_type = type;
- va_list ap;
- va_start(ap, fmt);
- m_what = xvasprintf(fmt, ap);
- va_end(ap);
+ return g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
}
-CABRTException::CABRTException(const CABRTException& rhs):
- m_type(rhs.m_type),
- m_what(xstrdup(rhs.m_what))
-{}
+void free_map_string(map_string_h *ms)
+{
+ if (ms)
+ g_hash_table_destroy(ms);
+}
+
+const char *get_map_string_item_or_empty(map_string_h *ms, const char *key)
+{
+ const char *v = (const char*)g_hash_table_lookup(ms, key);
+ if (!v) v = "";
+ return v;
+}
diff --git a/src/lib/abrt_xmlrpc.cpp b/src/lib/abrt_xmlrpc.cpp
index bf74f05b..6dfa8313 100644
--- a/src/lib/abrt_xmlrpc.cpp
+++ b/src/lib/abrt_xmlrpc.cpp
@@ -18,15 +18,13 @@
*/
#include "abrtlib.h"
#include "abrt_xmlrpc.h"
-#include "abrt_exception.h"
void throw_xml_fault(xmlrpc_env *env)
{
std::string errmsg = ssprintf("XML-RPC Fault(%d): %s", env->fault_code, env->fault_string);
xmlrpc_env_clean(env); // this is needed ONLY if fault_occurred
xmlrpc_env_init(env); // just in case user catches ex and _continues_ to use env
- error_msg("%s", errmsg.c_str()); // show error in daemon log
- throw CABRTException(EXCEP_PLUGIN, errmsg.c_str());
+ error_msg_and_die("%s", errmsg.c_str()); // show error in daemon log
}
void throw_if_xml_fault_occurred(xmlrpc_env *env)
diff --git a/src/lib/load_plugin_settings.cpp b/src/lib/load_plugin_settings.cpp
index 1052f19e..0f389069 100644
--- a/src/lib/load_plugin_settings.cpp
+++ b/src/lib/load_plugin_settings.cpp
@@ -18,8 +18,10 @@
*/
#include "abrtlib.h"
-bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings,
- bool skipKeysWithoutValue /*= true*/)
+/* Returns NULL if open failed.
+ * Returns empty hash if conf file is empty.
+ */
+bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue)
{
FILE *fp = stdin;
if (strcmp(pPath, "-") != 0)
@@ -36,8 +38,13 @@ bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings,
bool is_value = false;
bool valid = false;
bool in_quote = false;
- std::string key;
- std::string value;
+ /* We are reusing line buffer to form temporary
+ * "key\0value\0..." in its beginning
+ */
+ char *key = line;
+ char *value = line;
+ char *cur = line;
+
for (ii = 0; line[ii] != '\0'; ii++)
{
if (line[ii] == '"')
@@ -48,7 +55,7 @@ bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings,
{
continue;
}
- if (line[ii] == '#' && !in_quote && key == "")
+ if (line[ii] == '#' && !in_quote && cur == line)
{
break;
}
@@ -56,39 +63,36 @@ bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings,
{
is_value = true;
valid = true;
+ *cur++ = '\0'; /* terminate key */
+ value = cur; /* remember where value starts */
continue;
}
- if (!is_value)
- {
- key += line[ii];
- }
- else
- {
- value += line[ii];
- }
+ *cur++ = line[ii]; /* store next key or value char */
}
+ *cur++ = '\0'; /* terminate value */
/* Skip broken or empty lines. */
if (!valid)
goto free_line;
/* Skip lines with empty key. */
- if (key.length() == 0)
+ if (key[0] == '\0')
goto free_line;
- if (skipKeysWithoutValue && value.length() == 0)
+ if (skipKeysWithoutValue && value[0] == '\0')
goto free_line;
/* Skip lines with unclosed quotes. */
if (in_quote)
goto free_line;
- pSettings[key] = value;
+ g_hash_table_replace(settings, xstrdup(key), xstrdup(value));
free_line:
free(line);
}
if (fp != stdin)
fclose(fp);
+
return true;
}
diff --git a/src/plugins/CCpp.cpp b/src/plugins/CCpp.cpp
index e6807ea7..11968349 100644
--- a/src/plugins/CCpp.cpp
+++ b/src/plugins/CCpp.cpp
@@ -21,7 +21,6 @@
#include <set>
#include "abrtlib.h"
#include "CCpp.h"
-#include "abrt_exception.h"
#include "comm_layer_inner.h"
using namespace std;
diff --git a/src/plugins/KerneloopsScanner.cpp b/src/plugins/KerneloopsScanner.cpp
index 93f37e07..f4a637eb 100644
--- a/src/plugins/KerneloopsScanner.cpp
+++ b/src/plugins/KerneloopsScanner.cpp
@@ -24,7 +24,6 @@
#include <asm/unistd.h> /* __NR_syslog */
#include <glib.h>
#include "abrtlib.h"
-#include "abrt_exception.h"
#include "comm_layer_inner.h"
#include "KerneloopsSysLog.h"
#include "KerneloopsScanner.h"
diff --git a/src/plugins/abrt-action-bugzilla.cpp b/src/plugins/abrt-action-bugzilla.cpp
index b215735b..8486662d 100644
--- a/src/plugins/abrt-action-bugzilla.cpp
+++ b/src/plugins/abrt-action-bugzilla.cpp
@@ -19,7 +19,6 @@
#include "abrtlib.h"
#include "abrt_xmlrpc.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define XML_RPC_SUFFIX "/xmlrpc.cgi"
#define MAX_HOPS 5
@@ -612,15 +611,10 @@ int ctx::get_bug_info(struct bug_info* bz, xmlrpc_int32 bug_id)
void ctx::login(const char* login, const char* passwd)
{
xmlrpc_value* result = call("User.login", "({s:s,s:s})", "login", login, "password", passwd);
-
if (!result)
- {
- char *errmsg = xasprintf("Can't login. Check Edit->Plugins->Bugzilla and /etc/abrt/plugins/Bugzilla.conf. Server said: %s", env.fault_string);
- error_msg("%s", errmsg); // show error in daemon log
- CABRTException e(EXCEP_PLUGIN, errmsg);
- free(errmsg);
- throw e;
- }
+ error_msg_and_die("Can't login. Check Edit->Plugins->Bugzilla "
+ "and /etc/abrt/plugins/Bugzilla.conf. Server said: %s",
+ env.fault_string);
xmlrpc_DECREF(result);
}
@@ -638,13 +632,11 @@ void ctx::logout()
static void report_to_bugzilla(
const char *dump_dir_name,
- /*const*/ map_plugin_settings_t& settings)
+ map_string_h *settings)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
- {
- throw CABRTException(EXCEP_PLUGIN, _("Can't open '%s'"), dump_dir_name);
- }
+ xfunc_die(); /* dd_opendir already emitted error msg */
crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
dd_close(dd);
@@ -656,23 +648,23 @@ static void report_to_bugzilla(
bool ssl_verify;
env = getenv("Bugzilla_Login");
- login = env ? env : settings["Login"].c_str();
+ login = env ? env : get_map_string_item_or_empty(settings, "Login");
env = getenv("Bugzilla_Password");
- password = env ? env : settings["Password"].c_str();
+ password = env ? env : get_map_string_item_or_empty(settings, "Password");
if (!login[0] || !password[0])
{
VERB3 log("Empty login and password");
- throw CABRTException(EXCEP_PLUGIN, _("Empty login or password, please check %s"), PLUGINS_CONF_DIR"/Bugzilla.conf");
+ error_msg_and_die(_("Empty login or password, please check %s"), PLUGINS_CONF_DIR"/Bugzilla.conf");
}
env = getenv("Bugzilla_BugzillaURL");
- bugzilla_url = env ? env : settings["BugzillaURL"].c_str();
+ bugzilla_url = env ? env : get_map_string_item_or_empty(settings, "BugzillaURL");
if (!bugzilla_url[0])
bugzilla_url = "https://bugzilla.redhat.com";
bugzilla_xmlrpc = xasprintf("%s"XML_RPC_SUFFIX, bugzilla_url);
env = getenv("Bugzilla_SSLVerify");
- ssl_verify = string_to_bool(env ? env : settings["SSLVerify"].c_str());
+ ssl_verify = string_to_bool(env ? env : get_map_string_item_or_empty(settings, "SSLVerify"));
const char *component = get_crash_item_content_or_NULL(crash_data, FILENAME_COMPONENT);
const char *duphash = get_crash_item_content_or_NULL(crash_data, FILENAME_DUPHASH);
@@ -704,7 +696,7 @@ static void report_to_bugzilla(
if (!all_bugs)
{
throw_if_xml_fault_occurred(&bz_server.env);
- throw CABRTException(EXCEP_PLUGIN, _("Missing mandatory member 'bugs'"));
+ error_msg_and_die(_("Missing mandatory member 'bugs'"));
}
xmlrpc_int32 bug_id = -1;
@@ -723,7 +715,7 @@ static void report_to_bugzilla(
{
bug_info_destroy(&bz);
throw_if_xml_fault_occurred(&bz_server.env);
- throw CABRTException(EXCEP_PLUGIN, _("get_bug_info() failed. Could not collect all mandatory information"));
+ error_msg_and_die(_("get_bug_info() failed. Could not collect all mandatory information"));
}
if (strcmp(bz.bug_product, product) != 0)
@@ -740,7 +732,7 @@ static void report_to_bugzilla(
if (!all_bugs)
{
throw_if_xml_fault_occurred(&bz_server.env);
- throw CABRTException(EXCEP_PLUGIN, _("Missing mandatory member 'bugs'"));
+ error_msg_and_die(_("Missing mandatory member 'bugs'"));
}
all_bugs_size = bz_server.get_array_size(all_bugs);
@@ -756,7 +748,7 @@ static void report_to_bugzilla(
{
bug_info_destroy(&bz);
throw_if_xml_fault_occurred(&bz_server.env);
- throw CABRTException(EXCEP_PLUGIN, _("get_bug_info() failed. Could not collect all mandatory information"));
+ error_msg_and_die(_("get_bug_info() failed. Could not collect all mandatory information"));
}
}
else
@@ -777,7 +769,7 @@ static void report_to_bugzilla(
if (bug_id < 0)
{
throw_if_xml_fault_occurred(&bz_server.env);
- throw CABRTException(EXCEP_PLUGIN, _("Bugzilla entry creation failed"));
+ error_msg_and_die(_("Bugzilla entry creation failed"));
}
log("Adding attachments to bug %d...", bug_id);
@@ -816,7 +808,7 @@ static void report_to_bugzilla(
{
VERB3 log("Bugzilla could not find a parent of bug %d", (int)original_bug_id);
bug_info_destroy(&bz);
- throw CABRTException(EXCEP_PLUGIN, _("Bugzilla couldn't find parent of bug %d"), (int)original_bug_id);
+ error_msg_and_die(_("Bugzilla couldn't find parent of bug %d"), (int)original_bug_id);
}
log("Bug %d is a duplicate, using parent bug %d", bug_id, (int)bz.bug_dup_id);
@@ -831,7 +823,7 @@ static void report_to_bugzilla(
{
throw_if_xml_fault_occurred(&bz_server.env);
}
- throw CABRTException(EXCEP_PLUGIN, _("get_bug_info() failed. Could not collect all mandatory information"));
+ error_msg_and_die(_("get_bug_info() failed. Could not collect all mandatory information"));
}
// found a bug which is not CLOSED as DUPLICATE
@@ -905,8 +897,7 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- map_plugin_settings_t settings;
-
+ map_string_h *settings = new_map_string();
const char *dump_dir_name = ".";
enum {
OPT_s = (1 << 0),
@@ -919,7 +910,7 @@ int main(int argc, char **argv)
{
case 'c':
VERB1 log("Loading settings from '%s'", optarg);
- LoadPluginSettings(optarg, settings);
+ load_conf_file(optarg, settings, /*skip key w/o values:*/ true);
VERB3 log("Loaded '%s'", optarg);
break;
case 'd':
@@ -966,14 +957,8 @@ int main(int argc, char **argv)
error_msg_and_die("XML-RPC Fault: %s(%d)", env.fault_string, env.fault_code);
xmlrpc_env_clean(&env);
- try
- {
- report_to_bugzilla(dump_dir_name, settings);
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
- }
+ report_to_bugzilla(dump_dir_name, settings);
+ free_map_string(settings);
return 0;
}
diff --git a/src/plugins/abrt-action-kerneloops.cpp b/src/plugins/abrt-action-kerneloops.cpp
index ac90abd7..f3351ccd 100644
--- a/src/plugins/abrt-action-kerneloops.cpp
+++ b/src/plugins/abrt-action-kerneloops.cpp
@@ -20,7 +20,6 @@
#include <curl/curl.h>
#include "abrtlib.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define PROGNAME "abrt-action-kerneloops"
@@ -85,7 +84,7 @@ static CURLcode http_post_to_kerneloops_site(const char *url, const char *oopsda
static void report_to_kerneloops(
const char *dump_dir_name,
- const map_plugin_settings_t& settings)
+ map_string_h *settings)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
@@ -98,12 +97,8 @@ static void report_to_kerneloops(
if (!backtrace)
error_msg_and_die("Error sending kernel oops due to missing backtrace");
- map_plugin_settings_t::const_iterator end = settings.end();
- map_plugin_settings_t::const_iterator it;
-
const char *env = getenv("KerneloopsReporter_SubmitURL");
- it = settings.find("SubmitURL");
- const char *submitURL = (env ? env : it == end ? "" : it->second.c_str());
+ const char *submitURL = (env ? env : get_map_string_item_or_empty(settings, "SubmitURL"));
if (!submitURL[0])
submitURL = "http://submit.kerneloops.org/submitoops.php";
@@ -129,8 +124,7 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- map_plugin_settings_t settings;
-
+ map_string_h *settings = new_map_string();
const char *dump_dir_name = ".";
enum {
OPT_s = (1 << 0),
@@ -143,7 +137,7 @@ int main(int argc, char **argv)
{
case 'c':
VERB1 log("Loading settings from '%s'", optarg);
- LoadPluginSettings(optarg, settings);
+ load_conf_file(optarg, settings, /*skip key w/o values:*/ true);
VERB3 log("Loaded '%s'", optarg);
break;
case 'd':
@@ -182,14 +176,8 @@ int main(int argc, char **argv)
logmode = LOGMODE_SYSLOG;
}
- try
- {
- report_to_kerneloops(dump_dir_name, settings);
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
- }
+ report_to_kerneloops(dump_dir_name, settings);
+ free_map_string(settings);
return 0;
}
diff --git a/src/plugins/abrt-action-mailx.cpp b/src/plugins/abrt-action-mailx.cpp
index 824791fa..6c53c504 100644
--- a/src/plugins/abrt-action-mailx.cpp
+++ b/src/plugins/abrt-action-mailx.cpp
@@ -22,7 +22,6 @@
#include "abrtlib.h"
#include "parse_options.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define PROGNAME "abrt-action-mailx"
@@ -60,7 +59,7 @@ static char** append_str_to_vector(char **vec, unsigned &size, const char *str)
static void create_and_send_email(
const char *dump_dir_name,
- const map_plugin_settings_t& settings)
+ map_string_h *settings)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
@@ -70,20 +69,14 @@ static void create_and_send_email(
dd_close(dd);
char* env;
- map_plugin_settings_t::const_iterator end = settings.end();
- map_plugin_settings_t::const_iterator it;
env = getenv("Mailx_Subject");
- it = settings.find("Subject");
- const char *subject = xstrdup(env ? env : (it != end ? it->second.c_str() : "[abrt] full crash report"));
+ const char *subject = (env ? env : get_map_string_item_or_NULL(settings, "Subject") ? : "[abrt] full crash report");
env = getenv("Mailx_EmailFrom");
- it = settings.find("EmailFrom");
- const char *email_from = (env ? env : (it != end ? it->second.c_str() : "user@localhost"));
+ const char *email_from = (env ? env : get_map_string_item_or_NULL(settings, "EmailFrom") ? : "user@localhost");
env = getenv("Mailx_EmailTo");
- it = settings.find("EmailTo");
- const char *email_to = (env ? env : (it != end ? it->second.c_str() : "root@localhost"));
+ const char *email_to = (env ? env : get_map_string_item_or_NULL(settings, "EmailTo") ? : "root@localhost");
env = getenv("Mailx_SendBinaryData");
- it = settings.find("SendBinaryData");
- bool send_binary_data = string_to_bool(env ? env : (it != end ? it->second.c_str() : "0"));
+ bool send_binary_data = string_to_bool(env ? env : get_map_string_item_or_empty(settings, "SendBinaryData"));
char **args = NULL;
unsigned arg_size = 0;
@@ -166,18 +159,12 @@ int main(int argc, char **argv)
// logmode = LOGMODE_SYSLOG;
//}
- map_plugin_settings_t settings;
+ map_string_h *settings = new_map_string();
if (conf_file)
- LoadPluginSettings(conf_file, settings);
+ load_conf_file(conf_file, settings, /*skip key w/o values:*/ true);
- try
- {
- create_and_send_email(dump_dir_name, settings);
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
- }
+ create_and_send_email(dump_dir_name, settings);
+ free_map_string(settings);
return 0;
}
diff --git a/src/plugins/abrt-action-print.cpp b/src/plugins/abrt-action-print.cpp
index 04d01de3..55631c96 100644
--- a/src/plugins/abrt-action-print.cpp
+++ b/src/plugins/abrt-action-print.cpp
@@ -21,7 +21,6 @@
#include "abrtlib.h"
#include "parse_options.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define PROGNAME "abrt-action-print"
@@ -75,25 +74,17 @@ int main(int argc, char **argv)
}
}
- try
- {
- struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- return 1; /* error message is already logged */
+ struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
+ if (!dd)
+ return 1; /* error message is already logged */
- crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
- dd_close(dd);
+ crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
+ dd_close(dd);
- char *dsc = make_description_logger(crash_data);
- fputs(dsc, stdout);
- free(dsc);
- free_crash_data(crash_data);
- }
- catch (CABRTException& e)
- {
- log("%s", e.what());
- return 1;
- }
+ char *dsc = make_description_logger(crash_data);
+ fputs(dsc, stdout);
+ free(dsc);
+ free_crash_data(crash_data);
if (output_file)
{
diff --git a/src/plugins/abrt-action-rhtsupport.cpp b/src/plugins/abrt-action-rhtsupport.cpp
index 994c84f3..024b1efc 100644
--- a/src/plugins/abrt-action-rhtsupport.cpp
+++ b/src/plugins/abrt-action-rhtsupport.cpp
@@ -23,13 +23,12 @@
#include "abrt_xmlrpc.h"
#include "abrt_rh_support.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define PROGNAME "abrt-action-rhtsupport"
static void report_to_rhtsupport(
const char *dump_dir_name,
- const map_plugin_settings_t& settings)
+ map_string_h *settings)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
@@ -53,24 +52,17 @@ static void report_to_rhtsupport(
const char* package;
char* env;
- map_plugin_settings_t::const_iterator end = settings.end();
- map_plugin_settings_t::const_iterator it;
-
env = getenv("RHTSupport_URL");
- it = settings.find("URL");
- char *url = xstrdup(env ? env : it == end ? "https://api.access.redhat.com/rs" : it->second.c_str());
+ char *url = xstrdup(env ? env : (get_map_string_item_or_NULL(settings, "URL") ? : "https://api.access.redhat.com/rs"));
env = getenv("RHTSupport_Login");
- it = settings.find("Login");
- char *login = xstrdup(env ? env : it == end ? "" : it->second.c_str());
+ char *login = xstrdup(env ? env : get_map_string_item_or_empty(settings, "Login"));
env = getenv("RHTSupport_Password");
- it = settings.find("Password");
- char *password = xstrdup(env ? env : it == end ? "" : it->second.c_str());
+ char *password = xstrdup(env ? env : get_map_string_item_or_empty(settings, "Password"));
env = getenv("RHTSupport_SSLVerify");
- it = settings.find("SSLVerify");
- bool ssl_verify = string_to_bool(env ? env : it == end ? "1" : it->second.c_str());
+ bool ssl_verify = string_to_bool(env ? env : get_map_string_item_or_empty(settings, "SSLVerify"));
if (!login[0] || !password[0])
{
@@ -262,8 +254,7 @@ int main(int argc, char **argv)
if (env_verbose)
g_verbose = atoi(env_verbose);
- map_plugin_settings_t settings;
-
+ map_string_h *settings = new_map_string();
const char *dump_dir_name = ".";
enum {
OPT_s = (1 << 0),
@@ -276,7 +267,7 @@ int main(int argc, char **argv)
{
case 'c':
VERB1 log("Loading settings from '%s'", optarg);
- LoadPluginSettings(optarg, settings);
+ load_conf_file(optarg, settings, /*skip key w/o values:*/ true);
VERB3 log("Loaded '%s'", optarg);
break;
case 'd':
@@ -323,14 +314,8 @@ int main(int argc, char **argv)
error_msg_and_die("XML-RPC Fault: %s(%d)", env.fault_string, env.fault_code);
xmlrpc_env_clean(&env);
- try
- {
- report_to_rhtsupport(dump_dir_name, settings);
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
- }
+ report_to_rhtsupport(dump_dir_name, settings);
+ free_map_string(settings);
return 0;
}
diff --git a/src/plugins/abrt-action-upload.cpp b/src/plugins/abrt-action-upload.cpp
index 9741f543..8789f0e7 100644
--- a/src/plugins/abrt-action-upload.cpp
+++ b/src/plugins/abrt-action-upload.cpp
@@ -22,7 +22,6 @@
#include "abrtlib.h"
#include "parse_options.h"
#include "abrt_crash_dump.h"
-#include "abrt_exception.h"
#define PROGNAME "abrt-action-upload"
@@ -104,7 +103,7 @@ static int send_file(const char *url, const char *filename)
static int create_and_upload_archive(
const char *dump_dir_name,
- const map_plugin_settings_t& settings)
+ map_string_h *settings)
{
int result = 0;
@@ -125,12 +124,8 @@ static int create_and_upload_archive(
//ArchiveType = .tar.bz2
//ExcludeFiles = foo,bar*,b*z
char* env;
- map_plugin_settings_t::const_iterator end = settings.end();
- map_plugin_settings_t::const_iterator it;
-
env = getenv("Upload_URL");
- it = settings.find("URL");
- const char *url = (env ? env : (it == end ? NULL : it->second.c_str()));
+ const char *url = (env ? env : get_map_string_item_or_empty(settings, "URL"));
/* Create a child gzip which will compress the data */
/* SELinux guys are not happy with /tmp, using /var/run/abrt */
@@ -279,21 +274,14 @@ int main(int argc, char **argv)
// logmode = LOGMODE_SYSLOG;
//}
- map_plugin_settings_t settings;
+ map_string_h *settings = new_map_string();
if (url)
- settings["URL"] = url;
+ g_hash_table_replace(settings, xstrdup("URL"), xstrdup(url));
if (conf_file)
- LoadPluginSettings(conf_file, settings);
+ load_conf_file(conf_file, settings, /*skip key w/o values:*/ true);
- int result = 0;
- try
- {
- result = create_and_upload_archive(dump_dir_name, settings);
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
- }
+ int result = create_and_upload_archive(dump_dir_name, settings);
+ free_map_string(settings);
return result;
}