diff options
| author | Karel Klic <kklic@redhat.com> | 2010-03-18 11:18:19 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2010-03-18 11:18:19 +0100 |
| commit | e2d79ab74c2bfa798a3ec9772eb57bc4bcc7a7b8 (patch) | |
| tree | 05e4aeede1499a548d02304f1d68276e21630612 /src/Daemon | |
| parent | f916f9dc8938cd59fa8a119f245e6e61d1adf496 (diff) | |
| download | abrt-e2d79ab74c2bfa798a3ec9772eb57bc4bcc7a7b8.tar.gz abrt-e2d79ab74c2bfa798a3ec9772eb57bc4bcc7a7b8.tar.xz abrt-e2d79ab74c2bfa798a3ec9772eb57bc4bcc7a7b8.zip | |
Allow user to select which reporter he wants to use to report a crash using CLI.
The daemon skips reporters which are not in the list of reporters provided via Report() dbus call.
Reviewed by: Jiri Moskovcak <jmoskovc@redhat.com>
Reviewed by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon')
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 6 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.cpp | 43 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.h | 18 |
3 files changed, 29 insertions, 38 deletions
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index 103f867..d45209a 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -247,7 +247,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) return 0; } - /* Second parameter: reporters to use */ + /* Second parameter: list of reporters to use */ vector_string_t reporters; r = load_val(&in_iter, reporters); if (r == ABRT_DBUS_ERROR) @@ -256,7 +256,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) return -1; } - /* Third parameter is optional */ + /* Third parameter (optional): configuration data for plugins */ map_map_string_t user_conf_data; if (r == ABRT_DBUS_MORE_FIELDS) { @@ -294,7 +294,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) report_status_t argout1; try { - argout1 = Report(argin1, user_conf_data, unix_uid); + argout1 = Report(argin1, reporters, user_conf_data, unix_uid); } catch (CABRTException &e) { diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 3ab3ddd..7792f5b 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -27,6 +27,7 @@ #include "ABRTException.h" #include "CommLayerInner.h" #include "MiddleWare.h" +#include <algorithm> using namespace std; @@ -377,10 +378,11 @@ void RunActionsAndReporters(const char *pDebugDumpDir) } -// We must not trust client_report here! +// Do not trust client_report here! // dbus handler passes it from user without checking report_status_t Report(const map_crash_data_t& client_report, - map_map_string_t& pSettings, + const vector_string_t &reporters, + map_map_string_t& settings, long caller_uid) { // Get ID fields @@ -498,39 +500,20 @@ report_status_t Report(const map_crash_data_t& client_report, for (; it_r != keyPtr->second.end(); it_r++) { const char *plugin_name = it_r->first.c_str(); + + /* Check if the reporter is in the input list of allowed reporters. */ + if (reporters.end() == std::find(reporters.begin(), reporters.end(), plugin_name)) + { + continue; + } + try { if (g_pPluginManager->GetPluginType(plugin_name) == REPORTER) { CReporter* reporter = g_pPluginManager->GetReporter(plugin_name); /* can't be NULL */ -#if 0 /* Using ~user/.abrt/ is bad wrt security */ - std::string home; - map_plugin_settings_t oldSettings; - map_plugin_settings_t newSettings; - - if (pUID != "") - { - home = get_home_dir(xatoi_u(pUID.c_str())); - if (home != "") - { - oldSettings = reporter->GetSettings(); - - if (LoadPluginSettings(home + "/.abrt/" + plugin_name + "."PLUGINS_CONF_EXTENSION, newSettings)) - { - reporter->SetSettings(newSettings); - } - } - } -#endif - map_plugin_settings_t plugin_settings = pSettings[plugin_name]; + map_plugin_settings_t plugin_settings = settings[plugin_name]; std::string res = reporter->Report(stored_report, plugin_settings, it_r->second.c_str()); - -#if 0 /* Using ~user/.abrt/ is bad wrt security */ - if (home != "") - { - reporter->SetSettings(oldSettings); - } -#endif ret[plugin_name].push_back("1"); // REPORT_STATUS_IDX_FLAG ret[plugin_name].push_back(res); // REPORT_STATUS_IDX_MSG if (message != "") @@ -589,7 +572,7 @@ static bool IsDebugDumpSaved(long uid, vector_database_rows_t rows = database->GetUIDData(uid); database->DisConnect(); - int ii; + size_t ii; bool found = false; for (ii = 0; ii < rows.size(); ii++) { diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h index 275d531..4a2903c 100644 --- a/src/Daemon/MiddleWare.h +++ b/src/Daemon/MiddleWare.h @@ -87,12 +87,20 @@ void RunActionsAndReporters(const char *pDebugDumpDir); * fails, then default config is used. If pUID is emply string, default * config is used. * ...). - * @param pCrashData A crash report. - * @param pUID An user uid - * @return A report status, which reporters ends successfuly with messages. + * @param crash_data + * A crash report. + * @param reporters + * List of allowed reporters. Which reporters will be used depends + * on the analyzer of the crash_data. Reporters missing from this list + * will not be used. + * @param caller_uid + * An user uid. + * @return + * A report status, which reporters ends successfuly with messages. */ -report_status_t Report(const map_crash_data_t& pCrashData, - map_map_string_t& pSettings, +report_status_t Report(const map_crash_data_t& crash_data, + const vector_string_t& reporters, + map_map_string_t& settings, long caller_uid); /** * Adds package name and description to debugdump dir. |
