summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-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
8 files changed, 61 insertions, 139 deletions
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;
}