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 | |
| parent | 8569385a9a7f679e32febafda8e8bdcfdf0fa64a (diff) | |
| parent | 2ce0dac4d05ce449f4d054c4725a852a43aab428 (diff) | |
Merge branch 'master' into rhel6
Diffstat (limited to 'src')
29 files changed, 397 insertions, 83 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp index c29a164..9398e4b 100644 --- a/src/Applet/Applet.cpp +++ b/src/Applet/Applet.cpp @@ -15,22 +15,21 @@ 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 <dbus/dbus-shared.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> #if HAVE_CONFIG_H - #include <config.h> +# include <config.h> #endif #if HAVE_LOCALE_H - #include <locale.h> +# include <locale.h> #endif #if ENABLE_NLS - #include <libintl.h> - #define _(S) gettext(S) +# include <libintl.h> +# define _(S) gettext(S) #else - #define _(S) (S) +# define _(S) (S) #endif #include "abrtlib.h" #include "abrt_dbus.h" diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index 9817f41..13a6eb6 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -15,16 +15,15 @@ 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. - */ - +*/ #if HAVE_CONFIG_H - #include <config.h> +# include <config.h> #endif #if ENABLE_NLS - #include <libintl.h> - #define _(S) gettext(S) +# include <libintl.h> +# define _(S) gettext(S) #else - #define _(S) (S) +# define _(S) (S) #endif #include "abrtlib.h" #include "CCApplet.h" diff --git a/src/Applet/CCApplet.h b/src/Applet/CCApplet.h index 48dbabc..a14498e 100644 --- a/src/Applet/CCApplet.h +++ b/src/Applet/CCApplet.h @@ -15,8 +15,7 @@ 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 CC_APPLET_H_ #define CC_APPLET_H_ diff --git a/src/Backtrace/abrt-bz-dupchecker b/src/Backtrace/abrt-bz-dupchecker index d7748c7..cbdafc5 100755 --- a/src/Backtrace/abrt-bz-dupchecker +++ b/src/Backtrace/abrt-bz-dupchecker @@ -24,6 +24,7 @@ from optparse import OptionParser import sys import os.path import subprocess +import cPickle parser = OptionParser(version="%prog 1.0") parser.add_option("-u", "--user", dest="user", @@ -34,6 +35,8 @@ parser.add_option("-b", "--bugzilla", dest="bugzilla", help="Bugzilla URL (defaults to Red Hat Bugzilla)", metavar="URL") parser.add_option("-v", "--verbose", dest="verbose", help="Detailed output") +parser.add_option("-i", "--wiki", help="Generate output in wiki syntax", + action="store_true", default=False, dest="wiki") (options, args) = parser.parse_args() @@ -54,9 +57,38 @@ buginfos = bz.query({'status_whiteboard_type':'allwordssubstr','status_whiteboar print "{0} bugs found.".format(len(buginfos)) +# +# Load cache from previous run. Speeds up the case Bugzilla closes connection. +# The cache should be manually removed after a day or so, because the data in it +# are no longer valid. +# database = {} - +ids = {} +CACHE_FILE = "abrt-bz-dupchecker-cache.tmp" +if os.path.isfile(CACHE_FILE): + f = open(CACHE_FILE, 'r') + database = cPickle.load(f) + ids = cPickle.load(f) + f.close() + +def save_to_cache(): + global database + f = open(CACHE_FILE, 'w') + cPickle.dump(database, f, 2) + cPickle.dump(ids, f, 2) + f.close() + +count = 0 for buginfo in buginfos: + count += 1 + print "{0}/{1}".format(count, len(buginfos)) + if count % 100 == 0: + save_to_cache() + + if ids.has_key(buginfo.bug_id): + continue + ids[buginfo.bug_id] = True + if not buginfo.bug_status in ["NEW", "ASSIGNED", "MODIFIED", "VERIFIED"]: if options.verbose: print "Bug {0} has status {1}, skipping.".format(buginfo.bug_id, buginfo.bug_status) @@ -127,18 +159,38 @@ print "========================================================================= # The number of duplicates. dupcount = 0 +# The number of duplicates that can be closed. +dupclosecount = 0 for backtrace, components in database.items(): for component, bugitems in components.items(): - if len(bugitems) > 1: - dupcount += len(value) - 1 - + dupcount += len(bugitems) - 1 + dupclosecount += min(len(filter(lambda x: x <= 2, + map(lambda x: x["comments"], + bugitems))), + len(bugitems) - 1) + print "Total number of duplicate bugs detected: {0}".format(dupcount) +print "Number of duplicate bugs that will be closed : {0}".format(dupclosecount) print "------------------------------" # Print the duplicates for backtrace, components in database.items(): for component, bugitems in components.items(): if len(bugitems) > 1: - print "Component: {0}".format(component) - print "Duplicates: {0}".format(map(lambda x: "{0} ({1})".format(x['id'],x['comments']), bugitems).join(", ")) - print "Backtrace: {0}".format(backtrace) + if options.wiki: + print "----" + print "* component: '''{0}'''".format(component) + print "* duplicates: {0}".format( + reduce(lambda x,y: x+", "+y, + map(lambda x: "#[https://bugzilla.redhat.com/show_bug.cgi?id={0} {0}] ({1} comments)".format(x['id'],x['comments']), + bugitems))) + print "* backtrace:" + for line in backtrace.replace("Thread\n", "").splitlines(): + print "*# {0}".format(line) + else: + print "Component: {0}".format(component) + print "Duplicates: {0}".format( + reduce(lambda x,y: x+", "+y, + map(lambda x: "{0} ({1})".format(x['id'],x['comments']), + bugitems))) + print "Backtrace: {0}".format(backtrace) diff --git a/src/Backtrace/abrt-bz-hashchecker b/src/Backtrace/abrt-bz-hashchecker index 9c4a5ff..ec7ce1a 100755 --- a/src/Backtrace/abrt-bz-hashchecker +++ b/src/Backtrace/abrt-bz-hashchecker @@ -56,4 +56,4 @@ bz.logout() for hash, ids in hashes.items(): if len(ids) > 1: - print "Duplicates found: ", ids.join(", ") + print "Duplicates found: ", reduce(lambda x,y: str(x)+", "+str(y), ids) 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()) { diff --git a/src/Daemon/CommLayerServer.cpp b/src/Daemon/CommLayerServer.cpp index d61da39..5e25012 100644 --- a/src/Daemon/CommLayerServer.cpp +++ b/src/Daemon/CommLayerServer.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 "CommLayerServer.h" #include "CrashWatcher.h" diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 367c095..bb33a1e 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -1,7 +1,24 @@ +/* + 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 COMMLAYERSERVER_H_ #define COMMLAYERSERVER_H_ -#include <string> #include "abrtlib.h" #include "CrashTypes.h" diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index f247158..6dfc48b 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.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 <dbus/dbus.h> #include "abrtlib.h" #include "abrt_dbus.h" diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index 9bd7766..4fecf1b 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.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 COMMLAYERSERVERDBUS_H_ #define COMMLAYERSERVERDBUS_H_ diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index ab880fb..1e8bf6e 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.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 <sys/socket.h> #include <sys/un.h> #include "abrtlib.h" diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h index c511954..40f6f89 100644 --- a/src/Daemon/CommLayerServerSocket.h +++ b/src/Daemon/CommLayerServerSocket.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. +*/ #include "CommLayerServer.h" #include "DBusCommon.h" #include <glib.h> diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 93365f3..4d68a81 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -15,8 +15,7 @@ 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 "abrtlib.h" #include "Daemon.h" #include "ABRTException.h" diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index 31b72e0..eaf2499 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -15,8 +15,7 @@ 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 CRASHWATCHER_H_ #define CRASHWATCHER_H_ diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 9921423..704d2c3 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -15,8 +15,7 @@ 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 <syslog.h> #include <pthread.h> #include <resolv.h> /* res_init */ diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h index ac998b9..67a97ca 100644 --- a/src/Daemon/Daemon.h +++ b/src/Daemon/Daemon.h @@ -15,8 +15,7 @@ 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 DAEMON_H_ #define DAEMON_H_ diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index ebd5c0f..e0687fd 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -17,8 +17,7 @@ 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 "abrtlib.h" #include "abrt_types.h" #include "Daemon.h" diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h index aa37e3e..94f9fb9 100644 --- a/src/Daemon/MiddleWare.h +++ b/src/Daemon/MiddleWare.h @@ -18,8 +18,7 @@ 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 MIDDLEWARE_H_ #define MIDDLEWARE_H_ diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 5166c6a..e63cb3a 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -17,10 +17,7 @@ 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 <fstream> -#include <iostream> +*/ #include <dlfcn.h> #include "abrtlib.h" #include "ABRTException.h" @@ -85,23 +82,21 @@ static const char *const plugin_type_str[] = { bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings) { - ifstream fIn; - fIn.open(pPath); - if (!fIn.is_open()) + FILE *fp = fopen(pPath, "r"); + if (!fp) return false; - string line; - while (!fIn.eof()) + char line[512]; + while (fgets(line, sizeof(line), fp)) { - getline(fIn, line); - - int ii; + strchrnul(line, '\n')[0] = '\0'; + unsigned ii; bool is_value = false; bool valid = false; bool in_quote = false; string key; string value; - for (ii = 0; ii < line.length(); ii++) + for (ii = 0; line[ii] != '\0'; ii++) { if (line[ii] == '"') { @@ -135,7 +130,7 @@ bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings) pSettings[key] = value; } } - fIn.close(); + fclose(fp); return true; } diff --git a/src/Daemon/PluginManager.h b/src/Daemon/PluginManager.h index 8eebe7d..b5dcebc 100644 --- a/src/Daemon/PluginManager.h +++ b/src/Daemon/PluginManager.h @@ -18,8 +18,7 @@ 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 PLUGINMANAGER_H_ #define PLUGINMANAGER_H_ diff --git a/src/Daemon/RPM.cpp b/src/Daemon/RPM.cpp index 6cc0ba6..c40f9a0 100644 --- a/src/Daemon/RPM.cpp +++ b/src/Daemon/RPM.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 "abrtlib.h" #include "RPM.h" #include "CommLayerInner.h" diff --git a/src/Daemon/RPM.h b/src/Daemon/RPM.h index fed5e43..4df868d 100644 --- a/src/Daemon/RPM.h +++ b/src/Daemon/RPM.h @@ -18,8 +18,7 @@ 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 RPM_H_ #define RPM_H_ diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index 725c0d2..9b0376b 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -1,4 +1,21 @@ -#include <fstream> +/* + 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 "Settings.h" #include "abrtlib.h" #include "abrt_types.h" @@ -243,46 +260,45 @@ static void ParseAnalyzerActionsAndReporters() static void LoadGPGKeys() { - std::ifstream fIn; - fIn.open(CONF_DIR"/gpg_keys"); - if (fIn.is_open()) + FILE *fp = fopen(CONF_DIR"/gpg_keys", "r"); + if (fp) { - std::string line; /* every line is one key - FIXME: make it more robust, it doesn't handle comments - */ - while (fIn.good()) + * FIXME: make it more robust, it doesn't handle comments + */ + char line[512]; + while (fgets(line, sizeof(line), fp)) { - getline(fIn, line); if (line[0] == '/') // probably the begining of path, so let's handle it as a key + { + strchrnul(line, '\n')[0] = '\0'; g_settings_setOpenGPGPublicKeys.insert(line); + } } - fIn.close(); + fclose(fp); } } /* abrt daemon loads .conf file */ void LoadSettings() { - std::ifstream fIn; - fIn.open(CONF_DIR"/abrt.conf"); - if (fIn.is_open()) + FILE *fp = fopen(CONF_DIR"/abrt.conf", "r"); + if (fp) { - std::string line; + char line[512]; std::string section; - while (fIn.good()) + while (fgets(line, sizeof(line), fp)) { - getline(fIn, line); - - unsigned int ii; + strchrnul(line, '\n')[0] = '\0'; + unsigned ii; bool is_key = true; bool is_section = false; bool is_quote = false; std::string key; std::string value; - for (ii = 0; ii < line.length(); ii++) + for (ii = 0; line[ii] != '\0'; ii++) { - if (is_quote && line[ii] == '\\' && ii+1 < line.length()) + if (is_quote && line[ii] == '\\' && line[ii+1] != '\0') { value += line[ii]; ii++; @@ -355,7 +371,7 @@ void LoadSettings() } } } - fIn.close(); + fclose(fp); } ParseCommon(); ParseAnalyzerActionsAndReporters(); diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h index 3fdb8b9..cd3179d 100644 --- a/src/Daemon/Settings.h +++ b/src/Daemon/Settings.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 SETTINGS_H_ #define SETTINGS_H_ diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf index 6a3da4d..8ed5179 100644 --- a/src/Daemon/abrt.conf +++ b/src/Daemon/abrt.conf @@ -5,7 +5,7 @@ # in the file gpg_keys OpenGPGCheck = yes # Blacklisted packages -BlackList = nspluginwrapper, valgrind, strace +BlackList = nspluginwrapper, valgrind, strace, avant-window-navigator # Which database plugin to use Database = SQLite3 # Max size for crash storage [MiB] |
