[PATCH] save "type" element with the same value as "analyzer"
by Denys Vlasenko
"analyzer" element name lost last shreds of sense.
We use it as a type indicator.
We can't just rename it, we need to keep compatibility.
Proposed way to do it:
For now, we fetch and look at "analyzer" element,
but we always save both "analyzer" and "type" (with same contents).
By 2013, we switch to looking at "type". Then we will stop generating
"analyzer" element sometime in the future.
--
vda
diff -x '*.po' -d -urpN libreport.5/src/include/internal_libreport.h libreport.6/src/include/internal_libreport.h
--- libreport.5/src/include/internal_libreport.h 2012-06-05 13:50:34.000000000 +0200
+++ libreport.6/src/include/internal_libreport.h 2012-06-13 14:04:19.168626063 +0200
@@ -659,7 +659,15 @@ struct dump_dir *steal_directory(const c
#define FILENAME_TIME "time" /* mandatory */
#define FILENAME_REASON "reason" /* mandatory? */
#define FILENAME_UID "uid" /* mandatory? */
+/*
+ * "analyzer" is to be gradually changed to "type":
+ * For now, we fetch and look at "analyzer" element,
+ * but we always save both "analyzer" and "type" (with same contents).
+ * By 2013, we switch to looking at "type". Then we will stop generating
+ * "analyzer" element.
+ */
#define FILENAME_ANALYZER "analyzer"
+#define FILENAME_TYPE "type"
#define FILENAME_EXECUTABLE "executable"
#define FILENAME_PID "pid"
#define FILENAME_PWD "pwd"
@@ -678,7 +686,6 @@ struct dump_dir *steal_directory(const c
// Name of the function where the application crashed.
// Optional.
#define FILENAME_CRASH_FUNCTION "crash_function"
-// filled by CDebugDump::Create() (which also fills FILENAME_UID):
#define FILENAME_ARCHITECTURE "architecture"
#define FILENAME_KERNEL "kernel"
// From /etc/system-release or /etc/redhat-release
diff -x '*.po' -d -urpN libreport.5/src/lib/make_descr.c libreport.6/src/lib/make_descr.c
--- libreport.5/src/lib/make_descr.c 2012-05-29 15:52:21.000000000 +0200
+++ libreport.6/src/lib/make_descr.c 2012-06-13 14:01:52.101689695 +0200
@@ -249,6 +249,7 @@ char* make_description_mailx(problem_dat
static const char *const blacklisted_items[] = {
CD_DUMPDIR ,
FILENAME_ANALYZER ,
+ FILENAME_TYPE ,
FILENAME_COREDUMP ,
FILENAME_HOSTNAME ,
FILENAME_DUPHASH ,
diff -x '*.po' -d -urpN libreport.5/src/lib/problem_data.c libreport.6/src/lib/problem_data.c
--- libreport.5/src/lib/problem_data.c 2012-05-29 15:52:21.000000000 +0200
+++ libreport.6/src/lib/problem_data.c 2012-06-13 14:01:27.061881339 +0200
@@ -61,7 +61,11 @@ void add_basics_to_problem_data(problem_
{
const char *analyzer = get_problem_item_content_or_NULL(pd, FILENAME_ANALYZER);
if (analyzer == NULL)
- add_to_problem_data(pd, FILENAME_ANALYZER, "libreport");
+ {
+ analyzer = "libreport";
+ add_to_problem_data(pd, FILENAME_ANALYZER, analyzer);
+ }
+ add_to_problem_data(pd, FILENAME_TYPE, analyzer);
/* If application didn't provide dupe hash, we generate it
* from all components, so we at least eliminate the exact same
@@ -104,20 +108,19 @@ void add_basics_to_problem_data(problem_
add_to_problem_data(pd, FILENAME_DUPHASH, hash_str);
}
- pid_t pid = getpid();
const char *executable = get_problem_item_content_or_NULL(pd, FILENAME_EXECUTABLE);
- if (executable == NULL && pid > 0)
+ if (executable == NULL)
{
- char buf[PATH_MAX+1];
- char *exe = xasprintf("/proc/%u/exe", pid);
+ char buf[PATH_MAX + 1];
+ char exe[sizeof("/proc/%u/exe") + sizeof(int)*3]
+ sprintf(exe, "/proc/%u/exe", (int)getpid());
ssize_t read = readlink(exe, buf, PATH_MAX);
if (read > 0)
{
- buf[read] = 0;
+ buf[read] = '\0';
VERB2 log("reporting initiated from: %s", buf);
add_to_problem_data(pd, FILENAME_EXECUTABLE, buf);
}
- free(exe);
//#ifdef WITH_RPM
/* FIXME: component should be taken from rpm using librpm
11 years, 10 months
[PATCH] abrt-gui: add missing error check after dbus call
by Denys Vlasenko
Pretty trivial patch...
--
vda
diff -x '*.po' -d -urpN abrt.0/src/gui-gtk/main.c abrt.1/src/gui-gtk/main.c
--- abrt.0/src/gui-gtk/main.c 2012-06-13 13:40:49.000000000 +0200
+++ abrt.1/src/gui-gtk/main.c 2012-06-13 13:47:43.853436512 +0200
@@ -19,7 +19,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <sys/inotify.h>
-#include <gio/gio.h> //dbus
+#include <gio/gio.h> /* dbus */
#if HAVE_LOCALE_H
# include <locale.h>
#endif
@@ -263,8 +263,13 @@ static problem_data_t *get_problem_data_
NULL,
&error);
g_object_unref(proxy);
-
-//FIXME: error check?
+ if (error)
+ {
+ //TODO show a warning dialog here or on the higher level?
+ error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
+ g_error_free(error);
+ return NULL;
+ }
problem_data_t *pd = new_problem_data();
char *key, *val;
@@ -294,12 +299,15 @@ static void add_directory_to_dirlist(con
logmode = sv_logmode;
if (!dd)
return;
+//FIXME: this is inefficient. We can instead read only selected elements, not all:
pd = create_problem_data_from_dump_dir(dd);
dd_close(dd);
}
else
{
pd = get_problem_data_dbus(problem_dir_path);
+ if (!pd)
+ return;
}
char time_buf[sizeof("YYYY-MM-DD hh:mm:ss")];
@@ -398,9 +406,10 @@ static void query_dbus_and_add_to_dirlis
list_free_with_free(problem_dirs);
}
-//HACK ALERT! We "magically know" that dbus-reported problem dirs live in
-//g_settings_dump_location.
-//Notifications on changes should be implemented to go over dbus too.
+ /* HACK ALERT! We "magically know" that dbus-reported problem dirs
+ * live in g_settings_dump_location.
+ * Notifications on changes should be implemented to go over dbus too.
+ */
watch_this_dir(g_settings_dump_location);
}
11 years, 10 months
[PATCH] track#558 : pass a type of an ureported problem trough command line option
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/lib/json.c | 21 ++++++---------------
src/lib/ureport.h | 11 +++++++++--
src/plugins/ureport.c | 23 ++++++++++++++++++-----
3 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/src/lib/json.c b/src/lib/json.c
index 659eda2..c9aed5f 100644
--- a/src/lib/json.c
+++ b/src/lib/json.c
@@ -96,18 +96,9 @@ static void ureport_add_os(struct json_object *ur, problem_data_t *pd)
json_object_object_add(ur, "os", jobject);
}
-static void ureport_add_type(struct json_object *ur, problem_data_t *pd)
+static void ureport_add_type(struct json_object *ur, const char *problem_type)
{
- char *pd_item = get_problem_item_content_or_NULL(pd, FILENAME_ANALYZER);
- if (!pd_item)
- return;
-
- if (!strcmp(pd_item, "CCpp"))
- ureport_add_str(ur, "type", "USERSPACE");
- if (!strcmp(pd_item, "Python"))
- ureport_add_str(ur, "type", "PYTHON");
- if (!strcmp(pd_item, "Kerneloops"))
- ureport_add_str(ur, "type", "KERNELOOPS");
+ ureport_add_str(ur, "type", problem_type);
}
static void ureport_add_core_backtrace(struct json_object *ur, problem_data_t *pd)
@@ -216,7 +207,7 @@ static void ureport_add_reporter(struct json_object *ur, const char *name, const
json_object_object_add(ur, "reporter", jobject);
}
-char *new_json_ureport(problem_data_t *pd)
+char *new_json_ureport(problem_data_t *pd, const char *problem_type)
{
struct json_object *ureport = json_object_new_object();
if (!ureport)
@@ -236,7 +227,7 @@ char *new_json_ureport(problem_data_t *pd)
ureport_add_item_str(ureport, pd, FILENAME_REASON, NULL);
ureport_add_item_str(ureport, pd, FILENAME_COMPONENT, NULL);
- ureport_add_type(ureport, pd);
+ ureport_add_type(ureport, problem_type);
ureport_add_pkg(ureport, pd);
ureport_add_related_pkgs(ureport, pd);
@@ -251,7 +242,7 @@ char *new_json_ureport(problem_data_t *pd)
return j;
}
-struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config)
+struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_config *config)
{
int flags = ABRT_POST_WANT_BODY | ABRT_POST_WANT_ERROR_MSG;
@@ -266,7 +257,7 @@ struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_server_c
NULL,
};
- char *json_ureport = new_json_ureport(pd);
+ char *json_ureport = new_json_ureport(pd, config->ur_problem_type);
abrt_post_string_as_form_data(post_state, config->ur_url, "application/json",
headers, json_ureport);
diff --git a/src/lib/ureport.h b/src/lib/ureport.h
index b1b1d89..8b76e9d 100644
--- a/src/lib/ureport.h
+++ b/src/lib/ureport.h
@@ -26,18 +26,25 @@ extern "C" {
#endif
/*
+ * Maximal allowed lenght of problem type string
+ */
+#define UREPORT_PROBLEM_TYPE_MAX_LEN 16
+#define UREPORT_PROBLEM_TYPE_MAX_LEN_STR "16"
+
+/*
* uReport server configuration
*/
-struct ureport_server_config
+struct ureport_config
{
const char *ur_url; ///< Web service URL
bool ur_ssl_verify; ///< Verify HOST and PEER certificates
+ const char *ur_problem_type; ///< Type of problem
};
struct abrt_post_state;
#define post_ureport libreport_post_ureport
-struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config);
+struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_config *config);
#ifdef __cplusplus
}
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index 5ffcea3..f003bf1 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -30,7 +30,7 @@
*
* @param config a server configuration to be populated
*/
-static void load_ureport_server_config(struct ureport_server_config *config)
+static void load_ureport_config(struct ureport_config *config)
{
const char *environ;
@@ -88,9 +88,10 @@ int main(int argc, char **argv)
{
abrt_init(argv);
- struct ureport_server_config config = {
+ struct ureport_config config = {
.ur_url = "https://retrace.fedoraproject.org/faf/reports/new/",
.ur_ssl_verify = true,
+ .ur_problem_type = NULL,
};
bool insecure = !config.ur_ssl_verify;
@@ -101,13 +102,19 @@ int main(int argc, char **argv)
OPT_STRING('u', "url", &config.ur_url, "URL", _("Specify url")),
OPT_BOOL('k', "insecure", &insecure,
_("Allow insecure connection to ureport server")),
+ OPT_STRING('t', "problem-type", &config.ur_problem_type, "TYPE", _("Specify type of reported problem")),
OPT_END(),
};
const char *program_usage_string = _(
- "& [-v] [-u URL] [-k] -d DIR\n"
+ _("& [-v] [-u URL] [-k] -t TYPE -d DIR\n"
"\n"
- "Upload micro report"
+ "Upload micro report\n"
+ "\n"
+ "Option -t sets type of reported problem. A value of the problem type is\n"
+ "an arbitrary string shorter than "UREPORT_PROBLEM_TYPE_MAX_LEN_STR" letters. Server rejects all ureports\n"
+ "with uknown problem types."
+ )
);
parse_opts(argc, argv, program_options, program_usage_string);
@@ -115,8 +122,14 @@ int main(int argc, char **argv)
if (!dd)
xfunc_die();
+ if (!config.ur_problem_type
+ || strlen(config.ur_problem_type) > UREPORT_PROBLEM_TYPE_MAX_LEN )
+ error_msg_and_die(
+ _("Type of problem must be set and must not be longer than "\
+ UREPORT_PROBLEM_TYPE_MAX_LEN_STR" letters"));
+
config.ur_ssl_verify = !insecure;
- load_ureport_server_config(&config);
+ load_ureport_config(&config);
problem_data_t *pd = create_problem_data_from_dump_dir(dd);
dd_close(dd);
--
1.7.10.2
11 years, 11 months
[PATCH] track$555 : reporter-bugizlla : bug summary text from reason field command line option
by Jakub Filak
reporter-bugzilla should have an option forcing the reporter to create a
summary text from the reason field instead of magicall creation of a
summary text according to used analyzer.
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/plugins/bugzilla_event.conf | 2 +-
src/plugins/reporter-bugzilla.c | 21 ++++++++++++++-------
src/plugins/rhbz.c | 4 ++--
src/plugins/rhbz.h | 3 ++-
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/src/plugins/bugzilla_event.conf b/src/plugins/bugzilla_event.conf
index 109c581..dd3fdec 100644
--- a/src/plugins/bugzilla_event.conf
+++ b/src/plugins/bugzilla_event.conf
@@ -1 +1 @@
-EVENT=report_Bugzilla analyzer=libreport reporter-bugzilla -b
+EVENT=report_Bugzilla analyzer=libreport reporter-bugzilla -b -p
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index bb59ac7..af500b4 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
"\n"
- "& [-vbf] [-c CONFFILE] -d DIR\n"
+ "& [-vbfp] [-c CONFFILE] -d DIR\n"
"or:\n"
"& [-v] [-c CONFFILE] [-d DIR] -t[ID] FILE...\n"
"\n"
@@ -72,7 +72,9 @@ int main(int argc, char **argv)
"\n"
"If such bug is not found, then a new bug is created. Elements of DIR\n"
"are stored in the bug as part of bug description or as attachments,\n"
- "depending on their type and size.\n"
+ "depending on their type and size. Option -p forces reporter to create\n"
+ "bug summary without special decorations which are usually used for\n"
+ "filtering of bugs.\n"
"\n"
"Otherwise, if such bug is found and it is marked as CLOSED DUPLICATE,\n"
"the tool follows the chain of duplicates until it finds a non-DUPLICATE bug.\n"
@@ -101,6 +103,8 @@ int main(int argc, char **argv)
OPT_t = 1 << 3,
OPT_b = 1 << 4,
OPT_f = 1 << 5,
+ OPT_h = 1 << 6,
+ OPT_p = 1 << 7,
};
char *ticket_no = NULL, *abrt_hash = NULL;
@@ -113,6 +117,7 @@ int main(int argc, char **argv)
OPT_BOOL( 'b', NULL, NULL, _("When creating bug, attach binary files too")),
OPT_BOOL( 'f', NULL, NULL, _("Force reporting even if this problem is already reported")),
OPT_STRING( 'h', "duphash", &abrt_hash, "DUPHASH", _("Find BUG-ID according to DUPHASH")),
+ OPT_BOOL( 'p', "plain-summary", NULL, _("When creating bug, create summary without decorations")),
OPT_END()
};
unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
@@ -338,17 +343,19 @@ int main(int argc, char **argv)
if (all_bugs_size == 0)
{
+ int flags = RHBZ_NOMAIL_NOTIFY;
+ if (opts & OPT_b)
+ flags |= RHBZ_ATTACH_BINARY_FILES;
+ if (opts & OPT_p)
+ flags |= RHBZ_PLAIN_SUMMARY;
+
/* Create new bug */
log(_("Creating a new bug"));
- int bug_id = rhbz_new_bug(client, problem_data, rhbz.b_release);
+ int bug_id = rhbz_new_bug(client, problem_data, rhbz.b_release, flags);
log(_("Adding attachments to bug %i"), bug_id);
char bug_id_str[sizeof(int)*3 + 2];
snprintf(bug_id_str, sizeof(bug_id_str), "%i", bug_id);
-
- int flags = RHBZ_NOMAIL_NOTIFY;
- if (opts & OPT_b)
- flags |= RHBZ_ATTACH_BINARY_FILES;
rhbz_attach_files(client, bug_id_str, problem_data, flags);
bz = new_bug_info();
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 579655b..5df943d 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -596,7 +596,7 @@ char *rhbz_get_backtrace_info(problem_data_t *problem_data, size_t max_text_size
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
- const char *release)
+ const char *release, int flags)
{
func_entry();
@@ -628,7 +628,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
FILENAME_TAINTED_SHORT);
struct strbuf *buf_summary = strbuf_new();
- if (analyzer && strcmp(analyzer, "libreport") == 0)
+ if (flags & RHBZ_PLAIN_SUMMARY)
{
strbuf_append_str(buf_summary, reason);
}
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
index 84e0ba0..6b398f2 100644
--- a/src/plugins/rhbz.h
+++ b/src/plugins/rhbz.h
@@ -39,6 +39,7 @@ enum {
RHBZ_NOMAIL_NOTIFY = (1 << 3),
RHBZ_PRIVATE = (1 << 4),
RHBZ_ATTACH_BINARY_FILES = (1 << 5),
+ RHBZ_PLAIN_SUMMARY = (1 << 6),
};
#define IS_MANDATORY(flags) ((flags) & RHBZ_MANDATORY_MEMB)
@@ -102,7 +103,7 @@ int rhbz_array_size(xmlrpc_value *xml);
int rhbz_bug_id(xmlrpc_value *xml, size_t ver);
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
- const char *release);
+ const char *release, int flags);
int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags);
--
1.7.10.2
11 years, 11 months
[PATCH] report-gtk : skip events whit rquired bt rating greater than problem bt rating
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gui-wizard-gtk/wizard.c | 109 ++++++++++++++++++++++++------------------
1 files changed, 62 insertions(+), 47 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 30c25ee..38d20f2 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -62,8 +62,6 @@ static GtkTextView *g_tv_event_log;
/* List of event_gui_data's */
/* List of event_gui_data's */
-static GList *g_list_selected_reporters;
-
static GtkContainer *g_container_details1;
static GtkContainer *g_container_details2;
@@ -192,6 +190,8 @@ static struct strbuf *cmd_output = NULL;
/* Utility functions */
+static bool check_minimal_bt_rating(const char *event_name);
+
static void wrap_fixer(GtkWidget *widget, gpointer data_unused)
{
if (GTK_IS_CONTAINER(widget))
@@ -705,6 +705,7 @@ static void event_rb_was_toggled(GtkButton *button, gpointer user_data)
free(g_event_selected);
g_event_selected = xstrdup(evdata->event_name);
check_event_config(evdata->event_name);
+ gtk_widget_set_sensitive(g_btn_next, check_minimal_bt_rating(g_event_selected));
}
}
}
@@ -1693,10 +1694,20 @@ static void clear_warnings(void)
gtk_container_foreach(GTK_CONTAINER(g_box_warning_labels), &remove_child_widget, NULL);
}
-static void check_bt_rating_and_allow_send(void)
+static bool check_minimal_bt_rating(const char *event_name)
{
- int minimal_rating = 0;
bool send = true;
+ event_config_t *event_cfg = NULL;
+
+ if (!event_name)
+ perror_msg("Cannot check backtrace rating because of invalid event name");
+ else
+ {
+ event_cfg = get_event_config(event_name);
+
+ if (!event_cfg)
+ perror_msg("Cannot check backtrace rating because of invalid event config for '%s'", event_name);
+ }
/*
* FIXME: this should be bind to a reporter not to a compoment
@@ -1705,7 +1716,7 @@ static void check_bt_rating_and_allow_send(void)
*/
const char *analyzer = get_problem_item_content_or_NULL(g_cd, FILENAME_ANALYZER);
//FIXME: say "no" to special casing!
- if (analyzer && strcmp(analyzer, "Kerneloops") != 0)
+ if (event_cfg && analyzer && strcmp(analyzer, "Kerneloops") != 0)
{
const char *rating_str = get_problem_item_content_or_NULL(g_cd, FILENAME_RATING);
//COMPAT, remove after 2.1 release
@@ -1722,38 +1733,25 @@ static void check_bt_rating_and_allow_send(void)
add_warning(_("Reporting disabled because the rating does not contain a number '%s'."));
send = false;
}
-
- GList *li = g_list_selected_reporters;
- while (li != NULL)
+ else
{
- /* need to obey the highest minimal rating of all selected reporters
- * FIXME: check this when selecting the reporter and allow select
- * only usable ones
- */
- event_config_t *cfg = get_event_config((const char *)li->data);
- if (cfg->ec_minimal_rating > minimal_rating)
+ VERB1 log("Checking current rating %ld to required rating %ld.", rating, event_cfg->ec_minimal_rating);
+ if (rating == event_cfg->ec_minimal_rating) /* bt is usable, but not complete, so show a warning */
+ add_warning(_("The backtrace is incomplete, please make sure you provide the steps to reproduce."));
+ else if (rating < event_cfg->ec_minimal_rating)
{
- minimal_rating = cfg->ec_minimal_rating;
- VERB1 log("%s reporter sets the minimal rating to: %i", (const char *)li->data, minimal_rating);
+ //FIXME: see CreporterAssistant: 394 for ideas
+ add_warning(_("Reporting disabled because the backtrace is unusable."));
+ send = false;
}
-
- li = g_list_next(li);
- };
-
- if (rating == minimal_rating) /* bt is usable, but not complete, so show a warning */
- {
- add_warning(_("The backtrace is incomplete, please make sure you provide the steps to reproduce."));
- }
-
- if (rating < minimal_rating)
- {
- //FIXME: see CreporterAssistant: 394 for ideas
- add_warning(_("Reporting disabled because the backtrace is unusable."));
- send = false;
}
}
+ else
+ {
+ VERB1 log("Problem doesn't have backtrace rating.");
+ }
}
- gtk_widget_set_sensitive(g_btn_next, send);
+ return send;
}
static void on_bt_approve_toggle(GtkToggleButton *togglebutton, gpointer user_data)
@@ -1928,6 +1926,24 @@ static void highlight_forbidden(void)
static gint select_next_page_no(gint current_page_no, gpointer data);
+static GList *get_next_processed_event(GList **events_list)
+{
+ GList *event = *events_list;
+
+ while (event)
+ {
+ if (check_minimal_bt_rating((const char *)event->data))
+ break;
+
+ event = g_list_next(event);
+ }
+
+ if (event)
+ *events_list = g_list_next(event);
+
+ return event;
+}
+
static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer user_data)
{
//int page_no = gtk_assistant_get_current_page(g_assistant);
@@ -1960,7 +1976,6 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us
if (pages[PAGENO_EDIT_ELEMENTS].page_widget == page)
{
clear_warnings();
- check_bt_rating_and_allow_send();
highlight_forbidden();
show_warnings();
}
@@ -2006,19 +2021,13 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us
&& g_event_selected[0]
) {
start_event_run(g_event_selected,
- pages[PAGENO_EVENT_PROGRESS].page_widget,
- g_tv_event_log,
- g_lbl_event_log,
- _("Processing..."),
- _("Processing failed. You can try another operation if available."),
- _("Processing finished, please proceed to the next step.")
+ pages[PAGENO_EVENT_PROGRESS].page_widget,
+ g_tv_event_log,
+ g_lbl_event_log,
+ _("Processing..."),
+ _("Processing failed. You can try another operation if available."),
+ _("Processing finished, please proceed to the next step.")
);
-
- if (g_auto_event_list)
- {
- g_auto_event_list = g_auto_event_list->next;
- VERB1 log("next -e EVENT:%s", g_auto_event_list ? (char*)g_auto_event_list->data : "NULL");
- }
}
}
}
@@ -2048,9 +2057,16 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
{
if (!g_expert_mode)
{
- VERB1 log("selected -e EVENT:%s on page: %d", (char*)g_auto_event_list->data, current_page_no);
+ GList *event = get_next_processed_event(&g_auto_event_list);
+ if (!event)
+ {
+ current_page_no = pages[PAGENO_NOT_SHOWN].page_no -1;
+ goto again;
+ }
+
+ VERB1 log("selected -e EVENT:%s on page: %d", (char*)event->data, current_page_no);
free(g_event_selected);
- g_event_selected = xstrdup((char*)g_auto_event_list->data);
+ g_event_selected = xstrdup((char*)event->data);
/*
* We don't remove the list element, because GTK calls select_next_page_no()
* spuriously (for example, it calls it twice for first page).
@@ -2063,7 +2079,6 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
current_page_no = pages[PAGENO_EVENT_SELECTOR].page_no + 1;
goto event_was_selected;
-
}
}
--
1.7.7.6
11 years, 11 months
[PATCH v5 (koops bug fixed)] rhbz#747410 : bugzillas are created according to rh bugzilla default template
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/internal_libreport.h | 4 +
src/lib/make_descr.c | 43 ++++++---
src/plugins/reporter-bugzilla.c | 2 +-
src/plugins/rhbz.c | 204 +++++++++++++++++++++++++++++++++----
4 files changed, 216 insertions(+), 37 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index c57bd5f..23a74f9 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -581,6 +581,8 @@ enum {
};
#define make_description libreport_make_description
char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags);
+#define make_description_item_multiline libreport_make_description_item_multiline
+char *make_description_item_multiline(const char *name, const char* content);
#define make_description_bz libreport_make_description_bz
char* make_description_bz(problem_data_t *problem_data, unsigned max_text_size);
#define make_description_logger libreport_make_description_logger
@@ -716,6 +718,8 @@ struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name
#define FILENAME_PKG_VERSION "pkg_version"
#define FILENAME_PKG_RELEASE "pkg_release"
#define FILENAME_PKG_ARCH "pkg_arch"
+#define FILENAME_USERNAME "username"
+#define FILENAME_ABRT_VERSION "abrt_version"
// Not stored as files, added "on the fly":
#define CD_DUMPDIR "Directory"
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
index 68133a2..21fb83c 100644
--- a/src/lib/make_descr.c
+++ b/src/lib/make_descr.c
@@ -26,6 +26,27 @@ static bool rejected_name(const char *name, char **v, int flags)
return r;
}
+char *make_description_item_multiline(const char *name, const char *content)
+{
+ char *eol = strchr(content, '\n');
+ if (!eol)
+ return NULL;
+
+ struct strbuf *buf = strbuf_new();
+ strbuf_append_str(buf, name);
+ strbuf_append_str(buf, ":\n");
+ for (;;)
+ {
+ eol = strchrnul(content, '\n');
+ strbuf_append_strf(buf, ":%.*s\n", (int)(eol - content), content);
+ if (*eol == '\0' || eol[1] == '\0')
+ break;
+ content = eol + 1;
+ }
+
+ return strbuf_free_nobuf(buf);
+}
+
char *make_description(problem_data_t *problem_data, char **names_to_skip,
unsigned max_text_size, unsigned desc_flags)
{
@@ -171,24 +192,18 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip,
|| (!strcmp(analyzer, "Kerneloops") && !strcmp(key, FILENAME_BACKTRACE))))
{
char *formatted = format_problem_item(item);
- char *output = formatted ? formatted : item->content;
- char *eol = strchr(output, '\n');
- if (eol)
+ char *output = make_description_item_multiline(key, formatted ? formatted : item->content);
+
+ if (output)
{
if (!empty)
- strbuf_append_char(buf_dsc, '\n');
- strbuf_append_str(buf_dsc, key);
- strbuf_append_str(buf_dsc, ":\n");
- for (;;)
- {
- eol = strchrnul(output, '\n');
- strbuf_append_strf(buf_dsc, ":%.*s\n", (int)(eol - output), output);
- if (*eol == '\0' || eol[1] == '\0')
- break;
- output = eol + 1;
- }
+ strbuf_append_str(buf_dsc, "\n");
+
+ strbuf_append_str(buf_dsc, output);
empty = false;
+ free(output);
}
+
free(formatted);
}
}
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index b96549d..bb59ac7 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
int flags = RHBZ_NOMAIL_NOTIFY;
if (opts & OPT_b)
flags |= RHBZ_ATTACH_BINARY_FILES;
- rhbz_attach_big_files(client, bug_id_str, problem_data, flags);
+ rhbz_attach_files(client, bug_id_str, problem_data, flags);
bz = new_bug_info();
bz->bi_status = xstrdup("NEW");
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 53662e1..579655b 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -19,6 +19,11 @@
#include "internal_libreport.h"
#include "rhbz.h"
+#include <btparser/location.h>
+#include <btparser/backtrace.h>
+#include <btparser/thread.h>
+#include <btparser/frame.h>
+#include <btparser/strbuf.h>
#define MAX_HOPS 5
@@ -32,6 +37,78 @@
#define func_entry_str(x)
#endif
+/******************************************************************************/
+/* Global lists used in process of creation a new Bugzilla bug
+ * New bug logic:
+ * 1. 'Description of problem' is FILENAME_COMMENT
+ * 2. 'Version-Release number of selected component' is FILENAME_PACKAGE
+ * 3. 'Additional info' is a concatenation of files listed in ADDITIONAL_INFO_FILES_LIST
+ * 3.1 backtrace is also present in 'Additional info'
+ * - if has size lower than CD_TEXT_ATT_SIZE_BZ then the bactrace is inlined
+ * - otherwise preview of crashed thread stack trace is created
+ * 4. Attached files are the ONLY files which ARE NOT present in g_not_attached_files
+ * As you can see g_not_attached_files consist from some hardcoded files and
+ * files from ADDITIONAL_INFO_FILES_LIST.
+ * Black list for attached files allows us to attach all of files added to
+ * a problem directory by a user.
+ */
+#define INLINED_FILES_LIST\
+ FILENAME_ABRT_VERSION,\
+ FILENAME_RATING,\
+ FILENAME_KERNEL,\
+ FILENAME_CRASH_FUNCTION,\
+ FILENAME_CMDLINE,\
+ FILENAME_TAINTED_LONG
+
+/* Items we want to use in additional info */
+static const char *const g_additional_info_files[] = {
+ /* ! a bunch of file names */
+ INLINED_FILES_LIST,
+ NULL
+};
+
+/* Items we don't want to attach to bz */
+static const char *const g_not_attached_files[] = {
+ CD_DUMPDIR,
+ FILENAME_ANALYZER,
+ FILENAME_PID,
+ FILENAME_PWD,
+ FILENAME_ROOTDIR,
+ FILENAME_BINARY,
+ FILENAME_COREDUMP,
+ FILENAME_DUPHASH,
+ FILENAME_ARCHITECTURE,
+ FILENAME_OS_RELEASE,
+ FILENAME_OS_RELEASE_IN_ROOTDIR,
+ FILENAME_PACKAGE,
+ FILENAME_COMPONENT,
+ FILENAME_COMMENT,
+ FILENAME_HOSTNAME,
+ FILENAME_REASON,
+ FILENAME_UID,
+ FILENAME_REMOTE,
+ FILENAME_TAINTED,
+ FILENAME_TAINTED_SHORT,
+ FILENAME_VMCORE,
+ FILENAME_UUID,
+ FILENAME_COUNT,
+ FILENAME_REPORTED_TO,
+ FILENAME_NOT_REPORTABLE,
+ FILENAME_PKG_EPOCH,
+ FILENAME_PKG_NAME,
+ FILENAME_PKG_VERSION,
+ FILENAME_PKG_RELEASE,
+ FILENAME_PKG_ARCH,
+ FILENAME_REMOTE_RESULT,
+ FILENAME_USERNAME,
+ FILENAME_TIME,
+ FILENAME_EXECUTABLE,
+ /* ! a bunch of file names */
+ INLINED_FILES_LIST,
+ NULL
+};
+/******************************************************************************/
+
struct bug_info *new_bug_info()
{
func_entry();
@@ -461,6 +538,62 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
return bz;
}
+/*
+ * Produces an optimal backtrace for bugzilla comment
+ */
+char *rhbz_get_backtrace_info(problem_data_t *problem_data, size_t max_text_size)
+{
+ const problem_item *item = get_problem_data_item_or_NULL(problem_data,
+ FILENAME_BACKTRACE);
+
+ if (!item)
+ return NULL;
+
+ char *truncated = NULL;
+
+ if (strlen(item->content) >= max_text_size)
+ {
+ struct btp_location location;
+ btp_location_init(&location);
+
+ /* btp_backtrace_parse modifies the input parameter */
+ char *content = item->content;
+ struct btp_backtrace *backtrace = btp_backtrace_parse((const char **)&content, &location);
+
+ if (!backtrace)
+ {
+ log(_("Can't parse backtrace"));
+ return NULL;
+ }
+
+ /* Get optimized thread stack trace for 10 top most frames */
+ struct btp_thread *thread = btp_backtrace_get_optimized_thread(backtrace, 10);
+
+ btp_backtrace_free(backtrace);
+
+ if (!thread)
+ {
+ log(_("Can't find crash thread"));
+ return NULL;
+ }
+
+ /* Cannot be NULL, it dies on memory error */
+ struct btp_strbuf *bt = btp_strbuf_new();
+
+ btp_thread_append_to_str(thread, bt, true);
+
+ btp_thread_free(thread);
+
+ truncated = btp_strbuf_free_nobuf(bt);
+ }
+
+ char *bt = make_description_item_multiline(truncated ? "truncated backtrace" : FILENAME_BACKTRACE,
+ truncated ? truncated : item->content);
+ free(truncated);
+
+ return bt;
+}
+
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
const char *release)
@@ -520,14 +653,39 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
}
char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
- char *bz_dsc;
+ char *full_dsc = NULL;
if (analyzer && !strcmp(analyzer, "Kerneloops"))
- bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
+ {
+ char *bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
+ full_dsc = xasprintf("libreport version: "VERSION"\n%s", bz_dsc);
+ free(bz_dsc);
+ }
else
- bz_dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ);
-
- char *full_dsc = xasprintf("libreport version: "VERSION"\n%s", bz_dsc);
- free(bz_dsc);
+ {
+ const char *comment = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_COMMENT);
+
+ char *bz_dsc = make_description(problem_data, (char**)g_additional_info_files,
+ CD_TEXT_ATT_SIZE_BZ, MAKEDESC_SHOW_MULTILINE | MAKEDESC_WHITELIST);
+
+ char *backtrace = rhbz_get_backtrace_info(problem_data, CD_TEXT_ATT_SIZE_BZ);
+
+ /* Generating of a description according to the RH bugzilla default format:
+ * https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora
+ */
+ full_dsc = xasprintf("Description of problem:\n%s\n\n"
+ "Version-Release number of selected component:\n%s\n\n"
+ "Additional info:\n"
+ "libreport version: "VERSION"\n%s\n"
+ "%s",
+ comment ? comment : "",
+ package,
+ bz_dsc,
+ backtrace ? backtrace : "");
+
+ free(backtrace);
+ free(bz_dsc);
+ }
char *product = NULL;
char *version = NULL;
@@ -631,38 +789,40 @@ int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
}
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
-int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
+int rhbz_attach_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags)
{
func_entry();
+ const char *analyzer = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_ANALYZER);
+ /* Do not attach anything if analyzer is Kerneloops */
+ if (!strcmp(analyzer, "Kerneloops"))
+ return 0;
+
GHashTableIter iter;
char *name;
struct problem_item *value;
- const char *analyzer = get_problem_item_content_or_NULL(problem_data,
- FILENAME_ANALYZER);
-
g_hash_table_iter_init(&iter, problem_data);
while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
{
+ /* The not attached list contains files that are used in the description or
+ * in the bug fields and the files which nobody is interested in.
+ */
+ if (is_in_string_list(name, (char**)g_not_attached_files))
+ continue;
+
if (value->flags & CD_FLAG_TXT)
{
const char *content = value->content;
- if (!strcmp(analyzer, "Kerneloops") && !strcmp(name, FILENAME_BACKTRACE))
- continue;
+ const unsigned len = strlen(content);
- unsigned len = strlen(content);
+ /* For standard bugs, do not attach backtrace shorter than CD_TEXT_ATT_SIZE_BZ */
+ if (!strcmp(name, FILENAME_BACKTRACE) && len < CD_TEXT_ATT_SIZE_BZ)
+ continue;
- // We were special-casing FILENAME_BACKTRACE here, but karel says
- // he can retrieve it in inlined form from comments too.
- if (len > CD_TEXT_ATT_SIZE_BZ /*|| (strcmp(name, FILENAME_BACKTRACE) == 0)*/)
- {
- /* This text item wasn't added in comments, it is too big
- * for that. Attach it as a file.
- */
- rhbz_attach_blob(ax, name, bug_id, content, len, flags);
- }
+ rhbz_attach_blob(ax, name, bug_id, content, len, flags);
}
if ((flags & RHBZ_ATTACH_BINARY_FILES) && (value->flags & CD_FLAG_BIN))
{
--
1.7.7.6
11 years, 11 months
[PATCH v2] track#552 : reporter-ureport : allows to enable/disable SSL certificate checking
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/internal_libreport.h | 3 --
src/lib/Makefile.am | 3 +-
src/lib/json.c | 15 +++++++-----
src/lib/ureport.h | 46 +++++++++++++++++++++++++++++++++++++
src/plugins/report_uReport.xml.in | 5 ++++
src/plugins/ureport.c | 29 ++++++++++++-----------
6 files changed, 77 insertions(+), 24 deletions(-)
create mode 100644 src/lib/ureport.h
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index c57bd5f..6a7b53a 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -795,9 +795,6 @@ void show_usage_and_die(const char *usage, const struct options *opt) NORETURN;
*/
struct abrt_post_state;
-#define post_ureport libreport_post_ureport
-struct abrt_post_state *post_ureport(problem_data_t *pd, const char *ureport_url);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index b7af8c1..c29dd6b 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -93,7 +93,8 @@ libabrt_dbus_la_LIBADD = \
libabrt_web_la_SOURCES = \
abrt_curl.h abrt_curl.c \
abrt_xmlrpc.h abrt_xmlrpc.c \
- proxies.h proxies.c json.c
+ proxies.h proxies.c \
+ ureport.h json.c
libabrt_web_la_CPPFLAGS = \
-Wall -Wwrite-strings -Werror \
-I$(srcdir)/../include \
diff --git a/src/lib/json.c b/src/lib/json.c
index 6d4d72a..659eda2 100644
--- a/src/lib/json.c
+++ b/src/lib/json.c
@@ -22,6 +22,7 @@
#include <btparser/core-backtrace.h>
#include "internal_libreport.h"
+#include "ureport.h"
#include "abrt_curl.h"
@@ -250,12 +251,14 @@ char *new_json_ureport(problem_data_t *pd)
return j;
}
-abrt_post_state_t *post_ureport(problem_data_t *pd, const char *ureport_url)
+struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config)
{
- abrt_post_state_t *post_state;
- post_state = new_abrt_post_state(ABRT_POST_WANT_BODY
- | ABRT_POST_WANT_SSL_VERIFY
- | ABRT_POST_WANT_ERROR_MSG);
+ int flags = ABRT_POST_WANT_BODY | ABRT_POST_WANT_ERROR_MSG;
+
+ if (config->ur_ssl_verify)
+ flags |= ABRT_POST_WANT_SSL_VERIFY;
+
+ abrt_post_state_t *post_state = new_abrt_post_state(flags);
static const char *headers[] = {
"Accept: application/json",
@@ -265,7 +268,7 @@ abrt_post_state_t *post_ureport(problem_data_t *pd, const char *ureport_url)
char *json_ureport = new_json_ureport(pd);
- abrt_post_string_as_form_data(post_state, ureport_url, "application/json",
+ abrt_post_string_as_form_data(post_state, config->ur_url, "application/json",
headers, json_ureport);
free(json_ureport);
diff --git a/src/lib/ureport.h b/src/lib/ureport.h
new file mode 100644
index 0000000..b1b1d89
--- /dev/null
+++ b/src/lib/ureport.h
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 2012 ABRT team
+ Copyright (C) 2012 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 UREPORT_H_
+#define UREPORT_H_
+
+#include "problem_data.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * uReport server configuration
+ */
+struct ureport_server_config
+{
+ const char *ur_url; ///< Web service URL
+ bool ur_ssl_verify; ///< Verify HOST and PEER certificates
+};
+
+struct abrt_post_state;
+
+#define post_ureport libreport_post_ureport
+struct abrt_post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/plugins/report_uReport.xml.in b/src/plugins/report_uReport.xml.in
index 77b5880..988db55 100644
--- a/src/plugins/report_uReport.xml.in
+++ b/src/plugins/report_uReport.xml.in
@@ -13,5 +13,10 @@
<_description>Address of uReport webservice</_description>
<default-value>https://retrace.fedoraproject.org/faf/reports/new/</default-value>
</option>
+ <option type="bool" name="uReport_SSLVerify">
+ <_label>Verify SSL</_label>
+ <_description>Check SSL key validity</_description>
+ <default-value>yes</default-value>
+ </option>
</options>
</event>
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index 21dc58d..5ffcea3 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -19,17 +19,10 @@
#include <json/json.h>
#include "internal_libreport.h"
+#include "ureport.h"
#include "abrt_curl.h"
/*
- * uReport server configuration
- */
-struct ureport_server_config
-{
- const char *url; ///< Web service URL
-};
-
-/*
* Loads uReport configuration from various sources.
*
* Replaces a value of an already configured option only if the
@@ -42,7 +35,10 @@ static void load_ureport_server_config(struct ureport_server_config *config)
const char *environ;
environ = getenv("uReport_URL");
- config->url = environ ? environ : config->url;
+ config->ur_url = environ ? environ : config->ur_url;
+
+ environ = getenv("uReport_SSLVerify");
+ config->ur_ssl_verify = environ ? string_to_bool(environ) : config->ur_ssl_verify;
}
@@ -93,19 +89,23 @@ int main(int argc, char **argv)
abrt_init(argv);
struct ureport_server_config config = {
- .url = "https://retrace.fedoraproject.org/faf/reports/new/",
+ .ur_url = "https://retrace.fedoraproject.org/faf/reports/new/",
+ .ur_ssl_verify = true,
};
+ bool insecure = !config.ur_ssl_verify;
const char *dump_dir_path = ".";
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT__DUMP_DIR(&dump_dir_path),
- OPT_STRING('u', "url", &config.url, "URL", _("Specify url")),
+ OPT_STRING('u', "url", &config.ur_url, "URL", _("Specify url")),
+ OPT_BOOL('k', "insecure", &insecure,
+ _("Allow insecure connection to ureport server")),
OPT_END(),
};
const char *program_usage_string = _(
- "& [-v] -d DIR\n"
+ "& [-v] [-u URL] [-k] -d DIR\n"
"\n"
"Upload micro report"
);
@@ -115,6 +115,7 @@ int main(int argc, char **argv)
if (!dd)
xfunc_die();
+ config.ur_ssl_verify = !insecure;
load_ureport_server_config(&config);
problem_data_t *pd = create_problem_data_from_dump_dir(dd);
@@ -123,7 +124,7 @@ int main(int argc, char **argv)
xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */
abrt_post_state_t *post_state = NULL;
- post_state = post_ureport(pd, config.url);
+ post_state = post_ureport(pd, &config);
free_problem_data(pd);
if (post_state->http_resp_code != 200)
@@ -131,7 +132,7 @@ int main(int argc, char **argv)
char *errmsg = post_state->curl_error_msg;
if (errmsg && *errmsg)
{
- error_msg("%s '%s'", errmsg, config.url);
+ error_msg("%s '%s'", errmsg, config.ur_url);
free_abrt_post_state(post_state);
return 1;
}
--
1.7.7.6
11 years, 11 months
[PATCH v4] rhbz#747410 : bugzillas are created according to rh bugzilla default template
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/internal_libreport.h | 4 +
src/lib/make_descr.c | 43 ++++++---
src/plugins/reporter-bugzilla.c | 2 +-
src/plugins/rhbz.c | 201 ++++++++++++++++++++++++++++++++++----
4 files changed, 216 insertions(+), 34 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index c57bd5f..23a74f9 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -581,6 +581,8 @@ enum {
};
#define make_description libreport_make_description
char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags);
+#define make_description_item_multiline libreport_make_description_item_multiline
+char *make_description_item_multiline(const char *name, const char* content);
#define make_description_bz libreport_make_description_bz
char* make_description_bz(problem_data_t *problem_data, unsigned max_text_size);
#define make_description_logger libreport_make_description_logger
@@ -716,6 +718,8 @@ struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name
#define FILENAME_PKG_VERSION "pkg_version"
#define FILENAME_PKG_RELEASE "pkg_release"
#define FILENAME_PKG_ARCH "pkg_arch"
+#define FILENAME_USERNAME "username"
+#define FILENAME_ABRT_VERSION "abrt_version"
// Not stored as files, added "on the fly":
#define CD_DUMPDIR "Directory"
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
index 68133a2..21fb83c 100644
--- a/src/lib/make_descr.c
+++ b/src/lib/make_descr.c
@@ -26,6 +26,27 @@ static bool rejected_name(const char *name, char **v, int flags)
return r;
}
+char *make_description_item_multiline(const char *name, const char *content)
+{
+ char *eol = strchr(content, '\n');
+ if (!eol)
+ return NULL;
+
+ struct strbuf *buf = strbuf_new();
+ strbuf_append_str(buf, name);
+ strbuf_append_str(buf, ":\n");
+ for (;;)
+ {
+ eol = strchrnul(content, '\n');
+ strbuf_append_strf(buf, ":%.*s\n", (int)(eol - content), content);
+ if (*eol == '\0' || eol[1] == '\0')
+ break;
+ content = eol + 1;
+ }
+
+ return strbuf_free_nobuf(buf);
+}
+
char *make_description(problem_data_t *problem_data, char **names_to_skip,
unsigned max_text_size, unsigned desc_flags)
{
@@ -171,24 +192,18 @@ char *make_description(problem_data_t *problem_data, char **names_to_skip,
|| (!strcmp(analyzer, "Kerneloops") && !strcmp(key, FILENAME_BACKTRACE))))
{
char *formatted = format_problem_item(item);
- char *output = formatted ? formatted : item->content;
- char *eol = strchr(output, '\n');
- if (eol)
+ char *output = make_description_item_multiline(key, formatted ? formatted : item->content);
+
+ if (output)
{
if (!empty)
- strbuf_append_char(buf_dsc, '\n');
- strbuf_append_str(buf_dsc, key);
- strbuf_append_str(buf_dsc, ":\n");
- for (;;)
- {
- eol = strchrnul(output, '\n');
- strbuf_append_strf(buf_dsc, ":%.*s\n", (int)(eol - output), output);
- if (*eol == '\0' || eol[1] == '\0')
- break;
- output = eol + 1;
- }
+ strbuf_append_str(buf_dsc, "\n");
+
+ strbuf_append_str(buf_dsc, output);
empty = false;
+ free(output);
}
+
free(formatted);
}
}
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index b96549d..bb59ac7 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
int flags = RHBZ_NOMAIL_NOTIFY;
if (opts & OPT_b)
flags |= RHBZ_ATTACH_BINARY_FILES;
- rhbz_attach_big_files(client, bug_id_str, problem_data, flags);
+ rhbz_attach_files(client, bug_id_str, problem_data, flags);
bz = new_bug_info();
bz->bi_status = xstrdup("NEW");
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 53662e1..8a3e851 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -19,6 +19,11 @@
#include "internal_libreport.h"
#include "rhbz.h"
+#include <btparser/location.h>
+#include <btparser/backtrace.h>
+#include <btparser/thread.h>
+#include <btparser/frame.h>
+#include <btparser/strbuf.h>
#define MAX_HOPS 5
@@ -32,6 +37,78 @@
#define func_entry_str(x)
#endif
+/******************************************************************************/
+/* Global lists used in process of creation a new Bugzilla bug
+ * New bug logic:
+ * 1. 'Description of problem' is FILENAME_COMMENT
+ * 2. 'Version-Release number of selected component' is FILENAME_PACKAGE
+ * 3. 'Additional info' is a concatenation of files listed in ADDITIONAL_INFO_FILES_LIST
+ * 3.1 backtrace is also present in 'Additional info'
+ * - if has size lower than CD_TEXT_ATT_SIZE_BZ then the bactrace is inlined
+ * - otherwise preview of crashed thread stack trace is created
+ * 4. Attached files are the ONLY files which ARE NOT present in g_not_attached_files
+ * As you can see g_not_attached_files consist from some hardcoded files and
+ * files from ADDITIONAL_INFO_FILES_LIST.
+ * Black list for attached files allows us to attach all of files added to
+ * a problem directory by a user.
+ */
+#define INLINED_FILES_LIST\
+ FILENAME_ABRT_VERSION,\
+ FILENAME_RATING,\
+ FILENAME_KERNEL,\
+ FILENAME_CRASH_FUNCTION,\
+ FILENAME_CMDLINE,\
+ FILENAME_TAINTED_LONG
+
+/* Items we want to use in additional info */
+static const char *const g_additional_info_files[] = {
+ /* ! a bunch of file names */
+ INLINED_FILES_LIST,
+ NULL
+};
+
+/* Items we don't want to attach to bz */
+static const char *const g_not_attached_files[] = {
+ CD_DUMPDIR,
+ FILENAME_ANALYZER,
+ FILENAME_PID,
+ FILENAME_PWD,
+ FILENAME_ROOTDIR,
+ FILENAME_BINARY,
+ FILENAME_COREDUMP,
+ FILENAME_DUPHASH,
+ FILENAME_ARCHITECTURE,
+ FILENAME_OS_RELEASE,
+ FILENAME_OS_RELEASE_IN_ROOTDIR,
+ FILENAME_PACKAGE,
+ FILENAME_COMPONENT,
+ FILENAME_COMMENT,
+ FILENAME_HOSTNAME,
+ FILENAME_REASON,
+ FILENAME_UID,
+ FILENAME_REMOTE,
+ FILENAME_TAINTED,
+ FILENAME_TAINTED_SHORT,
+ FILENAME_VMCORE,
+ FILENAME_UUID,
+ FILENAME_COUNT,
+ FILENAME_REPORTED_TO,
+ FILENAME_NOT_REPORTABLE,
+ FILENAME_PKG_EPOCH,
+ FILENAME_PKG_NAME,
+ FILENAME_PKG_VERSION,
+ FILENAME_PKG_RELEASE,
+ FILENAME_PKG_ARCH,
+ FILENAME_REMOTE_RESULT,
+ FILENAME_USERNAME,
+ FILENAME_TIME,
+ FILENAME_EXECUTABLE,
+ /* ! a bunch of file names */
+ INLINED_FILES_LIST,
+ NULL
+};
+/******************************************************************************/
+
struct bug_info *new_bug_info()
{
func_entry();
@@ -461,6 +538,62 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
return bz;
}
+/*
+ * Produces an optimal backtrace for bugzilla comment
+ */
+char *rhbz_get_backtrace_info(problem_data_t *problem_data, size_t max_text_size)
+{
+ const problem_item *item = get_problem_data_item_or_NULL(problem_data,
+ FILENAME_BACKTRACE);
+
+ if (!item)
+ return NULL;
+
+ char *truncated = NULL;
+
+ if (strlen(item->content) >= max_text_size)
+ {
+ struct btp_location location;
+ btp_location_init(&location);
+
+ /* btp_backtrace_parse modifies the input parameter */
+ char *content = item->content;
+ struct btp_backtrace *backtrace = btp_backtrace_parse((const char **)&content, &location);
+
+ if (!backtrace)
+ {
+ log(_("Can't parse backtrace"));
+ return NULL;
+ }
+
+ /* Get optimized thread stack trace for 10 top most frames */
+ struct btp_thread *thread = btp_backtrace_get_optimized_thread(backtrace, 10);
+
+ btp_backtrace_free(backtrace);
+
+ if (!thread)
+ {
+ log(_("Can't find crash thread"));
+ return NULL;
+ }
+
+ /* Cannot be NULL, it dies on memory error */
+ struct btp_strbuf *bt = btp_strbuf_new();
+
+ btp_thread_append_to_str(thread, bt, true);
+
+ btp_thread_free(thread);
+
+ truncated = btp_strbuf_free_nobuf(bt);
+ }
+
+ char *bt = make_description_item_multiline(truncated ? "truncated backtrace" : FILENAME_BACKTRACE,
+ truncated ? truncated : item->content);
+ free(truncated);
+
+ return bt;
+}
+
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
const char *release)
@@ -520,14 +653,39 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
}
char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
- char *bz_dsc;
+ char *full_dsc = NULL;
if (analyzer && !strcmp(analyzer, "Kerneloops"))
- bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
+ {
+ char *bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
+ full_dsc = xasprintf("libreport version: "VERSION"\n%s", bz_dsc);
+ free(bz_dsc);
+ }
else
- bz_dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ);
-
- char *full_dsc = xasprintf("libreport version: "VERSION"\n%s", bz_dsc);
- free(bz_dsc);
+ {
+ const char *comment = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_COMMENT);
+
+ char *bz_dsc = make_description(problem_data, (char**)g_additional_info_files,
+ CD_TEXT_ATT_SIZE_BZ, MAKEDESC_SHOW_MULTILINE | MAKEDESC_WHITELIST);
+
+ char *backtrace = rhbz_get_backtrace_info(problem_data, CD_TEXT_ATT_SIZE_BZ);
+
+ /* Generating of a description according to the RH bugzilla default format:
+ * https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora
+ */
+ full_dsc = xasprintf("Description of problem:\n%s\n\n"
+ "Version-Release number of selected component:\n%s\n\n"
+ "Additional info:\n"
+ "libreport version: "VERSION"\n%s\n"
+ "%s",
+ comment ? comment : "",
+ package,
+ bz_dsc,
+ backtrace ? backtrace : "");
+
+ free(backtrace);
+ free(bz_dsc);
+ }
char *product = NULL;
char *version = NULL;
@@ -631,7 +789,7 @@ int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
}
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
-int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
+int rhbz_attach_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags)
{
func_entry();
@@ -643,26 +801,31 @@ int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
const char *analyzer = get_problem_item_content_or_NULL(problem_data,
FILENAME_ANALYZER);
+ const bool kerneloops = !strcmp(analyzer, "Kerneloops");
+
g_hash_table_iter_init(&iter, problem_data);
while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
{
+ /* The not attached list is used only if analyzer is not Kerneloops.
+ *
+ * For standard bugs:
+ * The not attached list contains files that are used in the description or
+ * in the bug fields and the files which nobody is interested in.
+ */
+ if (!kerneloops && is_in_string_list(name, (char**)g_not_attached_files))
+ continue;
+
if (value->flags & CD_FLAG_TXT)
{
const char *content = value->content;
- if (!strcmp(analyzer, "Kerneloops") && !strcmp(name, FILENAME_BACKTRACE))
- continue;
+ const unsigned len = strlen(content);
- unsigned len = strlen(content);
+ /* Do not attach backtrace in case of Kerneloops */
+ /* For standard bugs, do not attach backtrace shorter than CD_TEXT_ATT_SIZE_BZ */
+ if (!strcmp(name, FILENAME_BACKTRACE) && (kerneloops || len < CD_TEXT_ATT_SIZE_BZ))
+ continue;
- // We were special-casing FILENAME_BACKTRACE here, but karel says
- // he can retrieve it in inlined form from comments too.
- if (len > CD_TEXT_ATT_SIZE_BZ /*|| (strcmp(name, FILENAME_BACKTRACE) == 0)*/)
- {
- /* This text item wasn't added in comments, it is too big
- * for that. Attach it as a file.
- */
- rhbz_attach_blob(ax, name, bug_id, content, len, flags);
- }
+ rhbz_attach_blob(ax, name, bug_id, content, len, flags);
}
if ((flags & RHBZ_ATTACH_BINARY_FILES) && (value->flags & CD_FLAG_BIN))
{
--
1.7.7.6
11 years, 11 months