|
|
4b6aa8 |
From 5ff7f36c1a06f5317241b43999f4f03a21594c79 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
Date: Tue, 23 Sep 2014 13:54:51 +0200
|
|
|
4b6aa8 |
Subject: [LIBREPORT PATCH 84/93] rhtsupport: check for hints only when
|
|
|
4b6aa8 |
creating a new case
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
If the check for hints finds something, reporter-rhtsupport asks the
|
|
|
4b6aa8 |
user whether he wants to continue in creating a new case. While it is a
|
|
|
4b6aa8 |
useful feature, the reporter should ask that question only if the user
|
|
|
4b6aa8 |
runs the reporter with option -t (create a new case).
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
We also want to receive as many uReports as possible, so we need to
|
|
|
4b6aa8 |
submit uReport before checking for hints because the report might
|
|
|
4b6aa8 |
interrupt the reporting process in case of positive hints results.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Related to rhbz#1139987
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
src/plugins/reporter-rhtsupport.c | 120 ++++++++++++++++++++------------------
|
|
|
4b6aa8 |
1 file changed, 63 insertions(+), 57 deletions(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
|
|
|
4b6aa8 |
index cd72c87..47e544d 100644
|
|
|
4b6aa8 |
--- a/src/plugins/reporter-rhtsupport.c
|
|
|
4b6aa8 |
+++ b/src/plugins/reporter-rhtsupport.c
|
|
|
4b6aa8 |
@@ -215,6 +215,56 @@ char *submit_ureport(const char *dump_dir_name, struct ureport_server_config *co
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
static
|
|
|
4b6aa8 |
+bool check_for_hints(const char *url, const char *login, const char *password, bool ssl_verify, const char *tempfile)
|
|
|
4b6aa8 |
+{
|
|
|
4b6aa8 |
+ rhts_result_t *result = get_rhts_hints(url, login, password, ssl_verify, tempfile);
|
|
|
4b6aa8 |
+#if 0 /* testing */
|
|
|
4b6aa8 |
+ log("ERR:%d", result->error);
|
|
|
4b6aa8 |
+ log("MSG:'%s'", result->msg);
|
|
|
4b6aa8 |
+ log("BODY:'%s'", result->body);
|
|
|
4b6aa8 |
+ result->error = 0;
|
|
|
4b6aa8 |
+ result->body = xstrdup(
|
|
|
4b6aa8 |
+ ""
|
|
|
4b6aa8 |
+ "<problems xmlns=\"http://www.redhat.com/gss/strata\">"
|
|
|
4b6aa8 |
+ "<link uri=\"http://access.redhat.com/\" rel=\"help\">The main Red Hat Support web site</link>"
|
|
|
4b6aa8 |
+ "<property name=\"content\">an ABRT report</property>"
|
|
|
4b6aa8 |
+ "<problem>"
|
|
|
4b6aa8 |
+ "<property name=\"source\">a backtrace in the ABRT report</property>"
|
|
|
4b6aa8 |
+ "<link uri=\"https://avalon-ci.gss.redhat.com/kb/docs/DOC-22029\" rel=\"suggestion\">[RHEL 5.3] EVO autocompletion lookup hang</link>"
|
|
|
4b6aa8 |
+ "</problem>"
|
|
|
4b6aa8 |
+ "</problems>"
|
|
|
4b6aa8 |
+ );
|
|
|
4b6aa8 |
+#endif
|
|
|
4b6aa8 |
+ if (result->error)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ /* We don't use result->msg here because it looks like this:
|
|
|
4b6aa8 |
+ * Error in file upload at 'URL', HTTP code: 404,
|
|
|
4b6aa8 |
+ * server says: '<error...>404 <message>...</message></error>'
|
|
|
4b6aa8 |
+ * TODO: make server send bare textual msgs, not XML.
|
|
|
4b6aa8 |
+ */
|
|
|
4b6aa8 |
+ error_msg("Error in file upload at '%s', HTTP code: %d", url, result->http_resp_code);
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ else if (result->body)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ /* The message might contain URLs to known solutions and such */
|
|
|
4b6aa8 |
+ char *hint = parse_response_from_RHTS_hint_xml2txt(result->body);
|
|
|
4b6aa8 |
+ if (hint)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ hint = append_to_malloced_string(hint, " ");
|
|
|
4b6aa8 |
+ hint = append_to_malloced_string(hint,
|
|
|
4b6aa8 |
+ _("Do you still want to create a RHTSupport ticket?")
|
|
|
4b6aa8 |
+ );
|
|
|
4b6aa8 |
+ int create_ticket = ask_yes_no(hint);
|
|
|
4b6aa8 |
+ free(hint);
|
|
|
4b6aa8 |
+ if (!create_ticket)
|
|
|
4b6aa8 |
+ return true;
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ free_rhts_result(result);
|
|
|
4b6aa8 |
+ return false;
|
|
|
4b6aa8 |
+}
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+static
|
|
|
4b6aa8 |
char *ask_rh_login(const char *message)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
char *login = ask(message);
|
|
|
4b6aa8 |
@@ -519,63 +569,6 @@ int main(int argc, char **argv)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
off_t tempfile_size = stat_st_size_or_die(tempfile);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- if (tempfile_size <= QUERY_HINTS_IF_SMALLER_THAN)
|
|
|
4b6aa8 |
- {
|
|
|
4b6aa8 |
- /* Check for hints and show them if we have something */
|
|
|
4b6aa8 |
- log(_("Checking for hints"));
|
|
|
4b6aa8 |
- result = get_rhts_hints(base_api_url,
|
|
|
4b6aa8 |
- login,
|
|
|
4b6aa8 |
- password,
|
|
|
4b6aa8 |
- ssl_verify,
|
|
|
4b6aa8 |
- tempfile
|
|
|
4b6aa8 |
- );
|
|
|
4b6aa8 |
-#if 0 /* testing */
|
|
|
4b6aa8 |
- log("ERR:%d", result->error);
|
|
|
4b6aa8 |
- log("MSG:'%s'", result->msg);
|
|
|
4b6aa8 |
- log("BODY:'%s'", result->body);
|
|
|
4b6aa8 |
- result->error = 0;
|
|
|
4b6aa8 |
- result->body = xstrdup(
|
|
|
4b6aa8 |
- ""
|
|
|
4b6aa8 |
- "<problems xmlns=\"http://www.redhat.com/gss/strata\">"
|
|
|
4b6aa8 |
- "<link uri=\"http://access.redhat.com/\" rel=\"help\">The main Red Hat Support web site</link>"
|
|
|
4b6aa8 |
- "<property name=\"content\">an ABRT report</property>"
|
|
|
4b6aa8 |
- "<problem>"
|
|
|
4b6aa8 |
- "<property name=\"source\">a backtrace in the ABRT report</property>"
|
|
|
4b6aa8 |
- "<link uri=\"https://avalon-ci.gss.redhat.com/kb/docs/DOC-22029\" rel=\"suggestion\">[RHEL 5.3] EVO autocompletion lookup hang</link>"
|
|
|
4b6aa8 |
- "</problem>"
|
|
|
4b6aa8 |
- "</problems>"
|
|
|
4b6aa8 |
- );
|
|
|
4b6aa8 |
-#endif
|
|
|
4b6aa8 |
- if (result->error)
|
|
|
4b6aa8 |
- {
|
|
|
4b6aa8 |
- /* We don't use result->msg here because it looks like this:
|
|
|
4b6aa8 |
- * Error in file upload at 'URL', HTTP code: 404,
|
|
|
4b6aa8 |
- * server says: '<error...>404 <message>...</message></error>'
|
|
|
4b6aa8 |
- * TODO: make server send bare textual msgs, not XML.
|
|
|
4b6aa8 |
- */
|
|
|
4b6aa8 |
- error_msg("Error in file upload at '%s', HTTP code: %d",
|
|
|
4b6aa8 |
- base_api_url, result->http_resp_code);
|
|
|
4b6aa8 |
- }
|
|
|
4b6aa8 |
- if (result->error == 0 && result->body)
|
|
|
4b6aa8 |
- {
|
|
|
4b6aa8 |
- /* The message might contain URLs to known solutions and such */
|
|
|
4b6aa8 |
- char *hint = parse_response_from_RHTS_hint_xml2txt(result->body);
|
|
|
4b6aa8 |
- if (hint)
|
|
|
4b6aa8 |
- {
|
|
|
4b6aa8 |
- hint = append_to_malloced_string(hint, " ");
|
|
|
4b6aa8 |
- hint = append_to_malloced_string(hint,
|
|
|
4b6aa8 |
- _("Do you still want to create a RHTSupport ticket?")
|
|
|
4b6aa8 |
- );
|
|
|
4b6aa8 |
- int create_ticket = ask_yes_no(hint);
|
|
|
4b6aa8 |
- free(hint);
|
|
|
4b6aa8 |
- if (!create_ticket)
|
|
|
4b6aa8 |
- goto ret;
|
|
|
4b6aa8 |
- }
|
|
|
4b6aa8 |
- }
|
|
|
4b6aa8 |
- free_rhts_result(result);
|
|
|
4b6aa8 |
- result = NULL;
|
|
|
4b6aa8 |
- }
|
|
|
4b6aa8 |
-
|
|
|
4b6aa8 |
if (!(opts & OPT_t))
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
char *bthash = NULL;
|
|
|
4b6aa8 |
@@ -593,6 +586,19 @@ int main(int argc, char **argv)
|
|
|
4b6aa8 |
bthash = submit_ureport(dump_dir_name, &urconf);
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+ if (tempfile_size <= QUERY_HINTS_IF_SMALLER_THAN)
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ /* Check for hints and show them if we have something */
|
|
|
4b6aa8 |
+ log(_("Checking for hints"));
|
|
|
4b6aa8 |
+ if (check_for_hints(base_api_url, login, password, ssl_verify, tempfile))
|
|
|
4b6aa8 |
+ {
|
|
|
4b6aa8 |
+ ureport_server_config_destroy(&urconf);
|
|
|
4b6aa8 |
+ free_map_string(ursettings);
|
|
|
4b6aa8 |
+ free(bthash);
|
|
|
4b6aa8 |
+ goto ret;
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+ }
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
log(_("Creating a new case"));
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
char *product = NULL;
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
1.8.3.1
|
|
|
4b6aa8 |
|