summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/abrt_types.h3
-rw-r--r--lib/Plugins/Logger.cpp4
-rw-r--r--lib/Utils/logging.cpp1
-rw-r--r--src/CLI/CLI.cpp4
-rw-r--r--src/CLI/dbus.cpp13
-rw-r--r--src/CLI/dbus.h14
-rw-r--r--src/CLI/report.cpp150
-rw-r--r--src/CLI/report.h2
-rw-r--r--src/Daemon/MiddleWare.cpp8
9 files changed, 110 insertions, 89 deletions
diff --git a/inc/abrt_types.h b/inc/abrt_types.h
index 1fbb701a..d096ddd5 100644
--- a/inc/abrt_types.h
+++ b/inc/abrt_types.h
@@ -38,6 +38,9 @@ typedef std::map<std::string, vector_pair_string_string_t> map_vector_pair_strin
/* Report() method return type */
typedef map_vector_string_t report_status_t;
+/* map_vector_string_t's vector element meaning: */
+#define REPORT_STATUS_IDX_FLAG 0
+#define REPORT_STATUS_IDX_MSG 1
/* Holds result of .conf file section parsing: map["name"] = "value" */
typedef map_string_t map_plugin_settings_t;
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
index 35f042c7..a0dea424 100644
--- a/lib/Plugins/Logger.cpp
+++ b/lib/Plugins/Logger.cpp
@@ -63,7 +63,6 @@ std::string CLogger::Report(const map_crash_report_t& pCrashReport,
const map_plugin_settings_t& pSettings,
const char *pArgs)
{
- update_client(_("Creating a report..."));
std::string description = make_description_logger(pCrashReport);
description += "\n\n\n";
@@ -80,12 +79,13 @@ std::string CLogger::Report(const map_crash_report_t& pCrashReport,
if (fOut)
{
+ update_client(_("Writing report to '%s'"), m_sLogPath.c_str());
fputs(description.c_str(), fOut);
fclose(fOut);
return "file://" + m_sLogPath;
}
- throw CABRTException(EXCEP_PLUGIN, "Can't open file '%s'", m_sLogPath.c_str());
+ throw CABRTException(EXCEP_PLUGIN, "Can't open '%s'", m_sLogPath.c_str());
}
PLUGIN_INFO(REPORTER,
diff --git a/lib/Utils/logging.cpp b/lib/Utils/logging.cpp
index db952d17..53b83d72 100644
--- a/lib/Utils/logging.cpp
+++ b/lib/Utils/logging.cpp
@@ -60,6 +60,7 @@ static void verror_msg_helper(const char *s, va_list p, const char* strerr, int
fflush(stdout);
full_write(STDERR_FILENO, msg, used + msgeol_len);
}
+ msg[used] = '\0'; /* remove msg_eol (usually "\n") */
if (flags & LOGMODE_SYSLOG) {
syslog(LOG_ERR, "%s", msg + prefix_len);
}
diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp
index 1f7e5430..1ea3a5d6 100644
--- a/src/CLI/CLI.cpp
+++ b/src/CLI/CLI.cpp
@@ -194,10 +194,10 @@ int main(int argc, char** argv)
break;
}
case OPT_REPORT:
- report(uuid, false);
+ exitcode = report(uuid, false);
break;
case OPT_REPORT_ALWAYS:
- report(uuid, true);
+ exitcode = report(uuid, true);
break;
case OPT_DELETE:
{
diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp
index f25165bb..b2186798 100644
--- a/src/CLI/dbus.cpp
+++ b/src/CLI/dbus.cpp
@@ -142,7 +142,7 @@ map_crash_report_t call_CreateReport(const char* uuid)
return argout;
}
-void call_Report(const map_crash_report_t& report)
+report_status_t call_Report(const map_crash_report_t& report)
{
DBusMessage* msg = new_call_msg(__func__ + 5);
DBusMessageIter out_iter;
@@ -150,10 +150,17 @@ void call_Report(const map_crash_report_t& report)
store_val(&out_iter, report);
DBusMessage *reply = send_get_reply_and_unref(msg);
- //it returns a single value of report_status_t type,
- //but we don't use it (yet?)
+
+ DBusMessageIter in_iter;
+ dbus_message_iter_init(reply, &in_iter);
+
+ report_status_t result;
+ int r = load_val(&in_iter, result);
+ if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */
+ error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5);
dbus_message_unref(reply);
+ return result;
}
int32_t call_DeleteDebugDump(const char* uuid)
diff --git a/src/CLI/dbus.h b/src/CLI/dbus.h
index f39f5381..3c157c01 100644
--- a/src/CLI/dbus.h
+++ b/src/CLI/dbus.h
@@ -23,21 +23,21 @@
extern DBusConnection* s_dbus_conn;
-extern vector_crash_infos_t call_GetCrashInfos();
-extern map_crash_report_t call_CreateReport(const char *uuid);
-extern void call_Report(const map_crash_report_t& report);
-extern int32_t call_DeleteDebugDump(const char* uuid);
+vector_crash_infos_t call_GetCrashInfos();
+map_crash_report_t call_CreateReport(const char *uuid);
+report_status_t call_Report(const map_crash_report_t& report);
+int32_t call_DeleteDebugDump(const char* uuid);
/* Gets basic data about all installed plugins.
*/
-extern vector_map_string_t call_GetPluginsInfo();
+vector_map_string_t call_GetPluginsInfo();
/** Gets default plugin settings.
* @param name
* Corresponds to name obtained from call_GetPluginsInfo.
*/
-extern map_plugin_settings_t call_GetPluginSettings(const char *name);
+map_plugin_settings_t call_GetPluginSettings(const char *name);
-extern void handle_dbus_err(bool error_flag, DBusError *err);
+void handle_dbus_err(bool error_flag, DBusError *err);
#endif
diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp
index ac80e481..bc8f9008 100644
--- a/src/CLI/report.cpp
+++ b/src/CLI/report.cpp
@@ -332,88 +332,98 @@ int report(const char *uuid, bool always)
{
// Ask for an initial report.
map_crash_report_t cr = call_CreateReport(uuid);
+//TODO: error check?
- if (always)
+ if (!always)
{
- // Send the report immediately.
- call_Report(cr);
- return 0;
- }
-
- /* Open a temporary file and write the crash report to it. */
- char filename[] = "/tmp/abrt-report.XXXXXX";
- int fd = mkstemp(filename);
- if (fd == -1)
- {
- error_msg("can't generate temporary file name");
- return 1;
- }
+ /* Open a temporary file and write the crash report to it. */
+ char filename[] = "/tmp/abrt-report.XXXXXX";
+ int fd = mkstemp(filename);
+ if (fd == -1)
+ {
+ error_msg("can't generate temporary file name");
+ return 1;
+ }
- FILE *fp = fdopen(fd, "w");
- if (!fp)
- {
- error_msg("can't open '%s' to save the crash report", filename);
- return 1;
- }
+ FILE *fp = fdopen(fd, "w");
+ if (!fp)
+ {
+ error_msg("can't open '%s' to save the crash report", filename);
+ return 1;
+ }
- write_crash_report(cr, fp);
+ write_crash_report(cr, fp);
- if (fclose(fp))
- {
- error_msg("can't close '%s'", filename);
- return 2;
- }
+ if (fclose(fp))
+ {
+ error_msg("can't close '%s'", filename);
+ return 2;
+ }
- // Start a text editor on the temporary file.
- launch_editor(filename);
+ // Start a text editor on the temporary file.
+ launch_editor(filename);
- // Read the file back and update the report from the file.
- fp = fopen(filename, "r");
- if (!fp)
- {
- error_msg("can't open '%s' to read the crash report", filename);
- return 1;
- }
+ // Read the file back and update the report from the file.
+ fp = fopen(filename, "r");
+ if (!fp)
+ {
+ error_msg("can't open '%s' to read the crash report", filename);
+ return 1;
+ }
- fseek(fp, 0, SEEK_END);
- long size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ fseek(fp, 0, SEEK_END);
+ long size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
- char *text = (char*)xmalloc(size + 1);
- if (fread(text, 1, size, fp) != size)
- {
- error_msg("can't read '%s'", filename);
- return 1;
+ char *text = (char*)xmalloc(size + 1);
+ if (fread(text, 1, size, fp) != size)
+ {
+ error_msg("can't read '%s'", filename);
+ return 1;
+ }
+ text[size] = '\0';
+ fclose(fp);
+
+ remove_comments_and_unescape(text);
+ // Updates the crash report from the file text.
+ int report_changed = read_crash_report(cr, text);
+ if (report_changed)
+ puts(_("\nThe report has been updated."));
+ else
+ puts(_("\nNo changes were detected in the report."));
+
+ free(text);
+
+ if (unlink(filename) != 0) // Delete the tempfile.
+ perror_msg("can't unlink %s", filename);
+
+ // Report only if the user is sure.
+ printf(_("Do you want to send the report? [y/N]: "));
+ fflush(NULL);
+ char answer[16] = "n";
+ fgets(answer, sizeof(answer), stdin);
+ if ((answer[0] | 0x20) != 'y')
+ {
+ puts(_("Crash report was not sent."));
+ return 0;
+ }
}
- text[size] = '\0';
- fclose(fp);
-
- remove_comments_and_unescape(text);
- // Updates the crash report from the file text.
- int report_changed = read_crash_report(cr, text);
- if (report_changed)
- puts(_("\nThe report has been updated."));
- else
- puts(_("\nNo changes were detected in the report."));
- free(text);
-
- if (unlink(filename) != 0) // Delete the tempfile.
- perror_msg("can't unlink %s", filename);
-
- // Report only if the user is sure.
- printf(_("Do you want to send the report? [y/N]: "));
- fflush(NULL);
- char answer[16] = "n";
- fgets(answer, sizeof(answer), stdin);
- if (answer[0] == 'Y' || answer[0] == 'y')
+ int errors = 0;
+ int plugins = 0;
+ puts(_("Reporting..."));
+ report_status_t r = call_Report(cr);
+ report_status_t::iterator it = r.begin();
+ while (it != r.end())
{
- puts(_("Reporting..."));
- call_Report(cr);
- puts(_("Crash report was successfully sent."));
+ vector_string_t &v = it->second;
+ printf("%s: %s\n", it->first.c_str(), v[REPORT_STATUS_IDX_MSG].c_str());
+ plugins++;
+ if (v[REPORT_STATUS_IDX_FLAG] != "0")
+ errors++;
+ it++;
}
- else
- puts(_("Crash report was not sent."));
+ printf(_("Crash reported via %d plugins (%d errors)\n"), plugins, errors);
- return 0;
+ return errors != 0;
}
diff --git a/src/CLI/report.h b/src/CLI/report.h
index 888babf3..2969b650 100644
--- a/src/CLI/report.h
+++ b/src/CLI/report.h
@@ -19,6 +19,6 @@
#define ABRT_CLI_REPORT_H
/* Reports the crash with corresponding uuid over DBus. */
-extern int report(const char *uuid, bool always);
+int report(const char *uuid, bool always);
#endif
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index e483f3fe..c0ffabac 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -498,15 +498,15 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
reporter->SetSettings(oldSettings);
}
#endif
- ret[pluginName].push_back("1");
- ret[pluginName].push_back(res);
+ ret[pluginName].push_back("1"); // REPORT_STATUS_IDX_FLAG
+ ret[pluginName].push_back(res); // REPORT_STATUS_IDX_MSG
message += res + "\n";
}
}
catch (CABRTException& e)
{
- ret[pluginName].push_back("0");
- ret[pluginName].push_back(e.what());
+ ret[pluginName].push_back("0"); // REPORT_STATUS_IDX_FLAG
+ ret[pluginName].push_back(e.what()); // REPORT_STATUS_IDX_MSG
update_client("Reporting via '%s' was not successful: %s", pluginName.c_str(), e.what());
}
}