diff options
| author | Karel Klic <kklic@redhat.com> | 2010-03-18 11:37:36 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2010-03-18 11:37:36 +0100 |
| commit | ec0ffd2b421898b4165cb98ab92da50fc935107e (patch) | |
| tree | 59294771c5253751843dee89d81df438ddb6475f /lib | |
| parent | 7bc2585fe81ce94d05a3b7c8045c0177a6fc70cc (diff) | |
| parent | af63575dae4d2705b13966b1583230567b46538c (diff) | |
| download | abrt-ec0ffd2b421898b4165cb98ab92da50fc935107e.tar.gz abrt-ec0ffd2b421898b4165cb98ab92da50fc935107e.tar.xz abrt-ec0ffd2b421898b4165cb98ab92da50fc935107e.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Plugins/Bugzilla.cpp | 189 | ||||
| -rw-r--r-- | lib/Plugins/Bugzilla.h | 3 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 18 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsScanner.h | 2 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsSysLog.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/Makefile.am | 4 |
6 files changed, 112 insertions, 106 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 2979332..e59e9a7 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -106,7 +106,7 @@ struct ctx: public abrt_xmlrpc_conn { const char* get_bug_resolution(xmlrpc_value* result_xml); const char* get_bug_reporter(xmlrpc_value* result_xml); - xmlrpc_value* call_quicksearch_uuid(const char* component, const char* uuid); + xmlrpc_value* call_quicksearch_duphash(const char* component, const char* duphash); xmlrpc_value* get_cc_member(xmlrpc_value* result_xml); xmlrpc_value* get_member(const char* member, xmlrpc_value* result_xml); @@ -298,9 +298,9 @@ void ctx::get_bug_cc(xmlrpc_value* result_xml, struct bug_info* bz) return; } -xmlrpc_value* ctx::call_quicksearch_uuid(const char* component, const char* uuid) +xmlrpc_value* ctx::call_quicksearch_duphash(const char* component, const char* duphash) { - std::string query = ssprintf("ALL component:\"%s\" statuswhiteboard:\"%s\"", component, uuid); + std::string query = ssprintf("ALL component:\"%s\" statuswhiteboard:\"%s\"", component, duphash); return call("Bug.search", "({s:s})", "quicksearch", query.c_str()); } @@ -350,7 +350,7 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t& pCrashData) const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); const std::string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); const std::string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); + const std::string& duphash = get_crash_data_item_content(pCrashData, CD_DUPHASH); const char *reason = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_REASON); std::string summary = "[abrt] crash in " + package; @@ -359,7 +359,7 @@ xmlrpc_int32 ctx::new_bug(const map_crash_data_t& pCrashData) summary += ": "; summary += reason; } - std::string status_whiteboard = "abrt_hash:" + uuid; + std::string status_whiteboard = "abrt_hash:" + duphash; std::string description = "abrt "VERSION" detected a crash.\n\n"; description += make_description_bz(pCrashData); @@ -455,7 +455,7 @@ int ctx::get_bug_info(struct bug_info* bz, xmlrpc_int32 bug_id) // mandatory when bug status is CLOSED and resolution is DUPLICATE if ((strcmp(bz->bug_status, "CLOSED") == 0) && (strcmp(bz->bug_resolution, "DUPLICATE") == 0) - ) { + ) { bz->bug_dup_id = get_bug_dup_id(result); if (env.fault_occurred) return -1; @@ -508,6 +508,61 @@ void ctx::logout() * CReporterBugzilla */ +static map_plugin_settings_t parse_settings(const map_plugin_settings_t& pSettings) +{ + map_plugin_settings_t plugin_settings; + + map_plugin_settings_t::const_iterator end = pSettings.end(); + map_plugin_settings_t::const_iterator it; + it = pSettings.find("BugzillaURL"); + if (it != end) + { + std::string BugzillaURL = it->second; + //remove the /xmlrpc.cgi part from old settings + //FIXME: can be removed after users are informed about new config format + std::string::size_type pos = BugzillaURL.find(XML_RPC_SUFFIX); + if (pos != std::string::npos) + { + BugzillaURL.erase(pos); + } + //remove the trailing '/' + while (BugzillaURL[BugzillaURL.length() - 1] == '/') + { + BugzillaURL.erase(BugzillaURL.length() - 1); + } + plugin_settings["BugzillaXMLRPC"] = BugzillaURL + XML_RPC_SUFFIX; + plugin_settings["BugzillaURL"] = BugzillaURL; + } + + it = pSettings.find("Login"); + if (it == end) + { + /* if any of the option is not set we use the defaults for everything */ + plugin_settings.clear(); + return plugin_settings; + } + plugin_settings["Login"] = it->second; + + it = pSettings.find("Password"); + if (it == end) + { + plugin_settings.clear(); + return plugin_settings; + } + plugin_settings["Password"] = it->second; + + it = pSettings.find("NoSSLVerify"); + if (it == end) + { + plugin_settings.clear(); + return plugin_settings; + } + plugin_settings["NoSSLVerify"] = it->second; + + VERB1 log("User settings ok, using them instead of defaults"); + return plugin_settings; +} + CReporterBugzilla::CReporterBugzilla() : m_bNoSSLVerify(false), m_sBugzillaURL("https://bugzilla.redhat.com"), @@ -546,7 +601,6 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, NoSSLVerify = m_bNoSSLVerify; } - update_client(_("Logging into bugzilla...")); if ((Login == "") && (Password == "")) { VERB3 log("Empty login and password"); @@ -554,14 +608,15 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, } const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); + const std::string& duphash = get_crash_data_item_content(pCrashData, CD_DUPHASH); ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); + update_client(_("Logging into bugzilla...")); bz_server.login(Login.c_str(), Password.c_str()); update_client(_("Checking for duplicates...")); - xmlrpc_value* result = bz_server.call_quicksearch_uuid(component.c_str(), uuid.c_str()); + xmlrpc_value* result = bz_server.call_quicksearch_duphash(component.c_str(), duphash.c_str()); if (!result) { throw_if_xml_fault_occurred(&bz_server.env); @@ -577,7 +632,7 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, } int all_bugs_size = bz_server.get_array_size(all_bugs); - if (all_bugs_size == -1) + if (all_bugs_size < 0) { throw_if_xml_fault_occurred(&bz_server.env); } @@ -599,17 +654,19 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, update_client(_("Logging out...")); bz_server.logout(); - std::string bug_status = "Status: NEW\n"; - BugzillaURL = bug_status + BugzillaURL; - BugzillaURL += "/show_bug.cgi?id="; - BugzillaURL += to_string(bug_id); - return BugzillaURL; + std::string bug_status = ssprintf( + "Status: NEW\n" + "%s/show_bug.cgi?id=%u", + BugzillaURL.c_str(), + (int)bug_id + ); + return bug_status; } else if (all_bugs_size > 1) { - // When someone clones bug it has same uuid, so we can find more than 1. + // When someone clones bug it has same duphash, so we can find more than 1. // Need to be checked if component is same. - VERB3 log("Bugzilla has %i same uuids(%s)", all_bugs_size, uuid.c_str()); + VERB3 log("Bugzilla has %u reports with same duphash '%s'", all_bugs_size, duphash.c_str()); } // decision based on state @@ -682,15 +739,15 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, std::string description = make_description_reproduce_comment(pCrashData); if (!description.empty()) { - const char* package = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_PACKAGE); - const char* release = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_RELEASE); - const char* arch = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_ARCHITECTURE); + const char* package = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_PACKAGE); + const char* release = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_RELEASE); + const char* arch = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_ARCHITECTURE); - description = ssprintf( "Package: %s\n" - "Architecture: %s\n" - "OS Release: %s\n" - "%s", package, arch, release, description.c_str() - ); + description = ssprintf("Package: %s\n" + "Architecture: %s\n" + "OS Release: %s\n" + "%s", package, arch, release, description.c_str() + ); update_client(_("Add new comment into bug(%d)"), (int)bug_id); if (bz_server.add_comment(bug_id, description.c_str()) == -1) @@ -704,81 +761,19 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, update_client(_("Logging out...")); bz_server.logout(); - std::string bug_status; - - std::string status = bz.bug_status; - if (bz.bug_resolution) - { - std::string resolution = bz.bug_resolution; - bug_status = "Status: " + status + " " + resolution + "\n"; - } - else - { - bug_status = "Status: " + status + "\n"; - } + std::string bug_status = ssprintf( + "Status: %s%s%s\n" + "%s/show_bug.cgi?id=%u", + bz.bug_status, + bz.bug_resolution ? " " : "", + bz.bug_resolution ? bz.bug_resolution : "", + BugzillaURL.c_str(), + (int)bug_id + ); bug_info_destroy(&bz); - BugzillaURL = bug_status + BugzillaURL; - BugzillaURL += "/show_bug.cgi?id="; - BugzillaURL += to_string(bug_id); - return BugzillaURL; -} - -//todo: make static -map_plugin_settings_t CReporterBugzilla::parse_settings(const map_plugin_settings_t& pSettings) -{ - map_plugin_settings_t plugin_settings; - - map_plugin_settings_t::const_iterator end = pSettings.end(); - map_plugin_settings_t::const_iterator it; - it = pSettings.find("BugzillaURL"); - if (it != end) - { - std::string BugzillaURL = it->second; - //remove the /xmlrpc.cgi part from old settings - //FIXME: can be removed after users are informed about new config format - std::string::size_type pos = BugzillaURL.find(XML_RPC_SUFFIX); - if (pos != std::string::npos) - { - BugzillaURL.erase(pos); - } - //remove the trailing '/' - while (BugzillaURL[BugzillaURL.length() - 1] == '/') - { - BugzillaURL.erase(BugzillaURL.length() - 1); - } - plugin_settings["BugzillaXMLRPC"] = BugzillaURL + XML_RPC_SUFFIX; - plugin_settings["BugzillaURL"] = BugzillaURL; - } - - it = pSettings.find("Login"); - if (it == end) - { - /* if any of the option is not set we use the defaults for everything */ - plugin_settings.clear(); - return plugin_settings; - } - plugin_settings["Login"] = it->second; - - it = pSettings.find("Password"); - if (it == end) - { - plugin_settings.clear(); - return plugin_settings; - } - plugin_settings["Password"] = it->second; - - it = pSettings.find("NoSSLVerify"); - if (it == end) - { - plugin_settings.clear(); - return plugin_settings; - } - plugin_settings["NoSSLVerify"] = it->second; - - VERB1 log("User settings ok, using them instead of defaults"); - return plugin_settings; + return bug_status; } void CReporterBugzilla::SetSettings(const map_plugin_settings_t& pSettings) diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index 7ee7b01..cad00ef 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -30,9 +30,6 @@ class CReporterBugzilla : public CReporter std::string m_sBugzillaXMLRPC; std::string m_sLogin; std::string m_sPassword; - std::string m_sAttchmentInBase64; - - map_plugin_settings_t parse_settings(const map_plugin_settings_t& pSettings); public: CReporterBugzilla(); diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index fdcc3e5..9d15b26 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -50,7 +50,7 @@ static int scan_dmesg(vector_string_t& oopsList) /* "dumpoops" tool uses these two functions too */ extern "C" { -int scan_syslog_file(vector_string_t& oopsList, const char *filename) +int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t *last_changed_p) { VERB1 log("Scanning syslog file '%s'", filename); @@ -59,7 +59,6 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) int fd; int cnt_FoundOopses; ssize_t sz; - fd = open(filename, O_RDONLY); if (fd < 0) return 0; @@ -69,6 +68,15 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) return 0; } + if (last_changed_p != NULL) { + if (*last_changed_p == statb.st_mtime) { + VERB1 log("Syslog file '%s' hasn't changed since last scan, skipping", filename); + close(fd); + return 0; + } + *last_changed_p = statb.st_mtime; + } + /* * In theory we have a race here, since someone could spew * to /var/log/messages before we read it in... we try to @@ -123,6 +131,9 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) dd.SaveText(FILENAME_KERNEL, first_line); dd.SaveText(FILENAME_CMDLINE, "not_applicable"); dd.SaveText(FILENAME_BACKTRACE, second_line); + /* Optional, makes generated bz more informative */ + strchrnul(second_line, '\n')[0] = '\0'; + dd.SaveText(FILENAME_REASON, second_line); } catch (CABRTException& e) { @@ -137,6 +148,7 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) CKerneloopsScanner::CKerneloopsScanner() { int cnt_FoundOopses; + m_syslog_last_change = 0; /* Scan dmesg, on first call only */ vector_string_t oopsList; @@ -155,7 +167,7 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int forc } vector_string_t oopsList; - int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file); + int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file, &m_syslog_last_change); if (cnt_FoundOopses > 0) { save_oops_to_debug_dump(oopsList); /* diff --git a/lib/Plugins/KerneloopsScanner.h b/lib/Plugins/KerneloopsScanner.h index da856e0..2bff134 100644 --- a/lib/Plugins/KerneloopsScanner.h +++ b/lib/Plugins/KerneloopsScanner.h @@ -33,6 +33,8 @@ class CKerneloopsScanner : public CAction { + private: + time_t m_syslog_last_change; public: CKerneloopsScanner(); virtual void Run(const char *pActionDir, const char *pArgs, int force); diff --git a/lib/Plugins/KerneloopsSysLog.cpp b/lib/Plugins/KerneloopsSysLog.cpp index 7c60505..a5ee68b 100644 --- a/lib/Plugins/KerneloopsSysLog.cpp +++ b/lib/Plugins/KerneloopsSysLog.cpp @@ -353,7 +353,7 @@ next_line: } /* while (i < linecount) */ /* process last oops if we have one */ - if (oopsstart >= 0) { + if (oopsstart >= 0 && inbacktrace) { int oopsend = i-1; VERB3 log("End of oops at line %d (end of file): '%s'", oopsend, lines_info[oopsend].ptr); if (record_oops(oopses, lines_info, oopsstart, oopsend)) diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am index f4cd01e..968e8f9 100644 --- a/lib/Plugins/Makefile.am +++ b/lib/Plugins/Makefile.am @@ -129,8 +129,8 @@ libBugzilla_la_SOURCES = Bugzilla.h Bugzilla.cpp libBugzilla_la_LIBADD = $(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) libBugzilla_la_LDFLAGS = -avoid-version libBugzilla_la_CPPFLAGS = $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) \ - -I$(srcdir)/../../inc -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ - -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" + -I$(srcdir)/../../inc -I$(srcdir)/../Utils -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ + -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" # Catcut libCatcut_la_SOURCES = Catcut.h Catcut.cpp |
