diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-07 23:11:00 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-07 23:11:00 +0100 |
| commit | 4169595397ba962f230033b921964cae1629736d (patch) | |
| tree | 94e0a25a1c6b32e8b2d475ba3ab02d7ba7eaf075 /src/CLI | |
| parent | 8569385a9a7f679e32febafda8e8bdcfdf0fa64a (diff) | |
| parent | 2ce0dac4d05ce449f4d054c4725a852a43aab428 (diff) | |
Merge branch 'master' into rhel6
Diffstat (limited to 'src/CLI')
| -rw-r--r-- | src/CLI/ABRTSocket.cpp | 18 | ||||
| -rw-r--r-- | src/CLI/ABRTSocket.h | 18 | ||||
| -rw-r--r-- | src/CLI/dbus.cpp | 28 | ||||
| -rw-r--r-- | src/CLI/dbus.h | 14 | ||||
| -rw-r--r-- | src/CLI/report.cpp | 55 |
5 files changed, 126 insertions, 7 deletions
diff --git a/src/CLI/ABRTSocket.cpp b/src/CLI/ABRTSocket.cpp index 82c304e..61618c0 100644 --- a/src/CLI/ABRTSocket.cpp +++ b/src/CLI/ABRTSocket.cpp @@ -1,3 +1,21 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ #include "ABRTSocket.h" #include "ABRTException.h" #include "CrashTypesSocket.h" diff --git a/src/CLI/ABRTSocket.h b/src/CLI/ABRTSocket.h index d4905be..f8fb42b 100644 --- a/src/CLI/ABRTSocket.h +++ b/src/CLI/ABRTSocket.h @@ -1,3 +1,21 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ #ifndef ABRTSOCKET_H_ #define ABRTSOCKET_H_ diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp index ffd1157..db45cd8 100644 --- a/src/CLI/dbus.cpp +++ b/src/CLI/dbus.cpp @@ -142,12 +142,15 @@ map_crash_data_t call_CreateReport(const char* uuid) return argout; } -report_status_t call_Report(const map_crash_data_t& report) +report_status_t call_Report(const map_crash_data_t& report, + const map_map_string_t &plugins) { DBusMessage* msg = new_call_msg(__func__ + 5); DBusMessageIter out_iter; dbus_message_iter_init_append(msg, &out_iter); store_val(&out_iter, report); + if (!plugins.empty()) + store_val(&out_iter, plugins); DBusMessage *reply = send_get_reply_and_unref(msg); @@ -184,7 +187,6 @@ int32_t call_DeleteDebugDump(const char* uuid) return result; } -#ifdef UNUSED map_map_string_t call_GetPluginsInfo() { DBusMessage *msg = new_call_msg(__func__ + 5); @@ -201,7 +203,27 @@ map_map_string_t call_GetPluginsInfo() dbus_message_unref(reply); return argout; } -#endif + +map_plugin_settings_t call_GetPluginSettings(const char *name) +{ + DBusMessage *msg = new_call_msg(__func__ + 5); + dbus_message_append_args(msg, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + + DBusMessage *reply = send_get_reply_and_unref(msg); + + DBusMessageIter in_iter; + dbus_message_iter_init(reply, &in_iter); + + map_string_t argout; + int r = load_val(&in_iter, argout); + 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 argout; +} void handle_dbus_err(bool error_flag, DBusError *err) { diff --git a/src/CLI/dbus.h b/src/CLI/dbus.h index c6fd7a4..c6c61eb 100644 --- a/src/CLI/dbus.h +++ b/src/CLI/dbus.h @@ -25,10 +25,19 @@ extern DBusConnection* s_dbus_conn; vector_map_crash_data_t call_GetCrashInfos(); map_crash_data_t call_CreateReport(const char *uuid); -report_status_t call_Report(const map_crash_data_t& report); + +/** Sends report using enabled Reporter plugins. + * @param plugins + * Optional settings for plugins, can be empty. + * Format: plugins["PluginName"]["SettingsKey"] = "SettingsValue" + * If it contains settings for some plugin, it must contain _all fields_ + * obtained by call_GetPluginSettings, otherwise the plugin might ignore + * the settings. + */ +report_status_t call_Report(const map_crash_data_t& report, + const map_map_string_t &plugins); int32_t call_DeleteDebugDump(const char* uuid); -#ifdef UNUSED /* Gets basic data about all installed plugins. */ map_map_string_t call_GetPluginsInfo(); @@ -38,7 +47,6 @@ map_map_string_t call_GetPluginsInfo(); * Corresponds to name obtained from call_GetPluginsInfo. */ map_plugin_settings_t call_GetPluginSettings(const char *name); -#endif void handle_dbus_err(bool error_flag, DBusError *err); diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp index 2bcd52a..7ef33ac 100644 --- a/src/CLI/report.cpp +++ b/src/CLI/report.cpp @@ -412,10 +412,63 @@ int report(const char *uuid, bool always) } } + map_map_string_t pluginSettings; + if (!always) + { + // Get informations about all plugins. + map_map_string_t plugins = call_GetPluginsInfo(); + // Check the configuration of each enabled Reporter plugin. + map_map_string_t::iterator it, itend = plugins.end(); + for (it = plugins.begin(); it != itend; ++it) + { + // Skip disabled plugins. + if (0 != strcmp(it->second["Enabled"].c_str(), "yes")) + continue; + // Skip nonReporter plugins. + if (0 != strcmp(it->second["Type"].c_str(), "Reporter")) + continue; + + map_string_t settings = call_GetPluginSettings(it->first.c_str()); + // Login information is missing. + bool loginMissing = settings.find("Login") != settings.end() + && 0 == strcmp(settings["Login"].c_str(), ""); + bool passwordMissing = settings.find("Password") != settings.end() + && 0 == strcmp(settings["Password"].c_str(), ""); + if (!loginMissing && !passwordMissing) + continue; + + // Copy the received settings as defaults. + // Plugins won't work without it, if some value is missing + // they use their default values for all fields. + pluginSettings[it->first] = settings; + + printf(_("Wrong settings were detected for plugin %s.\n"), it->second["Name"].c_str()); + if (loginMissing) + { + printf(_("Enter your login: ")); + fflush(NULL); + char answer[64] = ""; + fgets(answer, sizeof(answer), stdin); + if (strlen(answer) > 0) + pluginSettings[it->first]["Login"] = answer; + } + if (passwordMissing) + { +// TODO: echo off, see http://fixunix.com/unix/84474-echo-off.html + printf(_("Enter your password: ")); + fflush(NULL); + char answer[64] = ""; + fgets(answer, sizeof(answer), stdin); + if (strlen(answer) > 0) + pluginSettings[it->first]["Password"] = answer; + } + } + } + int errors = 0; int plugins = 0; puts(_("Reporting...")); - report_status_t r = call_Report(cr); + report_status_t r = call_Report(cr, pluginSettings); report_status_t::iterator it = r.begin(); while (it != r.end()) { |
